##// END OF EJS Templates
findrenames: first loop over the removed files, it's faster...
Benoit Boissinot -
r9925:9dfe34bf default
parent child Browse files
Show More
@@ -270,15 +270,16 b' def matchfiles(repo, files):'
270
270
271 def findrenames(repo, added, removed, threshold):
271 def findrenames(repo, added, removed, threshold):
272 '''find renamed files -- yields (before, after, score) tuples'''
272 '''find renamed files -- yields (before, after, score) tuples'''
273 copies = {}
273 ctx = repo['.']
274 ctx = repo['.']
274 for a in added:
275 for r in removed:
275 aa = repo.wread(a)
276 if r not in ctx:
276 bestname, bestscore = None, threshold
277 continue
277 for r in removed:
278 fctx = ctx.filectx(r)
278 if r not in ctx:
279 rr = fctx.data()
279 continue
280 for a in added:
280 rr = ctx.filectx(r).data()
281 bestscore = copies.get(a, (None, threshold))[1]
281
282 aa = repo.wread(a)
282 # bdiff.blocks() returns blocks of matching lines
283 # bdiff.blocks() returns blocks of matching lines
283 # count the number of bytes in each
284 # count the number of bytes in each
284 equal = 0
285 equal = 0
@@ -292,9 +293,10 b' def findrenames(repo, added, removed, th'
292 if lengths:
293 if lengths:
293 myscore = equal*2.0 / lengths
294 myscore = equal*2.0 / lengths
294 if myscore >= bestscore:
295 if myscore >= bestscore:
295 bestname, bestscore = r, myscore
296 copies[a] = (r, myscore)
296 if bestname:
297 for dest, v in copies.iteritems():
297 yield bestname, a, bestscore
298 source, score = v
299 yield source, dest, score
298
300
299 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None):
301 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None):
300 if dry_run is None:
302 if dry_run is None:
General Comments 0
You need to be logged in to leave comments. Login now