comparison mercurial/cmdutil.py @ 8989:85b81cac9613

addremove: pass unknown and deleted to findrenames directly again
author Matt Mackall <mpm@selenic.com>
date Tue, 30 Jun 2009 16:11:42 -0500
parents 1247751d9bf8
children 627399330c7d
comparison
equal deleted inserted replaced
8988:1247751d9bf8 8989:85b81cac9613
263 return _match.always(repo.root, repo.getcwd()) 263 return _match.always(repo.root, repo.getcwd())
264 264
265 def matchfiles(repo, files): 265 def matchfiles(repo, files):
266 return _match.exact(repo.root, repo.getcwd(), files) 266 return _match.exact(repo.root, repo.getcwd(), files)
267 267
268 def findrenames(repo, match, threshold): 268 def findrenames(repo, added, removed, threshold):
269 '''find renamed files -- yields (before, after, score) tuples''' 269 '''find renamed files -- yields (before, after, score) tuples'''
270 added, removed = repo.status(match=match)[1:3]
271 ctx = repo['.'] 270 ctx = repo['.']
272 for a in added: 271 for a in added:
273 aa = repo.wread(a) 272 aa = repo.wread(a)
274 bestname, bestscore = None, threshold 273 bestname, bestscore = None, threshold
275 for r in removed: 274 for r in removed:
275 if r not in ctx:
276 continue
276 rr = ctx.filectx(r).data() 277 rr = ctx.filectx(r).data()
277 278
278 # bdiff.blocks() returns blocks of matching lines 279 # bdiff.blocks() returns blocks of matching lines
279 # count the number of bytes in each 280 # count the number of bytes in each
280 equal = 0 281 equal = 0
320 repo.ui.status(_('removing %s\n') % ((pats and rel) or abs)) 321 repo.ui.status(_('removing %s\n') % ((pats and rel) or abs))
321 if not dry_run: 322 if not dry_run:
322 repo.remove(deleted) 323 repo.remove(deleted)
323 repo.add(unknown) 324 repo.add(unknown)
324 if similarity > 0: 325 if similarity > 0:
325 for old, new, score in findrenames(repo, m, similarity): 326 for old, new, score in findrenames(repo, unknown, deleted, similarity):
326 if repo.ui.verbose or not m.exact(old) or not m.exact(new): 327 if repo.ui.verbose or not m.exact(old) or not m.exact(new):
327 repo.ui.status(_('recording removal of %s as rename to %s ' 328 repo.ui.status(_('recording removal of %s as rename to %s '
328 '(%d%% similar)\n') % 329 '(%d%% similar)\n') %
329 (m.rel(old), m.rel(new), score * 100)) 330 (m.rel(old), m.rel(new), score * 100))
330 if not dry_run: 331 if not dry_run: