[PATCH 04 of 10] summary: separate checking incoming/outgoing and showing remote summary
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Wed Mar 5 06:12:09 CST 2014
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1394019743 -32400
# Wed Mar 05 20:42:23 2014 +0900
# Node ID 4f6db8a3e6fde9810d0db5ec8714c46acd79e71f
# Parent b666a143d9d1958ee35a66d66354f4fdab81967e
summary: separate checking incoming/outgoing and showing remote summary
This patch separates checking incoming/outgoing and showing remote
summary, as a preparation for refactoring in succeeding patches,
because:
- checking incoming/outgoing may be needed, even if "--remote" is
not specified for "hg summary"
- checking incoming/outgoing may not be needed simultaneously
"hg summary --large" without "--remote" is typical case for these.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5498,7 +5498,11 @@
cmdutil.summaryhooks(ui, repo)
if opts.get('remote'):
- t = []
+ needsincoming, needsoutgoing = True, True
+ else:
+ needsincoming, needsoutgoing = False, False
+
+ def getincoming():
source, branches = hg.parseurl(ui.expandpath('default'))
sbranch = branches[0]
other = hg.peer(repo, {}, source)
@@ -5508,28 +5512,48 @@
ui.debug('comparing with %s\n' % util.hidepassword(source))
repo.ui.pushbuffer()
commoninc = discovery.findcommonincoming(repo, other, heads=revs)
- _common, incoming, _rheads = commoninc
repo.ui.popbuffer()
- if incoming:
- t.append(_('1 or more incoming'))
-
+ return source, sbranch, other, commoninc, commoninc[1]
+
+ if needsincoming:
+ source, sbranch, sother, commoninc, incoming = getincoming()
+ else:
+ source = sbranch = sother = commoninc = incoming = None
+
+ def getoutgoing():
dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
dbranch = branches[0]
revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
if source != dest:
- other = hg.peer(repo, {}, dest)
+ dother = hg.peer(repo, {}, dest)
ui.debug('comparing with %s\n' % util.hidepassword(dest))
+ else:
+ dother = sother
if (source != dest or (sbranch is not None and sbranch != dbranch)):
- commoninc = None
+ common = None
+ else:
+ common = commoninc
if revs:
revs = [repo.lookup(rev) for rev in revs]
repo.ui.pushbuffer()
- outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs,
- commoninc=commoninc)
+ outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
+ commoninc=common)
repo.ui.popbuffer()
+ return dest, dbranch, dother, outgoing
+
+ if needsoutgoing:
+ dest, dbranch, dother, outgoing = getoutgoing()
+ else:
+ dest = dbranch = dother = outgoing = None
+
+ if opts.get('remote'):
+ t = []
+ if incoming:
+ t.append(_('1 or more incoming'))
o = outgoing.missing
if o:
t.append(_('%d outgoing') % len(o))
+ other = dother or sother
if 'bookmarks' in other.listkeys('namespaces'):
lmarks = repo.listkeys('bookmarks')
rmarks = other.listkeys('bookmarks')
More information about the Mercurial-devel
mailing list