[PATCH] subrepo: better prompt during merge when subrepo is missing from remote revision

Angel Ezquerra angel.ezquerra at gmail.com
Sat May 21 17:32:45 CDT 2011


# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1301671367 -7200
# Node ID 02375760c833bf678a5601513a5efdd09d9c1ed4
# Parent  2c9f5897d4b7e163502b6ce56287d400da738d89
subrepo: better prompt during merge when subrepo is missing from remote revision

Without this patch, mercurial tells the user that remote removed a subrepo even
if it was in fact added on local.

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -138,12 +138,24 @@
             debug(s, "remote removed, remove")
             wctx.sub(s).remove()
         else:
-            if repo.ui.promptchoice(
-                _(' local changed subrepository %s which remote removed\n'
-                  'use (c)hanged version or (d)elete?') % s,
-                (_('&Changed'), _('&Delete')), 0):
-                debug(s, "prompt remove")
-                wctx.sub(s).remove()
+            if s in sa.keys():
+                # The ancestor contained the subrepo s,
+                # so remote must have removed it
+                if repo.ui.promptchoice(
+                    _(' local changed subrepository %s which remote removed\n'
+                      'use (c)hanged version or (d)elete?') % s,
+                    (_('&Changed'), _('&Delete')), 0):
+                    debug(s, "prompt remove")
+                    wctx.sub(s).remove()                
+            else:
+                # The ancestor did not contain the subrepo s,
+                # so local must have added it
+                if repo.ui.promptchoice(
+                    _(' subrepository %s was added to local but not to remote\n'
+                      '(k)eep subrepository or (d)elete?') % s,
+                    (_('&Keep'), _('&Delete')), 0):
+                    debug(s, "prompt remove")
+                    wctx.sub(s).remove()
 
     for s, r in sorted(s2.items()):
         if s in s1:


More information about the Mercurial-devel mailing list