changegroup: progress for added files is not measured in "chunks"
authorMartin von Zweigbergk <martinvonz@google.com>
Sun, 28 Feb 2016 22:51:07 -0800
changeset 28361 277a22cd8741
parent 28360 11287888ce4b
child 28363 1f94ef2bd88d
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'".
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)):