remotefilelog: use progress helper in shallowbundle
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 04 Dec 2018 16:31:04 -0800
changeset 53609 4e08bbfc6d51bc51e1faa99f3675a42a4aeba501
parent 53608 b80915b524768563caac2516a5576723208c4c6e
child 53610 b6a6dc1a14bd0b51e5015d12b426aaa96e2cdcba
push id1079
push usergszorc@mozilla.com
push dateMon, 10 Dec 2018 19:44:59 +0000
remotefilelog: use progress helper in shallowbundle Differential Revision: https://phab.mercurial-scm.org/D5379
hgext/remotefilelog/shallowbundle.py
--- a/hgext/remotefilelog/shallowbundle.py
+++ b/hgext/remotefilelog/shallowbundle.py
@@ -166,37 +166,36 @@ def makechangegroup(orig, repo, outgoing
         return orig(repo, outgoing, version, source, *args, **kwargs)
     finally:
         repo.shallowmatch = original
 
 def addchangegroupfiles(orig, repo, source, revmap, trp, expectedfiles, *args):
     if not shallowutil.isenabled(repo):
         return orig(repo, source, revmap, trp, expectedfiles, *args)
 
-    files = 0
     newfiles = 0
     visited = set()
     revisiondatas = {}
     queue = []
 
     # Normal Mercurial processes each file one at a time, adding all
     # the new revisions for that file at once. In remotefilelog a file
     # revision may depend on a different file's revision (in the case
     # of a rename/copy), so we must lay all revisions down across all
     # files in topological order.
 
     # read all the file chunks but don't add them
+    progress = repo.ui.makeprogress(_('files'), total=expectedfiles)
     while True:
         chunkdata = source.filelogheader()
         if not chunkdata:
             break
-        files += 1
         f = chunkdata["filename"]
         repo.ui.debug("adding %s revisions\n" % f)
-        repo.ui.progress(_('files'), files, total=expectedfiles)
+        progress.increment()
 
         if not repo.shallowmatch(f):
             fl = repo.file(f)
             deltas = source.deltaiter()
             fl.addgroup(deltas, revmap, trp)
             continue
 
         chain = None
@@ -284,11 +283,11 @@ def addchangegroupfiles(orig, repo, sour
             if p != nullid:
                 if not available(f, node, f, p):
                     continue
 
         fl.add(text, meta, trp, linknode, p1, p2)
         processed.add((f, node))
         skipcount = 0
 
-    repo.ui.progress(_('files'), None)
+    progress.complete()
 
     return len(revisiondatas), newfiles