diff mercurial/hgweb/webcommands.py @ 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 5e50982c633c
children e6b45e9a75dc
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Wed Mar 21 06:45:07 2012 +0100
+++ b/mercurial/hgweb/webcommands.py	Fri Mar 23 01:31:31 2012 +0100
@@ -262,10 +262,10 @@
 
     files = []
     parity = paritygen(web.stripecount)
-    for f in ctx.files():
+    for blockno, f in enumerate(ctx.files()):
         template = f in ctx and 'filenodelink' or 'filenolink'
         files.append(tmpl(template,
-                          node=ctx.hex(), file=f,
+                          node=ctx.hex(), file=f, blockno=blockno + 1,
                           parity=parity.next()))
 
     style = web.config('web', 'style', 'paper')