diff -r c74f1d9092f8 -r f7f25f58693a mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Fri Feb 15 18:37:00 2008 +0100 +++ b/mercurial/hgweb/hgweb_mod.py Fri Feb 15 19:44:54 2008 +0100 @@ -10,7 +10,8 @@ from mercurial.node import * from mercurial import mdiff, ui, hg, util, archival, patch, hook from mercurial import revlog, templater, templatefilters -from common import ErrorResponse, get_mtime, style_map, paritygen, get_contact +from common import get_mtime, style_map, paritygen, countgen, get_contact +from common import ErrorResponse from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR from request import wsgirequest import webcommands, protocol @@ -372,16 +373,26 @@ file=f, filenode=hex(fn or nullid)) + blockcount = countgen() def prettyprintlines(diff): - for l in diff.splitlines(1): + blockno = blockcount.next() + for lineno, l in enumerate(diff.splitlines(1)): + if blockno == 0: + lineno = lineno + 1 + else: + lineno = "%d.%d" % (blockno, lineno + 1) if l.startswith('+'): - yield tmpl("difflineplus", line=l) + ltype = "difflineplus" elif l.startswith('-'): - yield tmpl("difflineminus", line=l) + ltype = "difflineminus" elif l.startswith('@'): - yield tmpl("difflineat", line=l) + ltype = "difflineat" else: - yield tmpl("diffline", line=l) + ltype = "diffline" + yield tmpl(ltype, + line=l, + lineid="l%s" % lineno, + linenumber="% 8s" % lineno) r = self.repo c1 = r.changectx(node1) @@ -597,9 +608,10 @@ text = '(binary:%s)' % mt def lines(): - for l, t in enumerate(text.splitlines(1)): + for lineno, t in enumerate(text.splitlines(1)): yield {"line": t, - "linenumber": "% 6d" % (l + 1), + "lineid": "l%d" % (lineno + 1), + "linenumber": "% 6d" % (lineno + 1), "parity": parity.next()} return tmpl("filerevision", @@ -624,7 +636,7 @@ def annotate(**map): last = None - for f, l in fctx.annotate(follow=True): + for lineno, (f, l) in enumerate(fctx.annotate(follow=True)): fnode = f.filenode() name = self.repo.ui.shortuser(f.user()) @@ -636,7 +648,9 @@ "rev": f.rev(), "author": name, "file": f.path(), - "line": l} + "line": l, + "lineid": "l%d" % (lineno + 1), + "linenumber": "% 6d" % (lineno + 1)} return tmpl("fileannotate", file=f,