Patchwork merge: use labels in subrepo merge

login
register
mail settings
Submitter Simon Farnsworth
Date Oct. 8, 2016, 8:26 a.m.
Message ID <6b8becb59babb6ac9770.1475915175@devvm022.lla2.facebook.com>
Download mbox | patch
Permalink /patch/16909/
State Accepted
Headers show

Comments

Simon Farnsworth - Oct. 8, 2016, 8:26 a.m.
# HG changeset patch
# User Simon Farnsworth <simonfar@fb.com>
# Date 1475915128 25200
#      Sat Oct 08 01:25:28 2016 -0700
# Node ID 6b8becb59babb6ac9770d41551c2e533673b694c
# Parent  91a3c58ecf938ed675f5364b88f0d663f12b0047
merge: use labels in subrepo merge

This is the last place that doesn't respect conflict labels in merge output.
Teach subrepos to use subrepo merge output too.
Pierre-Yves David - Oct. 8, 2016, 8:47 a.m.
On 10/08/2016 10:26 AM, Simon Farnsworth wrote:
> # HG changeset patch
> # User Simon Farnsworth <simonfar@fb.com>
> # Date 1475915128 25200
> #      Sat Oct 08 01:25:28 2016 -0700
> # Node ID 6b8becb59babb6ac9770d41551c2e533673b694c
> # Parent  91a3c58ecf938ed675f5364b88f0d663f12b0047
> merge: use labels in subrepo merge

I've pushed this, I had to update test-subrepo-git.t, test-subrepo.t.

Thanks.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1150,7 +1150,7 @@ 
     numupdates = sum(len(l) for m, l in actions.items() if m != 'k')
 
     if [a for a in actions['r'] if a[0] == '.hgsubstate']:
-        subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
+        subrepo.submerge(repo, wctx, mctx, wctx, overwrite, labels)
 
     # remove in parallel (must come first)
     z = 0
@@ -1168,7 +1168,7 @@ 
     updated = len(actions['g'])
 
     if [a for a in actions['g'] if a[0] == '.hgsubstate']:
-        subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
+        subrepo.submerge(repo, wctx, mctx, wctx, overwrite, labels)
 
     # forget (manifest only, just log it) (must come first)
     for f, args, msg in actions['f']:
@@ -1253,7 +1253,7 @@ 
         progress(_updating, z, item=f, total=numupdates, unit=_files)
         if f == '.hgsubstate': # subrepo states need updating
             subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx),
-                             overwrite)
+                             overwrite, labels)
             continue
         audit(f)
         complete, r = ms.preresolve(f, wctx)
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -26,6 +26,7 @@ 
     config,
     error,
     exchange,
+    filemerge,
     match as matchmod,
     node,
     pathutil,
@@ -174,7 +175,7 @@ 
                                                 if state[s][1] != nullstate[1]]
     repo.wwrite('.hgsubstate', ''.join(lines), '')
 
-def submerge(repo, wctx, mctx, actx, overwrite):
+def submerge(repo, wctx, mctx, actx, overwrite, labels=None):
     """delegated from merge.applyupdates: merging of .hgsubstate file
     in working context, merging context and ancestor context"""
     if mctx == actx: # backwards?
@@ -200,6 +201,8 @@ 
             a = ld
 
         if s in s2:
+            prompts = filemerge.partextras(labels)
+            prompts['s'] = s
             r = s2[s]
             if ld == r or r == a: # no change or local is newer
                 sm[s] = l
@@ -209,10 +212,13 @@ 
                 wctx.sub(s).get(r, overwrite)
                 sm[s] = r
             elif ld[0] != r[0]: # sources differ
+                prompts['lo'] = l[0]
+                prompts['ro'] = r[0]
                 if repo.ui.promptchoice(
-                    _(' subrepository sources for %s differ\n'
-                      'use (l)ocal source (%s) or (r)emote source (%s)?'
-                      '$$ &Local $$ &Remote') % (s, l[0], r[0]), 0):
+                    _(' subrepository sources for %(s)s differ\n'
+                      'use (l)ocal%(l)s source (%(lo)s)'
+                      ' or (r)emote%(o)s source (%(ro)s)?'
+                      '$$ &Local $$ &Remote') % prompts, 0):
                     debug(s, "prompt changed, get", r)
                     wctx.sub(s).get(r, overwrite)
                     sm[s] = r
@@ -223,12 +229,14 @@ 
             else:
                 debug(s, "both sides changed")
                 srepo = wctx.sub(s)
