diff tests/test-hgweb-diffs.t @ 16308:2695aaf4eb72

hgweb: add block numbers to diff regions and related links The changeset view may show several diff regions, one per file, and this patch numbers each of them so that links produced by the filenodelink fragment can reference each diff region produced by the diffblock fragment through the use of the blockno variable made available to both of them. This permits navigation to diff regions on the changeset page from the file list, and where the :target pseudo-class is supported in browsers, permits selective presentation of diffs, showing one at a time instead of potentially many in what would otherwise be a very long page that is difficult to navigate.
author Paul Boddie <paul@boddie.org.uk>
date Fri, 23 Mar 2012 01:31:31 +0100
parents c5c9ca3719f9
children 7bf48bc7de23
line wrap: on
line diff
--- a/tests/test-hgweb-diffs.t	Wed Mar 21 06:45:07 2012 +0100
+++ b/tests/test-hgweb-diffs.t	Fri Mar 23 01:31:31 2012 +0100
@@ -552,6 +552,51 @@
   $ cd test1
   $ hg import -q --exact http://localhost:$HGPORT/rev/1
 
+raw revision with diff block numbers
+
+  $ "$TESTDIR/killdaemons.py"
+  $ cat <<EOF > .hg/hgrc
+  > [web]
+  > templates = rawdiff
+  > EOF
+  $ mkdir rawdiff
+  $ cat <<EOF > rawdiff/map
+  > mimetype = 'text/plain; charset={encoding}'
+  > changeset = '{diff}'
+  > difflineplus = '{line}'
+  > difflineminus = '{line}'
+  > difflineat = '{line}'
+  > diffline = '{line}'
+  > filenodelink = ''
+  > filenolink = ''
+  > fileline = '{line}'
+  > diffblock = 'Block: {blockno}\n{lines}\n'
+  > EOF
+  $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+  $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/raw-rev/0'
+  200 Script output follows
+  
+  Block: 1
+  diff -r 000000000000 -r 0cd96de13884 a
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +a
+  
+  Block: 2
+  diff -r 000000000000 -r 0cd96de13884 b
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +b
+  
+  $ "$TESTDIR/killdaemons.py"
+  $ rm .hg/hgrc rawdiff/map
+  $ rmdir rawdiff
+  $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+
 errors
 
   $ cat ../test/errors.log