remotefilelog: use progress helper when analyzing repos
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 04 Dec 2018 16:02:56 -0800
changeset 53605 05afb32e93809d983dbb1e89cec50938a9d59dc0
parent 53604 dd1006874a5aa49f03955f438fbab7effddecfbf
child 53606 ad21fbcb1ba5c819925b1c17c9137ec2ad725381
push id1079
push usergszorc@mozilla.com
push dateMon, 10 Dec 2018 19:44:59 +0000
remotefilelog: use progress helper when analyzing repos Differential Revision: https://phab.mercurial-scm.org/D5375
hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -806,24 +806,24 @@ def gcclient(ui, cachepath):
     reposfile = open(repospath, 'r')
     repos = set([r[:-1] for r in reposfile.readlines()])
     reposfile.close()
 
     # build list of useful files
     validrepos = []
     keepkeys = set()
 
-    _analyzing = _("analyzing repositories")
-
     sharedcache = None
     filesrepacked = False
 
     count = 0
+    progress = ui.makeprogress(_("analyzing repositories"), unit="repos",
+                               total=len(repos))
     for path in repos:
-        ui.progress(_analyzing, count, unit="repos", total=len(repos))
+        progress.update(count)
         count += 1
         try:
             path = ui.expandpath(os.path.normpath(path))
         except TypeError as e:
             ui.warn(_("warning: malformed path: %r:%s\n") % (path, e))
             traceback.print_exc()
             continue
         try:
@@ -863,17 +863,17 @@ def gcclient(ui, cachepath):
         if not sharedcache:
             sharedcache = repo.sharedstore
 
         # Compute a keepset which is not garbage collected
         def keyfn(fname, fnode):
             return fileserverclient.getcachekey(reponame, fname, hex(fnode))
         keepkeys = repackmod.keepset(repo, keyfn=keyfn, lastkeepkeys=keepkeys)
 
-    ui.progress(_analyzing, None)
+    progress.complete()
 
     # write list of valid repos back
     oldumask = os.umask(0o002)
     try:
         reposfile = open(repospath, 'w')
         reposfile.writelines([("%s\n" % r) for r in validrepos])
         reposfile.close()
     finally: