[PATCH 1 of 3] summary: report other parent from mergestate

timeless timeless at mozdev.org
Mon Apr 4 05:13:37 EDT 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1458698262 0
#      Wed Mar 23 01:57:42 2016 +0000
# Node ID 351a972e12d3fae7e291bb8ce61b2a2e9f0225d6
# Parent  ff0d3b6b287f89594bd8d0308fe2810d2a18ea01
summary: report other parent from mergestate

In some special instances (backout, update, unshelve), mergestate
will have an additional parent not reported by `hg parents`, this
parent is important, so let's report it.

Unfortunately, we can't call it a "parent", so we'll say "source"
instead...

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6595,11 +6595,12 @@
     else:
         unresolved = [f for f in ms if ms[f] == 'u']
 
-    for p in parents:
+    conflicts = ms is not None and ms.active()
+    localctx = otherctx = repo[nullrev]
+    def shownode(label, p):
         # label with log.changeset (instead of log.parent) since this
         # shows a working directory parent *changeset*:
-        # i18n: column positioning for "hg summary"
-        ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
+        ui.write(label % (p.rev(), str(p)),
                  label='log.changeset changeset.%s' % p.phasestr())
         ui.write(' '.join(p.tags()), label='log.tag')
         if p.bookmarks():
@@ -6607,12 +6608,34 @@
         if p.rev() == -1:
             if not len(repo):
                 ui.write(_(' (empty repository)'))
+            elif conflicts:
+                ui.write(_(' (no associated revision)'))
             else:
                 ui.write(_(' (no revision checked out)'))
         ui.write('\n')
         if p.description():
             ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
                       label='log.summary')
+    sources = []
+    if conflicts:
+        nodes = set(parents)
+        try:
+            localctx = ms.localctx
+        except error.RepoLookupError:
+            pass
+        try:
+            otherctx = ms.otherctx
+        except error.RepoLookupError:
+            pass
+        sources = [localctx, otherctx]
+    for p in parents:
+        # i18n: column positioning for "hg summary"
+        shownode(_('parent: %d:%s '), p)
+    for p in sources:
+        if not p in nodes:
+            nodes.add(p)
+            # i18n: column positioning for "hg summary"
+            shownode(_('source: %d:%s '), p)
 
     branch = ctx.branch()
     bheads = repo.branchheads(branch)
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -82,6 +82,8 @@
   $ hg summary
   parent: 4:ed99997b793d tip
    ypples
+  source: 1:22cb4f70d813 
+   chair
   branch: default
   commit: 1 unresolved (clean)
   update: (current)
@@ -705,6 +707,8 @@
   $ hg summary
   parent: 2:b71750c4b0fd tip
    capital ten
+  source: 0:a30dd8addae3 
+   initial
   branch: default
   commit: 1 unresolved (clean)
   update: (current)
@@ -724,6 +728,8 @@
   $ hg summary
   parent: 2:b71750c4b0fd tip
    capital ten
+  source: 0:a30dd8addae3 
+   initial
   branch: default
   commit: 1 modified, 1 unknown
   update: (current)
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -867,6 +867,7 @@
   $ hg summary
   parent: 4:33f7f61e6c5e tip
    create conflict
+  source: -1:000000000000  (no associated revision)
   branch: default
   bookmarks: *test
   commit: 2 unknown (clean)
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -491,6 +491,8 @@
   $ hg sum
   parent: 1:76dcf9fab855 tip
    b
+  source: 0:9ab35a2d17cb 
+   a
   branch: default
   commit: 1 modified, 1 unknown, 1 unresolved
   update: (current)


More information about the Mercurial-devel mailing list