mercurial/cmdutil.py
changeset 3971 68a0fa81ad28
parent 3893 6b4127c7d52a
child 4059 431f3c1d3a37
equal deleted inserted replaced
3970:fff8a5345eb0 3971:68a0fa81ad28
   144         yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact
   144         yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact
   145 
   145 
   146 def findrenames(repo, added=None, removed=None, threshold=0.5):
   146 def findrenames(repo, added=None, removed=None, threshold=0.5):
   147     if added is None or removed is None:
   147     if added is None or removed is None:
   148         added, removed = repo.status()[1:3]
   148         added, removed = repo.status()[1:3]
   149     changes = repo.changelog.read(repo.dirstate.parents()[0])
   149     ctx = repo.changectx()
   150     mf = repo.manifest.read(changes[0])
       
   151     for a in added:
   150     for a in added:
   152         aa = repo.wread(a)
   151         aa = repo.wread(a)
   153         bestscore, bestname = None, None
   152         bestscore, bestname = None, None
   154         for r in removed:
   153         for r in removed:
   155             rr = repo.file(r).read(mf[r])
   154             rr = ctx.filectx(r).data()
   156             delta = mdiff.textdiff(aa, rr)
   155             delta = mdiff.textdiff(aa, rr)
   157             if len(delta) < len(aa):
   156             if len(delta) < len(aa):
   158                 myscore = 1.0 - (float(len(delta)) / len(aa))
   157                 myscore = 1.0 - (float(len(delta)) / len(aa))
   159                 if bestscore is None or myscore > bestscore:
   158                 if bestscore is None or myscore > bestscore:
   160                     bestscore, bestname = myscore, r
   159                     bestscore, bestname = myscore, r