[squeak-dev] Diffs "upside-down"
Tony Garnock-Jones
tonyg at leastfixedpoint.com
Mon Nov 9 14:46:23 UTC 2020
Does it bother anyone else that Squeak prints diffs
+this line was added
-this line was removed
while Unix-derived tools (including those influenced by Unix, like
Github) print
-this line was removed
+this line was added
?
For a project of mine I added the following to rearrange things more
conventionally:
diff: diff doIfMatch: matchBlock ifInsert: insertBlock ifRemove:
removeBlock
"Like TextDiffBuilder >>
patchSequenceDoIfMatch:ifInsert:ifRemove:, but with
insertions/removals in the other order (matching what lots of
Unix-heritage diff-generation tools do)."
| pending flush |
pending := OrderedCollection new.
flush := [
pending do: insertBlock.
pending removeAll].
diff patchSequenceDoIfMatch: [:line | flush value. matchBlock
value: line]
ifInsert: [:line | pending add: line]
ifRemove: removeBlock.
flush value.
... where `diff` is an instance of TextDiffBuilder.
Tony
More information about the Squeak-dev
mailing list
|