@@ -190,12 +190,15 @@ class DiffProcessor(object):
(?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+)
\.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))?
(?:^---[ ](a/(?P<a_file>.+)|/dev/null)(?:\n|$))?
(?:^\+\+\+[ ](b/(?P<b_file>.+)|/dev/null)(?:\n|$))?
""", re.VERBOSE | re.MULTILINE)
#used for inline highlighter word split
_token_re = re.compile(r'()(>|<|&|\W+?)')
def __init__(self, diff, vcs='hg', format='gitdiff', diff_limit=None):
"""
:param diff: a text in diff format
:param vcs: type of version controll hg or git
:param format: format of diff passed, `udiff` or `gitdiff`
:param diff_limit: define the size of diff that is considered "big"
@@ -271,15 +274,14 @@ class DiffProcessor(object):
if line['action'] == 'del':
old, new = line, next_
else:
old, new = next_, line
oldwords = re.split(r'(\W)', old['line'])
newwords = re.split(r'(\W)', new['line'])
oldwords = self._token_re.split(old['line'])
newwords = self._token_re.split(new['line'])
sequence = difflib.SequenceMatcher(None, oldwords, newwords)
oldfragments, newfragments = [], []
for tag, i1, i2, j1, j2 in sequence.get_opcodes():
oldfrag = ''.join(oldwords[i1:i2])
newfrag = ''.join(newwords[j1:j2])
Status change: