[PATCH] Add an un-spaced line number to the filerevision line generator

Jonathan S. Shapiro shap at eros-os.com
Mon Sep 3 21:37:08 CDT 2007

# HG changeset patch
# User Jonathan S. Shapiro <shap at eros-os.com>
# Date 1188873227 14400
# Node ID 11d116b2823dec23dc8dc571cb08f808e29a4cc3
# Parent  a176f9c8b26e0a7cd526b7220bdb76be0b9e8fa9
Add an un-spaced line number to the filerevision line generator.

In OpenCM, every line number in a displayed file had an anchor. The
would take you directly to line 22. This was useful, as it allowed us
to reference particular locations in file versions directly from the

At present, the lines() function within filerevision() generates a
line number that is pre-biased with some number of spaces (a pre-bias,
aside, which should more properly be decide by the template if that is
possible). Because this string has leading spaces, it cannot be used
as an anchor target.

This change adds a new element "rawlinenumber" that provides the line
number *without* the spaces, so that anchors can be generated in the

diff -r a176f9c8b26e -r 11d116b2823d mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Sat Sep 01 02:49:18 2007 -0300
+++ b/mercurial/hgweb/hgweb_mod.py	Mon Sep 03 22:33:47 2007 -0400
@@ -396,6 +396,7 @@ class hgweb(object):
         def lines():
             for l, t in enumerate(text.splitlines(1)):
                 yield {"line": t,
+                       "rawlinenumber": "%d" % (l + 1),
                        "linenumber": "% 6d" % (l + 1),
                        "parity": parity.next()}

More information about the Mercurial-devel mailing list