Rendering the unified output of diff
Category:
TWikiPatches
This is what I did to make the
rdiff
script handle unified diff output.
Unified diff output is what you get when you call GNU
diff
with the
-u
option. It shows your changes inline with the surrounding text, so that you keep some form of context. See the attachments below for a screenshot.
This is a patch of my rdiff binary that was changed to render the output nicely. It handles both, so I propose these changes go in the cvs? It was based off
MegaTWiki, so there are some changes that don't make sense any more, like the lib path setting.
Todo
- Changes to meta data should be rendered nicely as well. Things like user 'blabla' changed the form field 'foo' to 'bar', or this topic was renamed to 'foo'.
- This code should be part of some rendering module instead of the binary, so that it can be shared with other notification tools.
- The rdiff code needs to be more robust where html changes are concerned. A description is part of the patch.
--
WoutMertens - 13 Nov 2002
Interesting patch, please add it in to
TWikiPatches. Glad to see that you used unified diff format for the patch as well
Good point about putting this into a module, I'm sure it would be useful for
EmailNotificationEnhancements. Do you have a screenshot or Internet TWiki that demos this feature?
BTW the term 'binary' normally refers to binary executables (e.g. diff.exe in
CygWin) -
rdiff
is a script (or a program, depending on your viewpoint).
--
RichardDonkin - 13 Nov 2002
Thanks Richard, I applied your comments above
--
WoutMertens - 14 Nov 2002
Looks nice, and I like the context being shown as well as just the changes - however, I'm not sure why the '+' and '-' markings don't cover the coloured bars completely. Is that intentional?
--
RichardDonkin - 14 Nov 2002
They are that way because it is impossible to predict how high the bars would be rendered. If I wanted to achieve that effect, I would have to use a repeated background. Possible, but I don't feel like it
Besides, it's that way in the original code as well...
I changed the rendering a little bit so that it is clearer what the changes are. See snapshot2.png. Do you like it?
BTW, would you happen to know if there is some way for
PeterThoeny to notice this? And I also have
NotifyOnChange that I would like to see in TWiki...
--
WoutMertens - 15 Nov 2002
Re the pluses in the bars - this is OK given that's how the current code works (hadn't noticed!), but it would be nice if it's an improvement. To take this into the core, we would need a patch to
TWikiAlphaRelease following the
PatchGuidelines, and you would also need to write the documentation. Might be best done after
BeijingRelease but if the docs can be updated perhaps it can be done before then.
I've commented on
NotifyOnChange - personally I think that area is a very important issue for TWiki, but it needs to be more selective (i.e. don't notify everyone on every change) for most sites. If there was some way of notifying the submitting of a Support web question that there's been an answer, I'm sure there would not be so many questions that end up with my answering them and the person who asked the question never responding... See
ConversationTracking and
TopicsThatDie for more on this.
Peter probably has looked at this page btw, but I'm on the
CoreTeam so I could put this into the core if people agree this is a useful feature. Since nobody else has commented on this page, I'm not sure that it is of majority interest, but perhaps it could be part of a 'hot patches' list, e.g.
TWikiPatches, for a while, and then move into the core. Of course, not all great ideas can get into the core
This page is not in
TWikiPatches yet, btw, so please add it...
--
RichardDonkin - 19 Nov 2002
The idea of using unified diff is awesome
:-)
. It should probably be the default. It's much clearer where the changes go because of the context. They make a lot more sense. Good work, Wout!
Perhaps people haven't commented anything because of the name (if you don't come from the UNIX world, probably "unified diff" says nothing to you).
--
EstebanManchado - 20 Nov 2002
I get the feeling that this has been applied to the Feb2003 release - Peter, can you confirm, and update this page to say so??
also - this degrades metadata diffs even further, calling them
administrative changes - though i'm playing with it
--
SvenDowideit - 21 Feb 2003
I don't think this was put into Feb2003, but of course
Acronym:UTSL applies
--
RichardDonkin - 21 Feb 2003
You were right, Esteban! I do come from windows world, and until I get emerged into CVS, I have no idea, what "unified diff" is. Now I do, and I like it! Will be nice to have it - maybe as a configurable parameter, so oldtimer will not notice.
--
PeterMasiar - 21 Feb 2003
Interesting patch. I've always much preferred unified diffs in general. In terms of being a configurable option it looks from the patch that this is the default setting - it looks at the patch output to autodetect a unified diff. After Acronym:UTSL'ing I discovered this hasn't been applied to/included in the Feb release.
I've applied this patch to the server running on
http://www.yeoldeclue.com/ - sample output with a variety of changes can be seen
on this page.
For those not used to using patches, apply the patch as follows:
-
cd ~twiki/ # or where-ever you installed twiki
-
cd bin
-
patch -p0 </tmp/rdiff.patch # or where ever you downloaded the patch to
To
use the patch, you need to add the
-u
diff option to your rcsdiff command in TWiki.cfg. ie change:
diffCmd => "$rcsDir/rcsdiff $rcsArg -q -w -B -r%REVISION1% -r%REVISION2% $keywordMode %FILENAME% $endRcsCmd",
to:
diffCmd => "$rcsDir/rcsdiff $rcsArg -u -q -w -B -r%REVISION1% -r%REVISION2% $keywordMode %FILENAME% $endRcsCmd",
In it's present form the patch doesn't really match how the rest of the rdiff script works however - for example the change from:
-# Set library paths in @INC, at compile time
-BEGIN { unshift @INC, '.'; require 'setlib.cfg'; }
To:
+use lib ( '.' );
+use lib ( '../lib' );
Which is a retrograde step. That said I
like this patch. If I get a chance I'll morph this into a more consistent patch.
--
MichaelSparks - 09 Jul 2003
this is what I am going to pull in next - and in the process I will clean up the mess i'm making by pulling other patches into rdiff
(and I'm going over to owiki to hae a gander @ what MS did and discussed with us on irc.)
--
SvenDowideit - 20 Mar 2004
I think I have applied the funtionality of this patch into
CairoRelease - please tell me if I'm mistaken Docco will come from
TWikiFormsDiffRendering.
--
SvenDowideit - 09 May 2004