Patchwork [v2,stable] subrepo: move prompts out of the if (issue5505)

login
register
mail settings
Submitter Simon Farnsworth
Date March 20, 2017, 11:37 a.m.
Message ID <43fbb6661cfe57813579.1490009832@devvm022.lla2.facebook.com>
Download mbox | patch
Permalink /patch/19473/
State Accepted
Headers show

Comments

Simon Farnsworth - March 20, 2017, 11:37 a.m.
# HG changeset patch
# User Simon Farnsworth <simonfar@fb.com>
# Date 1490009815 25200
#      Mon Mar 20 04:36:55 2017 -0700
# Branch stable
# Node ID 43fbb6661cfe578135791a3caff1473846c17899
# Parent  10c0ee33853539bd2721a05d4753785c2494d243
subrepo: move prompts out of the if (issue5505)

Prompts weren't available in the else clause
Yuya Nishihara - March 21, 2017, 12:49 p.m.
On Mon, 20 Mar 2017 04:37:12 -0700, Simon Farnsworth wrote:
> # HG changeset patch
> # User Simon Farnsworth <simonfar@fb.com>
> # Date 1490009815 25200
> #      Mon Mar 20 04:36:55 2017 -0700
> # Branch stable
> # Node ID 43fbb6661cfe578135791a3caff1473846c17899
> # Parent  10c0ee33853539bd2721a05d4753785c2494d243
> subrepo: move prompts out of the if (issue5505)

Looks good. Queued for stable, thanks.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -194,7 +194,9 @@ 
             r = "%s:%s:%s" % r
         repo.ui.debug("  subrepo %s: %s %s\n" % (s, msg, r))
 
+    promptssrc = filemerge.partextras(labels)
     for s, l in sorted(s1.iteritems()):
+        prompts = None
         a = sa.get(s, nullstate)
         ld = l # local state with possible dirty flag for compares
         if wctx.sub(s).dirty():
@@ -202,9 +204,9 @@ 
         if wctx == actx: # overwrite
             a = ld
 
+        prompts = promptssrc.copy()
+        prompts['s'] = s
         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
@@ -267,6 +269,7 @@ 
                 wctx.sub(s).remove()
 
     for s, r in sorted(s2.items()):
+        prompts = None
         if s in s1:
             continue
         elif s not in sa:
@@ -274,6 +277,8 @@ 
             mctx.sub(s).get(r)
             sm[s] = r
         elif r != sa[s]:
+            prompts = promptssrc.copy()
+            prompts['s'] = s
             if repo.ui.promptchoice(
                 _(' remote%(o)s changed subrepository %(s)s'
                   ' which local%(l)s removed\n'
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -349,7 +349,7 @@ 
 local removed, remote changed, keep changed
 
   $ hg merge 6
-   remote [merge rev] changed subrepository s which local [working copy] removed
+   remote [merge rev] changed subrepository t 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 [merge rev] changed subrepository s which local [working copy] removed
+   remote [merge rev] changed subrepository t 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 [working copy] changed subrepository s which remote [merge rev] removed
+   local [working copy] changed subrepository t 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 [working copy] changed subrepository s which remote [merge rev] removed
+   local [working copy] changed subrepository t 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)