# HG changeset patch # User Benoit Boissinot # Date 1242593477 -7200 # Node ID 1a96f1d9599b96cfa220606b9a758a6032b29cea # Parent 4e1795cf6e94b53b6a54677ddc7e377cc1789cc7 addremove/findrenames: find renames according to the match object (issue1527) Instead of only finding similarities in the added/removed files found by the addremove step, follow the match object: hg addremove -s80 foo -> add and removes files in foo + find similarities between files in foo hg addremove -s80 -> add and removes files in the whole repo + find similarities between files in the whole repo hg import --similarity will still work correctly (only find similarities between files found in the patch). diff -r 4e1795cf6e94 -r 1a96f1d9599b mercurial/cmdutil.py --- a/mercurial/cmdutil.py Sun May 17 22:40:04 2009 +0200 +++ b/mercurial/cmdutil.py Sun May 17 22:51:17 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) @@ -310,7 +309,7 @@ repo.remove(remove) repo.add(add) if similarity > 0: - for old, new, score in findrenames(repo, add, remove, similarity): + 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) diff -r 4e1795cf6e94 -r 1a96f1d9599b tests/test-addremove-similar --- a/tests/test-addremove-similar Sun May 17 22:40:04 2009 +0200 +++ b/tests/test-addremove-similar Sun May 17 22:51:17 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 diff -r 4e1795cf6e94 -r 1a96f1d9599b tests/test-addremove-similar.out --- a/tests/test-addremove-similar.out Sun May 17 22:40:04 2009 +0200 +++ b/tests/test-addremove-similar.out Sun May 17 22:51:17 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)