# HG changeset patch # User Martin von Zweigbergk # Date 2018-06-16 07:25:13 # Node ID cd196be26cb7065e3fd3d09aa8a6df30b34ff092 # Parent 89db59e5cf3ee068e1c9a5f3abf1655b3ca539a4 similar: use progress helper Note that a functional change here is that we now show the progress position *before* we start working on the item. This is consistent with how we do it elsewhere. Differential Revision: https://phab.mercurial-scm.org/D3768 diff --git a/mercurial/similar.py b/mercurial/similar.py --- a/mercurial/similar.py +++ b/mercurial/similar.py @@ -18,14 +18,14 @@ def _findexactmatches(repo, added, remov 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] @@ -33,9 +33,8 @@ def _findexactmatches(repo, added, remov 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 @@ def _findexactmatches(repo, added, remov break # Done - repo.ui.progress(_('searching for exact renames'), None) + progress.update(None) def _ctxdata(fctx): # lazily load text 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 @@ Test relative path printing + subrepos $ 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