[PATCH 5 of 6 V2] similar: take the first match instead of the last
Yuya Nishihara
yuya at tcha.org
Thu Mar 23 10:13:47 EDT 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1490269961 -32400
# Thu Mar 23 20:52:41 2017 +0900
# Node ID d628846ce8182338b112820860b3c7fe4dcbc33d
# Parent 9c622785c2b0a4f4f157dd8ac6a0d0c6816d3725
similar: take the first match instead of the last
It seems more natural. This makes the next patch slightly cleaner.
diff --git a/mercurial/similar.py b/mercurial/similar.py
--- a/mercurial/similar.py
+++ b/mercurial/similar.py
@@ -25,7 +25,7 @@ def _findexactmatches(repo, added, remov
# Get hashes of removed files.
hashes = {}
- for i, fctx in enumerate(removed):
+ for i, fctx in enumerate(reversed(removed)):
repo.ui.progress(_('searching for exact renames'), i, total=numfiles,
unit=_('files'))
h = hashlib.sha1(fctx.data()).digest()
@@ -85,7 +85,7 @@ def _findsimilarmatches(repo, added, rem
if data is None:
data = _ctxdata(r)
myscore = _score(a, data)
- if myscore >= bestscore:
+ if myscore > bestscore:
copies[a] = (r, myscore)
repo.ui.progress(_('searching'), None)
diff --git a/tests/test-addremove-similar.t b/tests/test-addremove-similar.t
--- a/tests/test-addremove-similar.t
+++ b/tests/test-addremove-similar.t
@@ -101,7 +101,7 @@ pick one from many identical files
removing 8
removing 9
adding a
- recording removal of 9 as rename to a (100% similar)
+ recording removal of 0 as rename to a (100% similar)
$ hg revert -aq
pick one from many similar files
@@ -124,7 +124,7 @@ pick one from many similar files
removing 8
removing 9
adding a
- recording removal of 9 as rename to a (99% similar)
+ recording removal of 0 as rename to a (99% similar)
$ hg commit -m 'always the same file should be selected'
should all fail
More information about the Mercurial-devel
mailing list