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

login
register
mail settings
Submitter Bryan O'Sullivan
Date Feb. 9, 2013, 2:06 p.m.
Message ID <0f7228360de75e966742.1360418804@australite.local>
Download mbox | patch
Permalink /patch/869/
State Superseded
Commit d9ff580fcaa26199ab8d76f35f81169431ce84b3
Headers show

Comments

Bryan O'Sullivan - Feb. 9, 2013, 2:06 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@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.

Patch

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,