Show More
@@ -18,6 +18,7 b' from node import hex, short' | |||
|
18 | 18 | import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error |
|
19 | 19 | |
|
20 | 20 | gitre = re.compile('diff --git a/(.*) b/(.*)') |
|
21 | tabsplitter = re.compile(r'(\t+|[^\t]+)') | |
|
21 | 22 | |
|
22 | 23 | class PatchError(Exception): |
|
23 | 24 | pass |
@@ -1673,15 +1674,26 b' def difflabel(func, *args, **kw):' | |||
|
1673 | 1674 | if line and line[0] not in ' +-@\\': |
|
1674 | 1675 | head = True |
|
1675 | 1676 | stripline = line |
|
1677 | diffline = False | |
|
1676 | 1678 | if not head and line and line[0] in '+-': |
|
1677 |
# highlight trailing whitespace, but only in |
|
|
1679 | # highlight tabs and trailing whitespace, but only in | |
|
1680 | # changed lines | |
|
1678 | 1681 | stripline = line.rstrip() |
|
1682 | diffline = True | |
|
1683 | ||
|
1679 | 1684 | prefixes = textprefixes |
|
1680 | 1685 | if head: |
|
1681 | 1686 | prefixes = headprefixes |
|
1682 | 1687 | for prefix, label in prefixes: |
|
1683 | 1688 | if stripline.startswith(prefix): |
|
1684 |
|
|
|
1689 | if diffline: | |
|
1690 | for token in tabsplitter.findall(stripline): | |
|
1691 | if '\t' == token[0]: | |
|
1692 | yield (token, 'diff.tab') | |
|
1693 | else: | |
|
1694 | yield (token, label) | |
|
1695 | else: | |
|
1696 | yield (stripline, label) | |
|
1685 | 1697 | break |
|
1686 | 1698 | else: |
|
1687 | 1699 | yield (line, '') |
@@ -159,4 +159,44 b' issue3712: test colorization of subrepo ' | |||
|
159 | 159 | b |
|
160 | 160 | \x1b[0;32m+bb\x1b[0m (esc) |
|
161 | 161 | |
|
162 | test tabs | |
|
163 | ||
|
164 | $ cat >> a <<EOF | |
|
165 | > one tab | |
|
166 | > two tabs | |
|
167 | > end tab | |
|
168 | > mid tab | |
|
169 | > all tabs | |
|
170 | > EOF | |
|
171 | $ hg diff --nodates --color=always | |
|
172 | \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) | |
|
173 | \x1b[0;31;1m--- a/a\x1b[0m (esc) | |
|
174 | \x1b[0;32;1m+++ b/a\x1b[0m (esc) | |
|
175 | \x1b[0;35m@@ -7,3 +7,9 @@\x1b[0m (esc) | |
|
176 | a | |
|
177 | c | |
|
178 | c | |
|
179 | \x1b[0;32m+aa\x1b[0m (esc) | |
|
180 | \x1b[0;32m+\x1b[0m \x1b[0;32mone tab\x1b[0m (esc) | |
|
181 | \x1b[0;32m+\x1b[0m \x1b[0;32mtwo tabs\x1b[0m (esc) | |
|
182 | \x1b[0;32m+end tab\x1b[0m\x1b[0;1;41m \x1b[0m (esc) | |
|
183 | \x1b[0;32m+mid\x1b[0m \x1b[0;32mtab\x1b[0m (esc) | |
|
184 | \x1b[0;32m+\x1b[0m \x1b[0;32mall\x1b[0m \x1b[0;32mtabs\x1b[0m\x1b[0;1;41m \x1b[0m (esc) | |
|
185 | $ echo "[color]" >> $HGRCPATH | |
|
186 | $ echo "diff.tab = bold magenta" >> $HGRCPATH | |
|
187 | $ hg diff --nodates --color=always | |
|
188 | \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) | |
|
189 | \x1b[0;31;1m--- a/a\x1b[0m (esc) | |
|
190 | \x1b[0;32;1m+++ b/a\x1b[0m (esc) | |
|
191 | \x1b[0;35m@@ -7,3 +7,9 @@\x1b[0m (esc) | |
|
192 | a | |
|
193 | c | |
|
194 | c | |
|
195 | \x1b[0;32m+aa\x1b[0m (esc) | |
|
196 | \x1b[0;32m+\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mone tab\x1b[0m (esc) | |
|
197 | \x1b[0;32m+\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mtwo tabs\x1b[0m (esc) | |
|
198 | \x1b[0;32m+end tab\x1b[0m\x1b[0;1;41m \x1b[0m (esc) | |
|
199 | \x1b[0;32m+mid\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mtab\x1b[0m (esc) | |
|
200 | \x1b[0;32m+\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mall\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mtabs\x1b[0m\x1b[0;1;41m \x1b[0m (esc) | |
|
201 | ||
|
162 | 202 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now