mercurial/similar.py
changeset 32202 ded48ad55146
parent 31584 985a98c6bad0
child 38348 cd196be26cb7
equal deleted inserted replaced
32201:4462a981e8df 32202:ded48ad55146
     7 
     7 
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
     9 
     9 
    10 from .i18n import _
    10 from .i18n import _
    11 from . import (
    11 from . import (
    12     bdiff,
       
    13     mdiff,
    12     mdiff,
    14 )
    13 )
    15 
    14 
    16 def _findexactmatches(repo, added, removed):
    15 def _findexactmatches(repo, added, removed):
    17     '''find renamed files that have no changes
    16     '''find renamed files that have no changes
    54     return orig, mdiff.splitnewlines(orig)
    53     return orig, mdiff.splitnewlines(orig)
    55 
    54 
    56 def _score(fctx, otherdata):
    55 def _score(fctx, otherdata):
    57     orig, lines = otherdata
    56     orig, lines = otherdata
    58     text = fctx.data()
    57     text = fctx.data()
    59     # bdiff.blocks() returns blocks of matching lines
    58     # mdiff.blocks() returns blocks of matching lines
    60     # count the number of bytes in each
    59     # count the number of bytes in each
    61     equal = 0
    60     equal = 0
    62     matches = bdiff.blocks(text, orig)
    61     matches = mdiff.blocks(text, orig)
    63     for x1, x2, y1, y2 in matches:
    62     for x1, x2, y1, y2 in matches:
    64         for line in lines[y1:y2]:
    63         for line in lines[y1:y2]:
    65             equal += len(line)
    64             equal += len(line)
    66 
    65 
    67     lengths = len(text) + len(orig)
    66     lengths = len(text) + len(orig)