D3212: patch: implement a new worddiff algorithm
quark (Jun Wu)
phabricator at mercurial-scm.org
Tue Apr 10 14:46:23 EDT 2018
quark added a comment.
Git first had a `contrib/diff-highlight/diff-highlight` script which inverts foreground/background for hunks with len(deleted_lines) = len(inserted_lines).
Then the latest version shows diff inline. That is:
common words [+inserted words with green color][-deleted words with red color] common words
I dislike that, since it could be ambiguous ("[+ x]" could be part of the original text).
For colors, it's really a hard question. I think if we can detect "dim" is unsupported and make it a no-op, then it'd be fine to use. `infocmp` can report "dim" correctly on my Linux terminal. Internally, we patched color.py to use 16 and 256 colors even if terminfo reports 8 colors. But I guess that's not an acceptable solution here.
INLINE COMMENTS
> yuja wrote in patch.py:2536
> Nit: maybe we can sort out tokens here instead of re-parsing tabs, newlines, trailing whitespaces later.
>
> But I'm not sure if that will make things simpler.
For a split list `['\n', '\t', ' ']`, mdiff might return a hunk that joins them. So `''.join(al[a1:a2])` will become more complex.
I think having mdiff step free from EOL/tab handling makes the code easier to read.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D3212
To: quark, #hg-reviewers, durin42, yuja
Cc: yuja, spectral, mercurial-devel
More information about the Mercurial-devel
mailing list