+                prompts['sl'] = srepo.shortid(l[1])
+                prompts['sr'] = srepo.shortid(r[1])
                 option = repo.ui.promptchoice(
-                    _(' subrepository %s diverged (local revision: %s, '
-                      'remote revision: %s)\n'
-                      '(M)erge, keep (l)ocal or keep (r)emote?'
+                    _(' subrepository %(s)s diverged (local revision: %(sl)s, '
+                      'remote revision: %(sr)s)\n'
+                      '(M)erge, keep (l)ocal%(l)s or keep (r)emote%(o)s?'
                       '$$ &Merge $$ &Local $$ &Remote')
-                    % (s, srepo.shortid(l[1]), srepo.shortid(r[1])), 0)
+                    % prompts, 0)
                 if option == 0:
                     wctx.sub(s).merge(r)
                     sm[s] = l
@@ -249,9 +257,10 @@ 
             continue
         else:
             if repo.ui.promptchoice(
-                _(' local changed subrepository %s which remote removed\n'
+                _(' local%(l)s changed subrepository %(s)s'
+                  ' which remote%(o)s removed\n'
                   'use (c)hanged version or (d)elete?'
-                  '$$ &Changed $$ &Delete') % s, 0):
+                  '$$ &Changed $$ &Delete') % prompts, 0):
                 debug(s, "prompt remove")
                 wctx.sub(s).remove()
 
@@ -264,9 +273,10 @@ 
             sm[s] = r
         elif r != sa[s]:
             if repo.ui.promptchoice(
-                _(' remote changed subrepository %s which local removed\n'
+                _(' remote%(o)s changed subrepository %(s)s'
+                  ' which local%(l)s removed\n'
                   'use (c)hanged version or (d)elete?'
-                  '$$ &Changed $$ &Delete') % s, 0) == 0:
+                  '$$ &Changed $$ &Delete') % prompts, 0) == 0:
                 debug(s, "prompt recreate", r)
                 mctx.sub(s).get(r)
                 sm[s] = r
diff --git a/tests/test-largefiles-update.t b/tests/test-largefiles-update.t
--- a/tests/test-largefiles-update.t
+++ b/tests/test-largefiles-update.t
@@ -546,7 +546,7 @@ 
   > l
   > EOF
    subrepository sub diverged (local revision: f74e50bd9e55, remote revision: d65e59e952a9)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for sub differ (in checked out version)
   use (l)ocal source (f74e50bd9e55) or (r)emote source (d65e59e952a9)? r
   remote turned local largefile large2 into a normal file
diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
--- a/tests/test-subrepo-git.t
+++ b/tests/test-subrepo-git.t
@@ -171,7 +171,7 @@ 
   (run 'hg heads' to see heads, 'hg merge' to merge)
   $ hg merge 2>/dev/null
    subrepository s diverged (local revision: 7969594, remote revision: aa84837)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [merge rev]? m
   pulling subrepo s from $TESTTMP/gitroot
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
@@ -507,7 +507,7 @@ 
   $ cd ..
   $ hg update 4
    subrepository s diverged (local revision: da5f5b1, remote revision: aa84837)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for s differ
   use (l)ocal source (da5f5b1) or (r)emote source (aa84837)? l
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -533,7 +533,7 @@ 
   $ cd ..
   $ hg update 1
    subrepository s diverged (local revision: 32a3438, remote revision: da5f5b1)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for s differ (in checked out version)
   use (l)ocal source (32a3438) or (r)emote source (da5f5b1)? l
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -555,7 +555,7 @@ 
   1+
   $ hg update 7
    subrepository s diverged (local revision: 32a3438, remote revision: 32a3438)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for s differ
   use (l)ocal source (32a3438) or (r)emote source (32a3438)? l
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
diff --git a/tests/test-subrepo-svn.t b/tests/test-subrepo-svn.t
--- a/tests/test-subrepo-svn.t
+++ b/tests/test-subrepo-svn.t
@@ -310,7 +310,7 @@ 
   $ cd ..
   $ hg update tip
    subrepository s diverged (local revision: 2, remote revision: 3)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for s differ
   use (l)ocal source (2) or (r)emote source (3)? l
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -341,7 +341,7 @@ 
   $ cd ..
   $ hg update 1
    subrepository s diverged (local revision: 3, remote revision: 2)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for s differ (in checked out version)
   use (l)ocal source (1) or (r)emote source (2)? l
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -364,7 +364,7 @@ 
   1+
   $ hg update tip
    subrepository s diverged (local revision: 3, remote revision: 3)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for s differ
   use (l)ocal source (1) or (r)emote source (3)? l
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -398,7 +398,7 @@ 
   $ cd ..
   $ hg update 1
    subrepository s diverged (local revision: 3, remote revision: 2)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg id -n
   1+
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -303,14 +303,14 @@ 
   subrepo merge e45c8b14af55+ f94576341bcf 1831e14459c4
     subrepo t: both sides changed 
    subrepository t diverged (local revision: 20a0db6fbf6c, remote revision: 7af322bc1198)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  starting 4 threads for background file closing (?)
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [merge rev]? m
   merging subrepo t
     searching for copies back to rev 2
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: 6747d179aa9a, local: 20a0db6fbf6c+, remote: 7af322bc1198
    preserving t for resolve of t
