Community Tech/Improved diffs

From Meta, a Wikimedia project coordination wiki
Jump to: navigation, search

NOTE: The original diff problem from the Wishlist proposal has been fixed, and Community Tech won't do any more diffs work this calendar year -- see the project page for more info and rationale.

Examples posted on this page can be used to write more specific proposals for the 2016 Community Wishlist Survey, which starts on November 7th, 2016. People who helped out by adding more examples to this page: Thank you, and I hope you're not too disappointed that these won't get attention this year. -- DannyH (WMF) (talk) 16:39, 30 September 2016 (UTC)

This is a page for notes and brainstorming about the #2 request in Community Tech’s 2015 Community Wishlist Survey: "Improved diff compare screen".

From the Wishlist proposal:

Don't you just love diffs like this one. It must be possible to improve this diffcompare-view. For inspiration you can look at the wikEdDiff gadget. -- The Quixotic Potato (talk) 06:41, 29 September 2015 (UTC)
[Combined from separate proposal:] When someone moves a paragraph and then edits it, this edit is not shown separately by the "Difference between revisions" functionality. This problem also occurs when someone inserts a blank line above a paragraph and then edits it. Thanks, --Gnom (talk) 10:12, 12 November 2015 (UTC)

Note for people watching this page: The WMDE Technical Wishes team is investigating a way to improve the problem of an edit that moves a paragraph from one place to another and changing a word in the paragraph. There's interesting (somewhat technical) discussion on Phabricator ticket T138922.

Examples of problems[edit]

Right now, this page is for collecting examples of unhelpful diffs, so we can understand the problems we’re trying to solve. Feel free to add more examples.

Diff often fails to recognize an unchanged paragraph. The paragraph shows up as both removed text and added text, and it makes a mess diffing it with a different paragraph.[1] Note that this can trigger a chain reaction where several unchanged paragraphs in a row all fail to pair up, yielding an entire screen full of fictional diff. Suggestion: Hash each paragraph so you can match up paragraphs up even if they are rearranged. Perhaps use green highlighting to indicate a moved paragraph? Bonus points if you can manage to pair up paragraphs that are 95% unchanged. I know that raises complexities but it would be real nice.

Similar example triggered by adding a section heading[2]

It's annoying when diff pointlessly starts and ends diff highlighting inside <tags>.[3] Instead of generating the first diff below, start the diff one character later (on the tag boundary) and generate the second version. That will defragment both the beginning and ending tag:

><ref>[ Arabahmet Mosque sight in Nicosia, Cyprus], [ Tripwolf travel guide].</ref
<ref>[ Arabahmet Mosque sight in Nicosia, Cyprus], [ Tripwolf travel guide].</ref>
In addition, diffs should be started at the beginning tag when possible to avoid stuff like this: [4][5].

A common diff problem is where someone inserts (or is it removes?) a blank line after a heading, and the diff compares the blank line on one side with the whole paragraph on the other. Sorry I can't find an example now! However, this shows simple gnoming which demonstrates the same issue in the original example above. The diff does a few things, one of which was to change "pages=874-9" to "pages=874–9" in a massive paragraph. Johnuniq (talk) 01:46, 23 December 2015 (UTC)

  • Update The first change in this diff deletes the blank line after a heading and changes a single letter in the paragraph ("7-zip" is changed to "7-Zip"). The diff compares the paragraph with the blank line. wikEdDiff shows the diff perfectly. Johnuniq (talk) 09:23, 27 December 2015 (UTC)

Sometimes a continuous change is fragmented into little bits by spaces. At some point, in some of these the entire paragraph should be marked as changed.

  • [6]. Additionally, the removed paragraph should have been compared to the second added paragraph and the first added paragraph should be a bulk addition.
  • [7]
  • [8]
  • [9]

I think this is a one character change, but shows the entire chuck of text as added and removed.[10]

This is a bizarre diff.[11] It should have shown up as a simple new ref added at the end, like this:

<ref>{{fr}} Bernard Wuthrich, [ "Conseil fédéral: comment un Romand s’est retrouvé élu"], ''[[Le Temps]]'', Wednesday 9 December 2015 (page visited on 9 December 2015).</ref><ref>{{fr}} Yves Petignat, [ "Le choix de Parmelin, un désaveu pour la direction de l'UDC"], ''[[Le Temps]]'', Wednesday 9 December 2015 (page visited on 9 December 2015).</ref>

This diff hides the change which was simple: two newlines are inserted and "after two days" is removed. This kind of edit is common and needs to be handled somehow. Has someone mentioned wikEdDiff which has some sensational algorithms? WikiEdDiff shows exactly what this diff does. Johnuniq (talk) 09:14, 24 December 2015 (UTC)

This diff[12] took too long to figure out. The yellow text and grey text switched places. The blue text was added. (The +text is an artifact of the switch, and the blue-yellow diff is a mismatch.)

  • In this diff two line breaks are deleted to join three short paragraphs, and "Though the modern" is replaced with "A". WikiEdDiff shows exactly what changed.
  • This diff is completely broken, although WikiEdDiff does a good job of showing that most of the many changes are quite simple. The diff covers 24 intermediate revisions from 31 May 2015 to 21 June 2015.

Fixing these might be awkward from a performance point of view. Consider showing a simple (but improved) diff, with a new button to do a more time-intensive diff. Johnuniq (talk) 04:58, 7 January 2016 (UTC)

