comparison mercurial/cmdutil.py @ 8489:1a96f1d9599b

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).
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sun, 17 May 2009 22:51:17 +0200
parents 4e1795cf6e94
children ff22d4c3ac04
comparison
equal deleted inserted replaced
8488:4e1795cf6e94 8489:1a96f1d9599b
250 return _match.always(repo.root, repo.getcwd()) 250 return _match.always(repo.root, repo.getcwd())
251 251
252 def matchfiles(repo, files): 252 def matchfiles(repo, files):
253 return _match.exact(repo.root, repo.getcwd(), files) 253 return _match.exact(repo.root, repo.getcwd(), files)
254 254
255 def findrenames(repo, added=None, removed=None, threshold=0.5): 255 def findrenames(repo, match=None, threshold=0.5):
256 '''find renamed files -- yields (before, after, score) tuples''' 256 '''find renamed files -- yields (before, after, score) tuples'''
257 if added is None or removed is None: 257 added, removed = repo.status(match=match)[1:3]
258 added, removed = repo.status()[1:3]
259 ctx = repo['.'] 258 ctx = repo['.']
260 for a in added: 259 for a in added:
261 aa = repo.wread(a) 260 aa = repo.wread(a)
262 bestname, bestscore = None, threshold 261 bestname, bestscore = None, threshold
263 for r in removed: 262 for r in removed:
308 repo.ui.status(_('removing %s\n') % ((pats and rel) or abs)) 307 repo.ui.status(_('removing %s\n') % ((pats and rel) or abs))
309 if not dry_run: 308 if not dry_run:
310 repo.remove(remove) 309 repo.remove(remove)
311 repo.add(add) 310 repo.add(add)
312 if similarity > 0: 311 if similarity > 0:
313 for old, new, score in findrenames(repo, add, remove, similarity): 312 for old, new, score in findrenames(repo, m, similarity):
314 oldexact, newexact = m.exact(old), m.exact(new) 313 oldexact, newexact = m.exact(old), m.exact(new)
315 if repo.ui.verbose or not oldexact or not newexact: 314 if repo.ui.verbose or not oldexact or not newexact:
316 oldrel, newrel = m.rel(old), m.rel(new) 315 oldrel, newrel = m.rel(old), m.rel(new)
317 repo.ui.status(_('recording removal of %s as rename to %s ' 316 repo.ui.status(_('recording removal of %s as rename to %s '
318 '(%d%% similar)\n') % 317 '(%d%% similar)\n') %