hgext/churn.py
changeset 46430 b84c3d43ff2e
parent 45942 89a2afe31e82
child 48875 6000f5b25c9b
equal deleted inserted replaced
46429:e61c2dc6e1c2 46430:b84c3d43ff2e
    36 
    36 
    37 
    37 
    38 def changedlines(ui, repo, ctx1, ctx2, fmatch):
    38 def changedlines(ui, repo, ctx1, ctx2, fmatch):
    39     added, removed = 0, 0
    39     added, removed = 0, 0
    40     diff = b''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch))
    40     diff = b''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch))
       
    41     inhunk = False
    41     for l in diff.split(b'\n'):
    42     for l in diff.split(b'\n'):
    42         if l.startswith(b"+") and not l.startswith(b"+++ "):
    43         if inhunk and l.startswith(b"+"):
    43             added += 1
    44             added += 1
    44         elif l.startswith(b"-") and not l.startswith(b"--- "):
    45         elif inhunk and l.startswith(b"-"):
    45             removed += 1
    46             removed += 1
       
    47         elif l.startswith(b"@"):
       
    48             inhunk = True
       
    49         elif l.startswith(b"d"):
       
    50             inhunk = False
    46     return (added, removed)
    51     return (added, removed)
    47 
    52 
    48 
    53 
    49 def countrate(ui, repo, amap, *pats, **opts):
    54 def countrate(ui, repo, amap, *pats, **opts):
    50     """Calculate stats"""
    55     """Calculate stats"""