Page History

Turn Off History

Colored Diffs: (from Daniel Lundin <daniel@codefactory.se>)

Since CVSTrac now has support for using an external 'diff' program (see checkin [229]), I wrote a small filter program to accomplish this, similar to the output of cvsview.

The output is marked up using CSS styles, so customizing the appearance should be simple enough for anyone who cares enough.

Example output

A sample output is viewable at http://afs.codefactory.se/user/daniel/diff2html/sample.html

Where to get it The program is available at:


MaciekStarzyk: Looks like the links above do not work. I found it at: http://www.dasbistro.com/~sam/nncs/diff2html.awk Is this the latest version ?


Setting up colored diffs

In the setup section of CVSTrac, under 'Diff Programs', add something like:

    rcsdiff -q -r%V1 -r%V2 -u '%F' | diff2html

That should work right away.

Using the included stylesheet

Also under setup, under 'Heders & Footers', make sure to link to the stylesheet as any regular CSS stylesheet.

A sample (probably overly simplified) header:

    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="http://afs.codefactory.se/user/daniel/diff2html/diff2html.css">
    </head>


Caveat: gawk 3.0.4 chokes on diff2html with the following error message: gawk: diff2html:93: fatal: match() cannot have 3 arguments

Rui Carmo: I also came across this problem, so I rigged up this short awk script that does everything I need (just pipe the rcsdiff output through it and define matching CSS classes on the page header):

  #! /usr/bin/gawk -f
  function html_escape( text ) {
    gsub(/</, "\\&lt;", text);
    gsub(/>/, "\\&gt;", text);
    gsub(/\t/, "    ", text);
    gsub(/ /, "\\ ", text);
    return text;
  }
  BEGIN { print "<pre>" }
  END { print "</pre>" }
  /^-/ { print "<span class=cvstrac-diff-deletion>" html_escape( $0 ) "</span>"; next; }
  /^+/ { print "<span class=cvstrac-diff-addition>" html_escape( $0 ) "</span>"; next; }
  /^@/ { print "<span class=cvstrac-diff-position>" html_escape( $0 ) "</span>"; next; }
  { print html_escape( $0 ) }


CS: Try a newer version of gawk (i.e. 3.1.1). Download it from this site: http://ftp.gnu.org/gnu/gawk/

Read this for more details.


RuiCarmo: Installing a new version of (g)awk is not an option on the box I'm running this - besides, simpler alternatives are easier to build upon...


DanielArena: I found a small bug in the diff2html script: lines replaced by blank lines will not show up in the diff. I corrected this by doing the following:

Replace these lines:

	state = substr ($0, 0, 1);
	text = substr ($0, 2);

With these lines:

	state = substr ($0 " ", 0, 1);
	text = substr ($0 " ", 2);

I don't really do much scripting, so use these at your own risk. Looks like it works, though.