remotefilelog: use progress helper in shallowrepo
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 04 Dec 2018 16:32:59 -0800
changeset 53610 b6a6dc1a14bd0b51e5015d12b426aaa96e2cdcba
parent 53609 4e08bbfc6d51bc51e1faa99f3675a42a4aeba501
child 53611 e58cd7ede1c3d21d2cb8216cf948abb3be6f660c
push id1079
push usergszorc@mozilla.com
push dateMon, 10 Dec 2018 19:44:59 +0000
remotefilelog: use progress helper in shallowrepo Differential Revision: https://phab.mercurial-scm.org/D5380
hgext/remotefilelog/shallowrepo.py
--- a/hgext/remotefilelog/shallowrepo.py
+++ b/hgext/remotefilelog/shallowrepo.py
@@ -35,18 +35,16 @@ from . import (
 
 if util.safehasattr(util, '_hgexecutable'):
     # Before 5be286db
     _hgexecutable = util.hgexecutable
 else:
     from mercurial.utils import procutil
     _hgexecutable = procutil.hgexecutable
 
-_prefetching = _('prefetching')
-
 # These make*stores functions are global so that other extensions can replace
 # them.
 def makelocalstores(repo):
     """In-repo stores, like .hg/store/data; can not be discarded."""
     localpath = os.path.join(repo.svfs.vfs.base, 'data')
     if not os.path.exists(localpath):
         os.makedirs(localpath)
 
@@ -228,19 +226,19 @@ def wraprepo(repo):
                 skip = set()
 
             # Copy the skip set to start large and avoid constant resizing,
             # and since it's likely to be very similar to the prefetch set.
             files = skip.copy()
             serverfiles = skip.copy()
             visited = set()
             visited.add(nullrev)
-            revnum = 0
             revcount = len(revs)
-            self.ui.progress(_prefetching, revnum, total=revcount)
+            progress = self.ui.makeprogress(_('prefetching'), total=revcount)
+            progress.update(0)
             for rev in sorted(revs):
                 ctx = repo[rev]
                 if pats:
                     m = scmutil.match(ctx, pats, opts)
                 sparsematch = repo.maybesparsematch(rev)
 
                 mfnode = ctx.manifestnode()
                 mfrev = mfrevlog.rev(mfnode)
@@ -259,22 +257,21 @@ def wraprepo(repo):
                 if sparsematch:
                     diff = (pf for pf in diff if sparsematch(pf[0]))
                 if rev not in localrevs:
                     serverfiles.update(diff)
                 else:
                     files.update(diff)
 
                 visited.add(mfrev)
-                revnum += 1
-                self.ui.progress(_prefetching, revnum, total=revcount)
+                progress.increment()
 
             files.difference_update(skip)
             serverfiles.difference_update(skip)
-            self.ui.progress(_prefetching, None)
+            progress.complete()
 
             # Fetch files known to be on the server
             if serverfiles:
                 results = [(path, hex(fnode)) for (path, fnode) in serverfiles]
                 repo.fileservice.prefetch(results, force=True)
 
             # Fetch files that may or may not be on the server
             if files: