Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 9928:a92539567ef3
findrenames: improve coding-style
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Tue, 24 Nov 2009 20:40:04 +0100 |
parents | 2ae4d0865629 |
children | 777c1df76ef4 0aa1a632262b |
comparison
equal
deleted
inserted
replaced
9927:2ae4d0865629 | 9928:a92539567ef3 |
---|---|
288 # bdiff.blocks() returns blocks of matching lines | 288 # bdiff.blocks() returns blocks of matching lines |
289 # count the number of bytes in each | 289 # count the number of bytes in each |
290 equal = 0 | 290 equal = 0 |
291 alines = mdiff.splitnewlines(text) | 291 alines = mdiff.splitnewlines(text) |
292 matches = bdiff.blocks(text, orig) | 292 matches = bdiff.blocks(text, orig) |
293 for x1,x2,y1,y2 in matches: | 293 for x1, x2, y1, y2 in matches: |
294 for line in alines[x1:x2]: | 294 for line in alines[x1:x2]: |
295 equal += len(line) | 295 equal += len(line) |
296 | 296 |
297 lengths = len(text) + len(orig) | 297 lengths = len(text) + len(orig) |
298 return equal*2.0 / lengths | 298 return equal * 2.0 / lengths |
299 | 299 |
300 for a in added: | 300 for a in added: |
301 bestscore = copies.get(a, (None, threshold))[1] | 301 bestscore = copies.get(a, (None, threshold))[1] |
302 myscore = score(repo.wread(a)) | 302 myscore = score(repo.wread(a)) |
303 if myscore >= bestscore: | 303 if myscore >= bestscore: |
304 copies[a] = (r, myscore) | 304 copies[a] = (r, myscore) |
305 | |
305 for dest, v in copies.iteritems(): | 306 for dest, v in copies.iteritems(): |
306 source, score = v | 307 source, score = v |
307 yield source, dest, score | 308 yield source, dest, score |
308 | 309 |
309 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None): | 310 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None): |