[PATCH 03 of 11] merge: handle subrepo merges and .hgsubstate specially

Bryan O'Sullivan bos at serpentine.com
Sat Feb 9 08:06:43 CST 2013


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1360418465 0
# Node ID e4a245ec89c65f2ceaf1f2c3e22f5981efc2ca5f
# Parent  a56cf72522f2d60eacaeb47392e4c9127277cc4c
merge: handle subrepo merges and .hgsubstate specially

In an upcoming patch, we will update .hgsubstate in a non-interactive
worker process. Merges of subrepo contents will still need to occur in the
master process (since they may be interactive), so we move that code into
a place where it will always run in what will become the master process.

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -314,10 +314,9 @@ def manifestmerge(repo, p1, p2, pa, over
 def actionkey(a):
     return a[1] == "r" and -1 or 0, a
 
-def getremove(repo, wctx, mctx, overwrite, args):
+def getremove(repo, mctx, overwrite, args):
     """apply usually-non-interactive updates to the working directory
 
-    wctx is the working copy context
     mctx is the context to be merged into the working copy
 
     yields tuples for progress updates
@@ -327,8 +326,6 @@ def getremove(repo, wctx, mctx, overwrit
         f = arg[0]
         if arg[1] == 'r':
             repo.ui.note(_("removing %s\n") % f)
-            if f == '.hgsubstate': # subrepo states need updating
-                subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
             audit(f)
             try:
                 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
@@ -338,8 +335,6 @@ def getremove(repo, wctx, mctx, overwrit
         else:
             repo.ui.note(_("getting %s\n") % f)
             repo.wwrite(f, mctx.filectx(f).data(), arg[2][0])
-            if f == '.hgsubstate': # subrepo states need updating
-                subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
         yield i, f
 
 def applyupdates(repo, actions, wctx, mctx, actx, overwrite):
@@ -398,10 +393,17 @@ def applyupdates(repo, actions, wctx, mc
     removed = len([a for a in workeractions if a[1] == 'r'])
     actions = [a for a in actions if a[1] not in 'gr']
 
-    for i, item in getremove(repo, wctx, mctx, overwrite, workeractions):
+    hgsub = [a[1] for a in workeractions if a[0] == '.hgsubstate']
+    if hgsub and hgsub[0] == 'r':
+        subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
+
+    for i, item in getremove(repo, mctx, overwrite, workeractions):
         repo.ui.progress(_('updating'), i + 1, item=item, total=numupdates,
                          unit=_('files'))
 
+    if hgsub and hgsub[0] == 'g':
+        subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
+
     z = len(workeractions)
 
     for i, a in enumerate(actions):


More information about the Mercurial-devel mailing list