[PATCH 2 of 4] web: provide the file number to the diffstat templates

Steven Brown stevengbrown at gmail.com
Wed Jun 8 12:38:07 CDT 2011


# HG changeset patch
# User Steven Brown <StevenGBrown at gmail.com>
# Date 1307553349 -28800
# Node ID 202c192a657a06befea8311c4cd04bb10f6c2463
# Parent  cdc51f4624e017397d1ea560a6a39078fb7aa051
web: provide the file number to the diffstat templates

This allows the diffstat templates to link into the diff output. For example,
the URLs of the first three files within the diff are #l1.1, #l2.1, #l3.1.

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -223,10 +223,12 @@
             return 0
         return (float(i) / maxtotal) * 100
 
+    fileno = 0
     for filename, adds, removes, isbinary in stats:
         template = filename in files and 'diffstatlink' or 'diffstatnolink'
         total = adds + removes
-        yield tmpl(template, node=ctx.hex(), file=filename,
+        fileno += 1
+        yield tmpl(template, node=ctx.hex(), file=filename, fileno=fileno,
                    total=total, addpct=pct(adds), removepct=pct(removes),
                    parity=parity.next())
 


More information about the Mercurial-devel mailing list