Show More
@@ -76,3 +76,9 b' def paritygen(stripecount, offset=0):' | |||
|
76 | 76 | parity = 1 - parity |
|
77 | 77 | count = 0 |
|
78 | 78 | |
|
79 | def countgen(start=0, step=1): | |
|
80 | """count forever -- useful for line numbers""" | |
|
81 | while True: | |
|
82 | yield start | |
|
83 | start += step | |
|
84 |
@@ -12,7 +12,7 b' from mercurial.node import *' | |||
|
12 | 12 | from mercurial.i18n import gettext as _ |
|
13 | 13 | from mercurial import mdiff, ui, hg, util, archival, streamclone, patch |
|
14 | 14 | from mercurial import revlog, templater |
|
15 | from common import get_mtime, staticfile, style_map, paritygen | |
|
15 | from common import get_mtime, staticfile, style_map, paritygen, countgen | |
|
16 | 16 | |
|
17 | 17 | def _up(p): |
|
18 | 18 | if p[0] != "/": |
@@ -170,16 +170,25 b' class hgweb(object):' | |||
|
170 | 170 | file=f, |
|
171 | 171 | filenode=hex(fn or nullid)) |
|
172 | 172 | |
|
173 | blockcount = countgen() | |
|
173 | 174 | def prettyprintlines(diff): |
|
174 | for l in diff.splitlines(1): | |
|
175 | blockno = blockcount.next() | |
|
176 | for lineno, l in enumerate(diff.splitlines(1)): | |
|
177 | if blockno == 0: | |
|
178 | lineno = lineno + 1 | |
|
179 | else: | |
|
180 | lineno = "%d.%d" % (blockno, lineno + 1) | |
|
181 | type = "diffline" | |
|
175 | 182 | if l.startswith('+'): |
|
176 |
|
|
|
183 | type = "difflineplus" | |
|
177 | 184 | elif l.startswith('-'): |
|
178 |
|
|
|
185 | type = "difflineminus" | |
|
179 | 186 | elif l.startswith('@'): |
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
187 | type = "difflineat" | |
|
188 | yield self.t(type, | |
|
189 | line=l, | |
|
190 | lineid="l%s" % lineno, | |
|
191 | linenumber="% 8s" % lineno) | |
|
183 | 192 | |
|
184 | 193 | r = self.repo |
|
185 | 194 | c1 = r.changectx(node1) |
@@ -398,9 +407,10 b' class hgweb(object):' | |||
|
398 | 407 | mt = mt or 'text/plain' |
|
399 | 408 | |
|
400 | 409 | def lines(): |
|
401 | for l, t in enumerate(text.splitlines(1)): | |
|
410 | for lineno, t in enumerate(text.splitlines(1)): | |
|
402 | 411 | yield {"line": t, |
|
403 |
"line |
|
|
412 | "lineid": "l%d" % (lineno + 1), | |
|
413 | "linenumber": "% 6d" % (lineno + 1), | |
|
404 | 414 | "parity": parity.next()} |
|
405 | 415 | |
|
406 | 416 | yield self.t("filerevision", |
@@ -427,7 +437,7 b' class hgweb(object):' | |||
|
427 | 437 | |
|
428 | 438 | def annotate(**map): |
|
429 | 439 | last = None |
|
430 | for f, l in fctx.annotate(follow=True): | |
|
440 | for lineno, (f, l) in enumerate(fctx.annotate(follow=True)): | |
|
431 | 441 | fnode = f.filenode() |
|
432 | 442 | name = self.repo.ui.shortuser(f.user()) |
|
433 | 443 | |
@@ -439,7 +449,9 b' class hgweb(object):' | |||
|
439 | 449 | "rev": f.rev(), |
|
440 | 450 | "author": name, |
|
441 | 451 | "file": f.path(), |
|
442 |
"line": l |
|
|
452 | "line": l, | |
|
453 | "lineid": "l%d" % (lineno + 1), | |
|
454 | "linenumber": "% 6d" % (lineno + 1)} | |
|
443 | 455 | |
|
444 | 456 | yield self.t("fileannotate", |
|
445 | 457 | file=f, |
@@ -22,12 +22,12 b' filerevision = filerevision.tmpl' | |||
|
22 | 22 | fileannotate = fileannotate.tmpl |
|
23 | 23 | filediff = filediff.tmpl |
|
24 | 24 | filelog = filelog.tmpl |
|
25 |
fileline = '<div style="font-family:monospace" class="parity#parity#"><pre>< |
|
|
26 | annotateline = '<tr style="font-family:monospace" class="parity#parity#"><td class="linenr" style="text-align: right;"><a href="#url#annotate/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#author|obfuscate#@#rev#</a></td><td><pre>#line|escape#</pre></td></tr>' | |
|
27 | difflineplus = '<div style="color:#008800;">#line|escape#</div>' | |
|
28 | difflineminus = '<div style="color:#cc0000;">#line|escape#</div>' | |
|
29 | difflineat = '<div style="color:#990099;">#line|escape#</div>' | |
|
30 | diffline = '<div>#line|escape#</div>' | |
|
25 | fileline = '<div style="font-family:monospace" class="parity#parity#"><pre><a class="linenr" href="##lineid#" id="#lineid#">#linenumber#</a> #line|escape#</pre></div>' | |
|
26 | annotateline = '<tr style="font-family:monospace" class="parity#parity#"><td class="linenr" style="text-align: right;"><a href="#url#annotate/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#author|obfuscate#@#rev#</a></td><td><pre><a class="linenr" href="##lineid#" id="#lineid#">#linenumber#</a></pre></td><td><pre>#line|escape#</pre></td></tr>' | |
|
27 | difflineplus = '<div style="color:#008800;"><a class="linenr" href="##lineid#" id="#lineid#">#linenumber#</a> #line|escape#</div>' | |
|
28 | difflineminus = '<div style="color:#cc0000;"><a class="linenr" href="##lineid#" id="#lineid#">#linenumber#</a> #line|escape#</div>' | |
|
29 | difflineat = '<div style="color:#990099;"><a class="linenr" href="##lineid#" id="#lineid#">#linenumber#</a> #line|escape#</div>' | |
|
30 | diffline = '<div><a class="linenr" href="##lineid#" id="#lineid#">#linenumber#</a> #line|escape#</div>' | |
|
31 | 31 | changelogparent = '<tr><th class="parent">parent #rev#:</th><td class="parent"><a href="#url#rev/#node|short#{sessionvars%urlparameter}">#node|short#</a></td></tr>' |
|
32 | 32 | changesetparent = '<tr><td>parent {rev}</td><td style="font-family:monospace"><a class="list" href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td></tr>' |
|
33 | 33 | filerevparent = '<tr><td>parent {rev}</td><td style="font-family:monospace"><a class="list" href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rename%filerename}{node|short}</a></td></tr>' |
@@ -21,13 +21,13 b' filerevision = filerevision.tmpl' | |||
|
21 | 21 | fileannotate = fileannotate.tmpl |
|
22 | 22 | filediff = filediff.tmpl |
|
23 | 23 | filelog = filelog.tmpl |
|
24 |
fileline = '<div class="parity#parity#">< |
|
|
24 | fileline = '<div class="parity#parity#"><a class="lineno" href="##lineid#" id="#lineid#">#linenumber#</a>#line|escape#</div>' | |
|
25 | 25 | filelogentry = filelogentry.tmpl |
|
26 | annotateline = '<tr class="parity#parity#"><td class="annotate"><a href="#url#annotate/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#author|obfuscate#@#rev#</a></td><td><pre>#line|escape#</pre></td></tr>' | |
|
27 | difflineplus = '<span class="plusline">#line|escape#</span>' | |
|
28 | difflineminus = '<span class="minusline">#line|escape#</span>' | |
|
29 | difflineat = '<span class="atline">#line|escape#</span>' | |
|
30 | diffline = '#line|escape#' | |
|
26 | annotateline = '<tr class="parity#parity#"><td class="annotate"><a href="#url#annotate/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#author|obfuscate#@#rev#</a></td><td><a class="lineno" href="##lineid#" id="#lineid#">#linenumber#</a></td><td><pre>#line|escape#</pre></td></tr>' | |
|
27 | difflineplus = '<span class="plusline"><a class="lineno" href="##lineid#" id="#lineid#">#linenumber#</a>#line|escape#</span>' | |
|
28 | difflineminus = '<span class="minusline"><a class="lineno" href="##lineid#" id="#lineid#">#linenumber#</a>#line|escape#</span>' | |
|
29 | difflineat = '<span class="atline"><a class="lineno" href="##lineid#" id="#lineid#">#linenumber#</a>#line|escape#</span>' | |
|
30 | diffline = '<a class="lineno" href="##lineid#" id="#lineid#">#linenumber#</a>#line|escape#' | |
|
31 | 31 | changelogparent = '<tr><th class="parent">parent #rev#:</th><td class="parent"><a href="#url#rev/#node|short#{sessionvars%urlparameter}">#node|short#</a></td></tr>' |
|
32 | 32 | changesetparent = '<tr><th class="parent">parent #rev#:</th><td class="parent"><a href="#url#rev/#node|short#{sessionvars%urlparameter}">#node|short#</a></td></tr>' |
|
33 | 33 | filerevparent = '<tr><td class="metatag">parent:</td><td><a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rename%filerename}{node|short}</a></td></tr>' |
General Comments 0
You need to be logged in to leave comments.
Login now