[PATCH] Fix tab display when browsing source via hgweb

Thomas Arendsen Hein thomas at intevation.de
Mon Jul 23 08:17:09 CDT 2012


* Dave Hines <mercurial at dph.fluff.org> [20120719 21:01]:
> # HG changeset patch
> # User Dave Hines <mercurial at high-availability.com>
> # Date 1342722334 -3600
> # Branch stable
> # Node ID d67c3d938216603a9dd1a14f6778f95cf4fecb6c
> # Parent  b013baa3898e117959984fc64c29d8c784d2f28b
> hgweb: Change line numbers in web file listings so tabs display correctly.
> 
> Many files contain tab characters, with the assumption that there are
> tab stop positions every eight characters horizontally along a line.
> When displaying files, hgweb prepends a seven character field containing
> a line number. This causes some lines containing tabs to be displayed
> incorrectly. This patch adds a character so that eight characters are
> prepended, so lines containing tabs are displayed correctly.
> 
> diff -r b013baa3898e -r d67c3d938216 mercurial/hgweb/webcommands.py
> --- a/mercurial/hgweb/webcommands.py	Sun Jul 01 13:10:54 2012 -0500
> +++ b/mercurial/hgweb/webcommands.py	Thu Jul 19 19:25:34 2012 +0100
> @@ -76,7 +76,7 @@
>          for lineno, t in enumerate(text.splitlines(True)):
>              yield {"line": t,
>                     "lineid": "l%d" % (lineno + 1),
> -                   "linenumber": "% 6d" % (lineno + 1),
> +                   "linenumber": "% 7d" % (lineno + 1),
>                     "parity": parity.next()}
>  
>      return tmpl("filerevision",

Can you give an example where this works?

I tried a file "x" with:
<one tab>foo
<eight spaces>bar

and I need "% 10d" to make both words aligned with hg serve and the
URL http://localhost:8000/file/tip/x
(and it would still not work with other pages, e.g. annotate)

Regards,
Thomas

-- 
thomas at intevation.de - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Neuer Graben 17, 49074 Osnabrueck - AG Osnabrueck, HR B 18998
Geschaeftsfuehrer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner


More information about the Mercurial-devel mailing list