-  starting 4 threads for background file closing (?)
    t: versions differ -> m (premerge)
   picked tool ':merge' for t (binary False symlink False changedelete False)
   merging t
@@ -349,7 +349,7 @@ 
 local removed, remote changed, keep changed
 
   $ hg merge 6
-   remote changed subrepository t which local removed
+   remote [merge rev] changed subrepository s which local [working copy] removed
   use (c)hanged version or (d)elete? c
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
@@ -380,7 +380,7 @@ 
   $ hg merge --config ui.interactive=true 6 <<EOF
   > d
   > EOF
-   remote changed subrepository t which local removed
+   remote [merge rev] changed subrepository s which local [working copy] removed
   use (c)hanged version or (d)elete? d
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
@@ -404,7 +404,7 @@ 
   $ hg co -C 6
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg merge 11
-   local changed subrepository t which remote removed
+   local [working copy] changed subrepository s which remote [merge rev] removed
   use (c)hanged version or (d)elete? c
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
@@ -436,7 +436,7 @@ 
   $ hg merge --config ui.interactive=true 11 <<EOF
   > d
   > EOF
-   local changed subrepository t which remote removed
+   local [working copy] changed subrepository s which remote [merge rev] removed
   use (c)hanged version or (d)elete? d
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
@@ -860,7 +860,7 @@ 
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg merge 4    # try to merge default into br again
    subrepository s diverged (local revision: f8f13b33206e, remote revision: a3f9062a4f88)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [merge rev]? m
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ cd ..
@@ -1129,7 +1129,7 @@ 
   adding file changes
   added 1 changesets with 2 changes to 2 files
    subrepository sub/repo diverged (local revision: f42d5c7504a8, remote revision: 46cd4aac504c)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
   pulling subrepo sub/repo from $TESTTMP/issue1852a/sub/repo (glob)
   searching for changes
   adding changesets
@@ -1238,11 +1238,11 @@ 
   e95bcfa18a35+
   $ hg update tip
    subrepository s diverged (local revision: fc627a69481f, remote revision: 12a213df6fa9)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for s differ
   use (l)ocal source (fc627a69481f) or (r)emote source (12a213df6fa9)? l
    subrepository t diverged (local revision: e95bcfa18a35, remote revision: 52c0adc0515a)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for t differ
   use (l)ocal source (e95bcfa18a35) or (r)emote source (52c0adc0515a)? l
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -1271,9 +1271,9 @@ 
   $ cd ..
   $ hg update 10
    subrepository s diverged (local revision: 12a213df6fa9, remote revision: fc627a69481f)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository t diverged (local revision: 52c0adc0515a, remote revision: 20a0db6fbf6c)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for t differ (in checked out version)
   use (l)ocal source (7af322bc1198) or (r)emote source (20a0db6fbf6c)? l
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -1297,11 +1297,11 @@ 
   7af322bc1198+
   $ hg update tip
    subrepository s diverged (local revision: 12a213df6fa9, remote revision: 12a213df6fa9)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for s differ
   use (l)ocal source (02dcf1d70411) or (r)emote source (12a213df6fa9)? l
    subrepository t diverged (local revision: 52c0adc0515a, remote revision: 52c0adc0515a)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
    subrepository sources for t differ
   use (l)ocal source (7af322bc1198) or (r)emote source (52c0adc0515a)? l
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -1329,7 +1329,7 @@ 
   $ cd ..
   $ hg update 11
    subrepository s diverged (local revision: 12a213df6fa9, remote revision: fc627a69481f)
-  (M)erge, keep (l)ocal or keep (r)emote? m
+  (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg id -n