from mercurial.version import version as v
hgversion = v.get_version()
-try:
- from mercurial.discovery import findcommonincoming
- from mercurial.discovery import findoutgoing
-except:
- def findcommonincoming(repo, remote):
- return repo.findcommonincoming(remote)
- def findoutgoing(repo, remote):
- return repo.findoutgoing(remote)
-
# in Mercurial 1.9 the cmdutil.match and cmdutil.revpair moved to scmutil
if hgversion >= '1.9':
from mercurial import scmutil
except AttributeError:
return ui.prompt(msg, ["&yes", "&no"], "y") != "n"
+def incoming(repo, other):
+ fui = FakeMercurialUI()
+ ret = commands.incoming(fui, repo, *[other.path], **{'bundle': '', 'force': False})
+ if ret and ret != 1:
+ raise util.Abort(ret)
+ out = fui.output
+ return out
+
+def outgoing(repo):
+ fui = FakeMercurialUI()
+ ret = commands.outgoing(fui, repo, *[], **{})
+ if ret and ret != 1:
+ raise util.Abort(ret)
+ out = fui.output
+ return out
+
# To experiment with Mercurial in the python interpreter:
# >>> repo = hg.repository(ui.ui(), path = ".")
os.environ['http_proxy'] = proxy
return other
-def Incoming(ui, repo, opts):
- _, incoming, _ = findcommonincoming(repo, getremote(ui, repo, opts))
- return incoming
-
desc_re = '^(.+: |(tag )?(release|weekly)\.|fix build|undo CL)'
desc_msg = '''Your CL description appears not to use the standard form.
# in that CL.
original_match = None
global_repo = None
+global_ui = None
def ReplacementForCmdutilMatch(ctx, pats=None, opts=None, globbed=False, default='relpath'):
taken = []
files = []
def reposetup(ui, repo):
global original_match
if original_match is None:
- global global_repo
+ global global_repo, global_ui
global_repo = repo
+ global_ui = ui
start_status_thread()
original_match = scmutil.match
scmutil.match = ReplacementForCmdutilMatch
# We already called this on startup but sometimes Mercurial forgets.
set_mercurial_encoding_to_utf8()
+ other = getremote(ui, repo, opts)
repo.ui.quiet = True
- if not opts["no_incoming"] and Incoming(ui, repo, opts):
+ if not opts["no_incoming"] and incoming(repo, other):
return "local repository out of date; must sync before submit"
cl, err = CommandLineCL(ui, repo, pats, opts, defaultcc=defaultcc)
set_status("pushing " + cl.name + " to remote server")
other = getremote(ui, repo, opts)
- if findoutgoing(repo, other):
+ if outgoing(repo):
raise util.Abort("local repository corrupt or out-of-phase with remote: found outgoing changes")
m = match.exact(repo.root, repo.getcwd(), cl.files)
return False
return not mimetype.startswith("text/")
+
class FakeMercurialUI(object):
def __init__(self):
self.quiet = True
def write(self, *args, **opts):
self.output += ' '.join(args)
+ def copy(self):
+ return self
+ def status(self, *args, **opts):
+ pass
+
+ def readconfig(self, *args, **opts):
+ pass
+ def expandpath(self, *args, **opts):
+ return global_ui.expandpath(*args, **opts)
+ def configitems(self, *args, **opts):
+ return global_ui.configitems(*args, **opts)
+ def config(self, *args, **opts):
+ return global_ui.config(*args, **opts)
use_hg_shell = False # set to True to shell out to hg always; slower