PATCH improve cmdutil.findrenames to use threshold

Alil Adamov diagiman at gmail.com
Thu Mar 18 10:19:13 CDT 2010


This activates threshold use in findrenames
it is used in rename guess dialog of TortoiseHg

--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -287,7 +287,7 @@

 def findrenames(repo, added, removed, threshold):
     '''find renamed files -- yields (before, after, score) tuples'''
-    copies = {}
+    copies = []
     ctx = repo['.']
     for i, r in enumerate(removed):
         repo.ui.progress(_('searching'), i, total=len(removed))
@@ -321,5 +321,4 @@
             return equal * 2.0 / lengths

         for a in added:
-            bestscore = copies.get(a, (None, threshold))[1]
             myscore = score(repo.wread(a))
@@ -325,5 +324,5 @@
             myscore = score(repo.wread(a))
-            if myscore >= bestscore:
-                copies[a] = (r, myscore)
+            if myscore >= threshold:
+                copies += [(a, r, myscore)]
     repo.ui.progress(_('searching'), None)

@@ -328,7 +327,6 @@
     repo.ui.progress(_('searching'), None)

-    for dest, v in copies.iteritems():
-        source, score = v
+    for dest, source, score in copies:
         yield source, dest, score

 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None):

--
Regards,
Alil Adamov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100318/bdffdb8d/attachment.htm>


More information about the Mercurial-devel mailing list