Patchwork D3768: similar: use progress helper

login
register
mail settings
Submitter phabricator
Date June 17, 2018, 6:07 p.m.
Message ID <58bb35c3a6746c51002f46c770778ac2@localhost.localdomain>
Download mbox | patch
Permalink /patch/32225/
State Not Applicable
Headers show

Comments

phabricator - June 17, 2018, 6:07 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGcd196be26cb7: similar: use progress helper (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3768?vs=9131&id=9136

REVISION DETAIL
  https://phab.mercurial-scm.org/D3768

AFFECTED FILES
  mercurial/similar.py
  tests/test-subrepo-deep-nested-change.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t
--- a/tests/test-subrepo-deep-nested-change.t
+++ b/tests/test-subrepo-deep-nested-change.t
@@ -379,7 +379,7 @@ 
   $ touch bar/abc
   $ hg addremove -S ..
   \r (no-eol) (esc)
-  searching for exact renames [                         ] 0/1\r (no-eol) (esc)
+  searching for exact renames [========================>] 1/1\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
   adding ../sub1/sub2/folder/test.txt
   removing ../sub1/sub2/test.txt
diff --git a/mercurial/similar.py b/mercurial/similar.py
--- a/mercurial/similar.py
+++ b/mercurial/similar.py
@@ -18,24 +18,23 @@ 
     Takes a list of new filectxs and a list of removed filectxs, and yields
     (before, after) tuples of exact matches.
     '''
-    numfiles = len(added) + len(removed)
-
     # Build table of removed files: {hash(fctx.data()): [fctx, ...]}.
     # We use hash() to discard fctx.data() from memory.
     hashes = {}
-    for i, fctx in enumerate(removed):
-        repo.ui.progress(_('searching for exact renames'), i, total=numfiles,
-                         unit=_('files'))
+    progress = repo.ui.makeprogress(_('searching for exact renames'),
+                                    total=(len(added) + len(removed)),
+                                    unit=_('files'))
+    for fctx in removed:
+        progress.increment()
         h = hash(fctx.data())
         if h not in hashes:
             hashes[h] = [fctx]
         else:
             hashes[h].append(fctx)
 
     # For each added file, see if it corresponds to a removed file.
-    for i, fctx in enumerate(added):
-        repo.ui.progress(_('searching for exact renames'), i + len(removed),
-                total=numfiles, unit=_('files'))
+    for fctx in added:
+        progress.increment()
         adata = fctx.data()
         h = hash(adata)
         for rfctx in hashes.get(h, []):
@@ -45,7 +44,7 @@ 
                 break
 
     # Done
-    repo.ui.progress(_('searching for exact renames'), None)
+    progress.update(None)
 
 def _ctxdata(fctx):
     # lazily load text