Patchwork [3,of,5,v2] summary: report other parent from mergestate

login
register
mail settings
Submitter timeless@mozdev.org
Date March 23, 2016, 3:23 a.m.
Message ID <4bff81fb8154285cf1c9.1458703438@waste.org>
Download mbox | patch
Permalink /patch/14038/
State Changes Requested
Headers show

Comments

timeless@mozdev.org - March 23, 2016, 3:23 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1458698262 0
#      Wed Mar 23 01:57:42 2016 +0000
# Node ID 4bff81fb8154285cf1c9a335d6700eab7cc81bb1
# Parent  a0537de695eedc01bd2e3dc847324b8d01b8c0ef
summary: report other parent from mergestate

In some special instances, 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...
Pierre-Yves David - March 29, 2016, 6:32 p.m.
On 03/22/2016 08:23 PM, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1458698262 0
> #      Wed Mar 23 01:57:42 2016 +0000
> # Node ID 4bff81fb8154285cf1c9a335d6700eab7cc81bb1
> # Parent  a0537de695eedc01bd2e3dc847324b8d01b8c0ef
> summary: report other parent from mergestate
>
> In some special instances, 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...

Do you know what these special cases are? Having some more details would 
help us being confident than 'source' is the right name.

Cheers,
timeless - March 30, 2016, 6 p.m.
backout, update, and unshelve.

I've updated the commit message, but I'll wait to resend on you
deciding what I should do w/ 4 of 5 ...

On Tue, Mar 29, 2016 at 2:32 PM, Pierre-Yves David
<pierre-yves.david@ens-lyon.org> wrote:
>
>
> On 03/22/2016 08:23 PM, timeless wrote:
>>
>> # HG changeset patch
>> # User timeless <timeless@mozdev.org>
>> # Date 1458698262 0
>> #      Wed Mar 23 01:57:42 2016 +0000
>> # Node ID 4bff81fb8154285cf1c9a335d6700eab7cc81bb1
>> # Parent  a0537de695eedc01bd2e3dc847324b8d01b8c0ef
>> summary: report other parent from mergestate
>>
>> In some special instances, 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...
>
>
> Do you know what these special cases are? Having some more details would
> help us being confident than 'source' is the right name.
>
> Cheers,
>
> --
> Pierre-Yves David
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Pierre-Yves David - March 31, 2016, 11:46 p.m.
On 03/30/2016 11:00 AM, timeless wrote:
> backout, update, and unshelve.
>
> I've updated the commit message, but I'll wait to resend on you
> deciding what I should do w/ 4 of 5 ...

Can you add a comment inline also, the next person reading the code will 
get confused by this too.

Do we have to use "source" in all case or could we have a more precised 
work for each action?
timeless - April 1, 2016, 2:55 a.m.
Pierre-Yves David wrote:
> Can you add a comment inline also, the next person reading the code will get
> confused by this too.

Yes.

> Do we have to use "source" in all case or could we have a more precised work
> for each action?

I don't think we know this today. It might be possible using the other
work going on in this area -- but it would only apply to new
mergestates and not ones generated by older versions of Mercurial.
Pierre-Yves David - April 1, 2016, 2:58 a.m.
On 03/31/2016 07:55 PM, timeless wrote:
> Pierre-Yves David wrote:
>> Can you add a comment inline also, the next person reading the code will get
>> confused by this too.
>
> Yes.
>
>> Do we have to use "source" in all case or could we have a more precised work
>> for each action?
>
> I don't think we know this today. It might be possible using the other
> work going on in this area -- but it would only apply to new
> mergestates and not ones generated by older versions of Mercurial.

Which is fine since older version of mercurial will not display it 
either ;-)

This would seems like a good next step here.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6584,11 +6584,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():
@@ -6596,12 +6597,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
@@ -866,6 +866,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)