changeset 8490:ea1981f65b3a

merge with crew
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sun, 17 May 2009 23:07:23 +0200
parents 1a96f1d9599b (diff) 338412820a57 (current diff)
children bd45047afaeb
files
diffstat 3 files changed, 35 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sun May 17 22:52:45 2009 +0200
+++ b/mercurial/cmdutil.py	Sun May 17 23:07:23 2009 +0200
@@ -252,10 +252,9 @@
 def matchfiles(repo, files):
     return _match.exact(repo.root, repo.getcwd(), files)
 
-def findrenames(repo, added=None, removed=None, threshold=0.5):
+def findrenames(repo, match=None, threshold=0.5):
     '''find renamed files -- yields (before, after, score) tuples'''
-    if added is None or removed is None:
-        added, removed = repo.status()[1:3]
+    added, removed = repo.status(match=match)[1:3]
     ctx = repo['.']
     for a in added:
         aa = repo.wread(a)
@@ -286,7 +285,6 @@
     if similarity is None:
         similarity = float(opts.get('similarity') or 0)
     add, remove = [], []
-    mapping = {}
     audit_path = util.path_auditor(repo.root)
     m = match(repo, pats, opts)
     for abs in repo.walk(m):
@@ -300,23 +298,21 @@
         exact = m.exact(abs)
         if good and abs not in repo.dirstate:
             add.append(abs)
-            mapping[abs] = rel, m.exact(abs)
             if repo.ui.verbose or not exact:
                 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs))
         if repo.dirstate[abs] != 'r' and (not good or not util.lexists(target)
             or (os.path.isdir(target) and not os.path.islink(target))):
             remove.append(abs)
-            mapping[abs] = rel, exact
             if repo.ui.verbose or not exact:
                 repo.ui.status(_('removing %s\n') % ((pats and rel) or abs))
     if not dry_run:
         repo.remove(remove)
         repo.add(add)
     if similarity > 0:
-        for old, new, score in findrenames(repo, add, remove, similarity):
-            oldrel, oldexact = mapping[old]
-            newrel, newexact = mapping[new]
+        for old, new, score in findrenames(repo, m, similarity):
+            oldexact, newexact = m.exact(old), m.exact(new)
             if repo.ui.verbose or not oldexact or not newexact:
+                oldrel, newrel = m.rel(old), m.rel(new)
                 repo.ui.status(_('recording removal of %s as rename to %s '
                                  '(%d%% similar)\n') %
                                (oldrel, newrel, score * 100))
--- a/tests/test-addremove-similar	Sun May 17 22:52:45 2009 +0200
+++ b/tests/test-addremove-similar	Sun May 17 23:07:23 2009 +0200
@@ -46,4 +46,22 @@
 hg addremove -s -1
 hg addremove -s 1e6
 
+cd ..
+
+echo '% issue 1527'
+hg init rep3; cd rep3
+mkdir d
+echo a > d/a
+hg add d/a
+hg commit -m 1
+
+mv d/a d/b
+hg addremove -s80
+hg debugstate
+mv d/b c
+echo "% no copies found here (since the target isn't in d"
+hg addremove -s80 d
+echo "% copies here"
+hg addremove -s80
+
 true
--- a/tests/test-addremove-similar.out	Sun May 17 22:52:45 2009 +0200
+++ b/tests/test-addremove-similar.out	Sun May 17 23:07:23 2009 +0200
@@ -18,3 +18,15 @@
 abort: similarity must be a number
 abort: similarity must be between 0 and 100
 abort: similarity must be between 0 and 100
+% issue 1527
+removing d/a
+adding d/b
+recording removal of d/a as rename to d/b (100% similar)
+r   0          0 1970-01-01 00:00:00 d/a
+a   0         -1 unset               d/b
+copy: d/a -> d/b
+% no copies found here (since the target isn't in d
+removing d/b
+% copies here
+adding c
+recording removal of d/a as rename to c (100% similar)