changeset 38395:59c9d3cc810f

similar: use progress helper A side-effect is that progress is now reported as 1 *before* we start checking the first file. That seems to be how we do it in most places. Also, the right topic is now closed. Differential Revision: https://phab.mercurial-scm.org/D3796
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 17 Jun 2018 23:17:03 -0700
parents f0b0c853f598
children 0ddbe03c5aaa
files mercurial/similar.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/similar.py	Sun Jun 17 23:13:03 2018 -0700
+++ b/mercurial/similar.py	Sun Jun 17 23:17:03 2018 -0700
@@ -75,10 +75,10 @@
     (before, after, score) tuples of partial matches.
     '''
     copies = {}
-    for i, r in enumerate(removed):
-        repo.ui.progress(_('searching for similar files'), i,
-                         total=len(removed), unit=_('files'))
-
+    progress = repo.ui.makeprogress(_('searching for similar files'),
+                         unit=_('files'), total=len(removed))
+    for r in removed:
+        progress.increment()
         data = None
         for a in added:
             bestscore = copies.get(a, (None, threshold))[1]
@@ -87,7 +87,7 @@
             myscore = _score(a, data)
             if myscore > bestscore:
                 copies[a] = (r, myscore)
-    repo.ui.progress(_('searching'), None)
+    progress.complete()
 
     for dest, v in copies.iteritems():
         source, bscore = v