changeset 38537:a3be09e277e9

fix: add progress bar for number of file revisions processed This ensures responsiveness when the configured tools are slow or numerous. Differential Revision: https://phab.mercurial-scm.org/D3848
author Danny Hooper <hooper@google.com>
date Tue, 26 Jun 2018 16:29:55 -0700
parents 5ffe2041d427
children 2f7104984857
files hgext/fix.py
diffstat 1 files changed, 19 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/fix.py	Tue Jun 26 15:30:49 2018 -0700
+++ b/hgext/fix.py	Tue Jun 26 16:29:55 2018 -0700
@@ -162,22 +162,25 @@
         filedata = collections.defaultdict(dict)
         replacements = {}
         commitorder = sorted(revstofix, reverse=True)
-        for rev, path, newdata in results:
-            if newdata is not None:
-                filedata[rev][path] = newdata
-            numitems[rev] -= 1
-            # Apply the fixes for this and any other revisions that are ready
-            # and sitting at the front of the queue. Using a loop here prevents
-            # the queue from being blocked by the first revision to be ready out
-            # of order.
-            while commitorder and not numitems[commitorder[-1]]:
-                rev = commitorder.pop()
-                ctx = repo[rev]
-                if rev == wdirrev:
-                    writeworkingdir(repo, ctx, filedata[rev], replacements)
-                else:
-                    replacerev(ui, repo, ctx, filedata[rev], replacements)
-                del filedata[rev]
+        with ui.makeprogress(topic=_('fixing'), unit=_('files'),
+                             total=sum(numitems.values())) as progress:
+            for rev, path, newdata in results:
+                progress.increment(item=path)
+                if newdata is not None:
+                    filedata[rev][path] = newdata
+                numitems[rev] -= 1
+                # Apply the fixes for this and any other revisions that are
+                # ready and sitting at the front of the queue. Using a loop here
+                # prevents the queue from being blocked by the first revision to
+                # be ready out of order.
+                while commitorder and not numitems[commitorder[-1]]:
+                    rev = commitorder.pop()
+                    ctx = repo[rev]
+                    if rev == wdirrev:
+                        writeworkingdir(repo, ctx, filedata[rev], replacements)
+                    else:
+                        replacerev(ui, repo, ctx, filedata[rev], replacements)
+                    del filedata[rev]
 
         replacements = {prec: [succ] for prec, succ in replacements.iteritems()}
         scmutil.cleanupnodes(repo, replacements, 'fix', fixphase=True)