Related to previous examples, diff isn't aware that an open-tag through to close-tag is a logical entity.[13]

Desired diff: <ref>foo</ref><ref>bar</ref>

Current diff: <ref>foo</ref><ref>bar</ref>

This may be tricky to fix.[14] Possibly a good way to catch this would be to specifically look for appended text, trying to identify a diff-chunk starting backwards from the *end* of the paragraph. Or maybe recognize date or signature as an "entity" and avoid splitting it.

Desired diff: Old message. Alsee (talk) 22:40, 13 January 2016 (UTC) New message. Alsee (talk) 06:56, 17 January 2016 (UTC)

Current diff: Old message. Alsee (talk) 22:40, 13 January 2016 (UTC) New message. Alsee (talk) 06:56, 17 January 2016 (UTC)

Many mismatches, and missed-opportunities-to-match, here.[15]

  • Every {futher} template should have been an insertion. In each case the paragraph at that spot was a near-exact-match and should have been diffed with itself. (The algorithm worked sequentially, it grabbed the next available very poor % match, and missed an extremely high % match.)
  • "cheerfully" text should diff-paired with "cheerfully" text - in fact this resulted in three paragraphs in a row being mismatched.
  • "unprincipled" chunk of text could have been helpfully diff-paired with itself.

Untouched section heading == Glaring omission ==[16] should obviously be paired with itself rather than appearing as + and - text.

No-backspace markup can pollute diffs: both on mobile or on desktop, there is some strange spaces removed and then added when a no-backspace is replaced by a regular space. That's wired for a user.

Unmodified text which has been moved is shown as generic +/- text. It should have an = symbol instead, and use a different color to indicate it is unmodified. (Maybe green?) See this diff. Note that text moves are inherently ambiguous about whether one chunk was moved up, or the other chunk was moved own. A good heuristic is to assume the larger chunk is unmoved and the smaller chunk is moved (as shown in that diff), however I would suggest adding some weight to discourage moving chunks containing =section= title(s). In that particular diff my intention was to move a chunk of text from one section to another. I think the diff would read better if the =section= chunk had been defined as the unmoved chunk.

[17] The minus text should be paired with the paragraph after the =Background=. If possible the end of that paragraph should be shown as moved to =Rebel Soldier= section.

Approximately twenty instances of ></nowiki [18]

Similar to previous examples,pointlessly fragmented ref plus pointlessly fragmented template:[19]

  • Desired diff: <ref>{{Foo}}</ref> Bar<ref>{{Baz}}</ref>
  • Current diff: <ref>{{Foo}}</ref> Bar<ref>{{Baz}}</ref>

Several lines unchanged lines are mismatched and incorrectly shown as shown as +/- text. Specifically year_completed, construction_cost, spire_quantity, and spire_height.[20]

This diff should be a prime test case! The diff is completely unreadable. I would had to pull it into a text editor and check lines one by one to figure out what DIDN'T change. The true diff is:

  • 3 lines added (Brunei, Kota Batu, Kota Batu)
  • Either 2 lines moved up (Kota Negeri and Kota district moved) or 3 lines moved down (Kota Kinabalu, India, Kota Rajasthan)
  • 21 lines with a one character diff (15 with the leading * removed and 6 with the leading * to ;)

IMPORTANT! We allow people to edit other people's comments. The community very deliberately wants to judge and enforce such edits at the social level, not at the technical-capability-enforcement level. Diff fails us badly in this edit. The modified line is mismatched, meaning that we get no diff of changes for that line. This makes it difficult to spot that one editor changed the content of another editor's comment. We really want that sort of change to be highly visible.

Another pointlessly fragmented ref.[21]

  • Desired diff: <ref>{{foo|access-date=July 16, 2016}}</ref><ref>{{bar|access-date=July 16, 2016}}</ref>
  • Current diff: <ref>{{foo|access-date=July 16, 2016}}</ref><ref>{{bar|access-date=July 16, 2016}}</ref>

Useless diff[22]. Diff was confused by a mere blank newline, and fails to show what changed.

Another fragmented diff, this one involving two images. [[File:MTA Flatbush South 15.jpg|128px]]<br>[[File:New Flyer Q70 SBS.jpg|128px]]
It looks like most of these fragmented cases are fixed by highlighting-to-end-of-line when possible. The more general fix is to balance punctuation () [] {} <> in a diff whenever possible.

See the first sentence in this diff. A blank line was deleted, and a hyphen was added. Diff shows the entire sentence as removed and added, instead of diffing the two virtually-identical sentences. (Note: The diff is ok if only one of the two changes is present.) Perhaps diff needs to consider percentage-change when deciding whether to pair up the old and new text, or whether to show unpaired removed-text-block & added-text-block.

WikidiffLX 2011[edit]

May I lead your attention to mw:User:PerfektesChaos/WikidiffLX?

  • It solves at least some of the problems mentioned here.
  • There is a suitable C++ code implementing the suggestions available since summer 2011.
  • Has been submitted to Bugzilla, but no one was assigned by WMF to have a look at difficult matters.
  • The code worked fine for a pile of easy test scenarios, but would need deeper experiences with real wiki edits.

Greetings --PerfektesChaos (talk) 17:08, 20 December 2015 (UTC)

Oh, thank you! We'll check that out. -- DannyH (WMF) (talk) 19:05, 22 December 2015 (UTC)