[PATCH 2 of 3 V2] changegroup: progress for added files is not measured in "chunks"

Martin von Zweigbergk martinvonz at google.com
Mon Feb 29 12:31:58 EST 2016


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1456728667 28800
#      Sun Feb 28 22:51:07 2016 -0800
# Node ID 59b9ced20093cd7d0999111dda9910636d366cb0
# Parent  37f0bbe9fd420eff5487aaa5e499a34f1fa9c902
changegroup: progress for added files is not measured in "chunks"

The "prog" class cg1unpacker.apply() has the unit set to
"chunks". This is not correct for files, where the file itself is the
unit. The unit is not usually printed, which is probably why this has
not been fixed yet. It can be show with e.g. "--config
progress.format='topic number unit'".

diff -r 37f0bbe9fd42 -r 59b9ced20093 mercurial/changegroup.py
--- a/mercurial/changegroup.py	Sun Feb 28 21:15:06 2016 -0800
+++ b/mercurial/changegroup.py	Sun Feb 28 22:51:07 2016 -0800
@@ -394,9 +394,8 @@
 
                 # process the files
                 repo.ui.status(_("adding file changes\n"))
-                pr = prog(_('files'), efiles)
                 newrevs, newfiles = _addchangegroupfiles(
-                    repo, self, revmap, trp, pr, needfiles)
+                    repo, self, revmap, trp, efiles, needfiles)
                 revisions += newrevs
                 files += newfiles
 
@@ -1068,16 +1067,18 @@
     # to avoid a race we use changegroupsubset() (issue1320)
     return changegroupsubset(repo, basenodes, repo.heads(), source)
 
-def _addchangegroupfiles(repo, source, revmap, trp, pr, needfiles):
+def _addchangegroupfiles(repo, source, revmap, trp, expectedfiles, needfiles):
     revisions = 0
     files = 0
     while True:
         chunkdata = source.filelogheader()
         if not chunkdata:
             break
+        files += 1
         f = chunkdata["filename"]
         repo.ui.debug("adding %s revisions\n" % f)
-        pr()
+        repo.ui.progress(_('files'), files, unit=_('files'),
+                         total=expectedfiles)
         fl = repo.file(f)
         o = len(fl)
         try:
@@ -1086,7 +1087,6 @@
         except error.CensoredBaseError as e:
             raise error.Abort(_("received delta base is censored: %s") % e)
         revisions += len(fl) - o
-        files += 1
         if f in needfiles:
             needs = needfiles[f]
             for new in xrange(o, len(fl)):


More information about the Mercurial-devel mailing list