--- a/mercurial/patch.py Wed Sep 17 13:08:03 2014 -0700
+++ b/mercurial/patch.py Wed Aug 20 15:15:50 2014 -0400
@@ -18,6 +18,7 @@
import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error
gitre = re.compile('diff --git a/(.*) b/(.*)')
+tabsplitter = re.compile(r'(\t+|[^\t]+)')
class PatchError(Exception):
pass
@@ -1673,15 +1674,26 @@
if line and line[0] not in ' +-@\\':
head = True
stripline = line
+ diffline = False
if not head and line and line[0] in '+-':
- # highlight trailing whitespace, but only in changed lines
+ # highlight tabs and trailing whitespace, but only in
+ # changed lines
stripline = line.rstrip()
+ diffline = True
+
prefixes = textprefixes
if head:
prefixes = headprefixes
for prefix, label in prefixes:
if stripline.startswith(prefix):
- yield (stripline, label)
+ if diffline:
+ for token in tabsplitter.findall(stripline):
+ if '\t' == token[0]:
+ yield (token, 'diff.tab')
+ else:
+ yield (token, label)
+ else:
+ yield (stripline, label)
break
else:
yield (line, '')