Show More
@@ -189,9 +189,25 b' def colorshowpatch(orig, self, node):' | |||||
189 | finally: |
|
189 | finally: | |
190 | self.ui.write = oldwrite |
|
190 | self.ui.write = oldwrite | |
191 |
|
191 | |||
|
192 | def colordiffstat(orig, s): | |||
|
193 | lines = s.split('\n') | |||
|
194 | for i, line in enumerate(lines): | |||
|
195 | if line and line[-1] in '+-': | |||
|
196 | name, graph = line.rsplit(' ', 1) | |||
|
197 | graph = graph.replace('-', | |||
|
198 | render_effects('-', _diff_effects['deleted'])) | |||
|
199 | graph = graph.replace('+', | |||
|
200 | render_effects('+', _diff_effects['inserted'])) | |||
|
201 | lines[i] = ' '.join([name, graph]) | |||
|
202 | orig('\n'.join(lines)) | |||
|
203 | ||||
192 | def colordiff(orig, ui, repo, *pats, **opts): |
|
204 | def colordiff(orig, ui, repo, *pats, **opts): | |
193 | '''run the diff command with colored output''' |
|
205 | '''run the diff command with colored output''' | |
194 | oldwrite = extensions.wrapfunction(ui, 'write', colorwrap) |
|
206 | if opts.get('stat'): | |
|
207 | wrapper = colordiffstat | |||
|
208 | else: | |||
|
209 | wrapper = colorwrap | |||
|
210 | oldwrite = extensions.wrapfunction(ui, 'write', wrapper) | |||
195 | try: |
|
211 | try: | |
196 | orig(ui, repo, *pats, **opts) |
|
212 | orig(ui, repo, *pats, **opts) | |
197 | finally: |
|
213 | finally: |
@@ -35,6 +35,9 b' hg diff --nodates --color=always' | |||||
35 | echo '% --unified=2' |
|
35 | echo '% --unified=2' | |
36 | hg diff --nodates -U 2 --color=always |
|
36 | hg diff --nodates -U 2 --color=always | |
37 |
|
37 | |||
|
38 | echo '% diffstat' | |||
|
39 | hg diff --stat --color=always | |||
|
40 | ||||
38 | echo "record=" >> $HGRCPATH |
|
41 | echo "record=" >> $HGRCPATH | |
39 | echo "[ui]" >> $HGRCPATH |
|
42 | echo "[ui]" >> $HGRCPATH | |
40 | echo "interactive=true" >> $HGRCPATH |
|
43 | echo "interactive=true" >> $HGRCPATH |
@@ -23,6 +23,9 b' adding a' | |||||
23 | [0;32m+dd[0m |
|
23 | [0;32m+dd[0m | |
24 | a |
|
24 | a | |
25 | a |
|
25 | a | |
|
26 | % diffstat | |||
|
27 | a | 2 [0;32m+[0m[0;31m-[0m | |||
|
28 | 1 files changed, 1 insertions(+), 1 deletions(-) | |||
26 | % record |
|
29 | % record | |
27 | [0;1mdiff --git a/a b/a[0m |
|
30 | [0;1mdiff --git a/a b/a[0m | |
28 | [0;36;1mold mode 100644[0m |
|
31 | [0;36;1mold mode 100644[0m |
General Comments 0
You need to be logged in to leave comments.
Login now