[PATCH 04 of 11] merge: report non-interactive progress in chunks

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


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1360418465 0
# Node ID 0f7228360de75e966742d29662ff6984077806ff
# Parent  e4a245ec89c65f2ceaf1f2c3e22f5981efc2ca5f
merge: report non-interactive progress in chunks

Instead of a monotonic count, getupdates yields the number of files it
has updated since it last reported, and its caller sums the numbers
when updating progress.

We also report progress every 100 operations instead of for every
operation. This will become important as soon as we start reporting
progress over a pipe from multiple worker processes.

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -322,7 +322,8 @@ def getremove(repo, mctx, overwrite, arg
     yields tuples for progress updates
     """
     audit = repo.wopener.audit
-    for i, arg in enumerate(args):
+    i = 0
+    for arg in args:
         f = arg[0]
         if arg[1] == 'r':
             repo.ui.note(_("removing %s\n") % f)
@@ -335,6 +336,11 @@ def getremove(repo, mctx, overwrite, arg
         else:
             repo.ui.note(_("getting %s\n") % f)
             repo.wwrite(f, mctx.filectx(f).data(), arg[2][0])
+        if i == 100:
+            yield i, f
+            i = 0
+        i += 1
+    if i > 0:
         yield i, f
 
 def applyupdates(repo, actions, wctx, mctx, actx, overwrite):
@@ -397,15 +403,15 @@ def applyupdates(repo, actions, wctx, mc
     if hgsub and hgsub[0] == 'r':
         subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
 
+    z = 0
     for i, item in getremove(repo, mctx, overwrite, workeractions):
-        repo.ui.progress(_('updating'), i + 1, item=item, total=numupdates,
+        z += i
+        repo.ui.progress(_('updating'), z, 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):
         f, m, args, msg = a
         repo.ui.progress(_('updating'), z + i + 1, item=f, total=numupdates,


More information about the Mercurial-devel mailing list