[PATCH] Highlight word differences in diffs
Benoit Boissinot
benoit.boissinot at ens-lyon.org
Wed May 27 19:38:18 CDT 2009
On Wed, May 27, 2009 at 08:09:41PM -0000, Martin Geisler wrote:
> # HG changeset patch
> # User Martin Geisler <mg at lazybytes.net>
> # Date 1243454861 -7200
> # Node ID 2504b69072eea7415bda241b43dd99dd7db7b3bb
> # Parent c6483eec6092414bac04f916706f572ed2305ec0
> Highlight word differences in diffs
>
> I wondered if it would be difficult to add word diffs to the color
> extension, and it turned out to be easier than I thought easy. This
> patch shows a rough prototype...
or you could steal the lodgeit code :)
https://bitbucket.org/EnTeQuAk/lodgeit-main/src/tip/lodgeit/lib/diff.py
I changed a bit your patch (I don't like the underline):
diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -83,6 +83,7 @@
'underline': 4,
'nounderline': 24,
'inverse': 7,
+ 'uninverse': 27,
'black_background': 40,
'red_background': 41,
'green_background': 42,
@@ -196,15 +197,19 @@
#pprint(blocks)
def highlight(s):
- return "\033[%dm%s\033[%dm" % (_effect_params['underline'], s,
- _effect_params['nounderline'])
+ return "\033[%dm%s\033[%dm" % (_effect_params['inverse'], s,
+ _effect_params['uninverse'])
s = (0, 0, 0, 0)
for t in blocks:
for i in range(s[1], t[0]):
apieces[2*i] = highlight(apieces[2*i])
+ for i in range(s[1], t[0]-1):
+ apieces[2*i+1] = highlight(apieces[2*i+1])
for i in range(s[3], t[2]):
bpieces[2*i] = highlight(bpieces[2*i])
+ for i in range(s[3], t[2]-1):
+ bpieces[2*i+1] = highlight(bpieces[2*i+1])
s = t
a = ''.join(apieces)
--
:wq
More information about the Mercurial-devel
mailing list