In TPC in Glasgow I released App::ccdiff, which - in short - will more clearly shows horizontal diff as well as vertical diff.
That might look like (with all verbosity on) like this screenshot
$ ccdiff -u0m --ascii termc*
5,5c5,5
-
+
+ ^
40,41c40,41
- :Va=\E[0m:Vc=\E[0;33m:Ve=\E[0;4m:Vg=\E[0;4;36m:\
- ^
- :Vi=\E[0;37;41m:Vk=\E[0;1;33;41m:Vo=\E[0;1;36;41;4m:cQ=\E?25I:
- ^ ^ ^ ^
+ :Va=\E[0m:Vc=\E[0;36m:Ve=\E[0;4m:Vg=\E[0;4;36m:\
+ ^
+ :Vi=\E[0;37;44m:Vk=\E[0;1;37;44m:Vo=\E[0;1;36;44;4m:cQ=\E?25I:
+ ^ ^ ^ ^
This works fine for the purpose it is written for: find tiny changes with more ease.
It however makes no sense if chunk shows a change of 4 lines to 24 lines with a completely different content, in which case you just want to see the chunk as lines-deleted + lines-added, with no markers to the changed characters in there, as that would mean that almost every character will be marked.
As I currently see it, there are multiple approaches to the fallback of the current behavior to a normal diff report:
- If the number of lines mismatch
If the removed chunk has n lines and the added chunk has n ± x lines and the user can define x, the horizontal diff is invoked, otherwise it will fallback to normal diff-like behavior. A default of 2 seems reasonable.
- If the percentage of changed characters is over x%, where the user can specify x
If the percentage of changed characters in a chunk (all characters marked as removed or added compared to those that did not change) is over x%, fallback to normal diff-like behavior. A default of 40% seems reasonable.
It is possible to implement both and allow both at the same time.
- Did I state the problem well enough?
- Do these options make sense?
- Do the defaults make sense?
- Do you envision other options (that you would use)?
Before I start coding/changing, I'd like opinions on how you would use it and/or expect it to use, in order to raise DWIM behavior
Enjoy, Have FUN! H.Merijn
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.