##// END OF EJS Templates
Add line anchors to annotate, changeset, diff, file views for hgweb
Edward Lee -
r6122:800e2756 default
parent child Browse files
Show More
@@ -76,3 +76,9 b' def paritygen(stripecount, offset=0):'
76 parity = 1 - parity
76 parity = 1 - parity
77 count = 0
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 from mercurial.i18n import gettext as _
12 from mercurial.i18n import gettext as _
13 from mercurial import mdiff, ui, hg, util, archival, streamclone, patch
13 from mercurial import mdiff, ui, hg, util, archival, streamclone, patch
14 from mercurial import revlog, templater
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 def _up(p):
17 def _up(p):
18 if p[0] != "/":
18 if p[0] != "/":
@@ -170,16 +170,25 b' class hgweb(object):'
170 file=f,
170 file=f,
171 filenode=hex(fn or nullid))
171 filenode=hex(fn or nullid))
172
172
173 blockcount = countgen()
173 def prettyprintlines(diff):
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 if l.startswith('+'):
182 if l.startswith('+'):
176 yield self.t("difflineplus", line=l)
183 type = "difflineplus"
177 elif l.startswith('-'):
184 elif l.startswith('-'):
178 yield self.t("difflineminus", line=l)
185 type = "difflineminus"
179 elif l.startswith('@'):
186 elif l.startswith('@'):
180 yield self.t("difflineat", line=l)
187 type = "difflineat"
181 else:
188 yield self.t(type,
182 yield self.t("diffline", line=l)
189 line=l,
190 lineid="l%s" % lineno,
191 linenumber="% 8s" % lineno)
183
192
184 r = self.repo
193 r = self.repo
185 c1 = r.changectx(node1)
194 c1 = r.changectx(node1)
@@ -398,9 +407,10 b' class hgweb(object):'
398 mt = mt or 'text/plain'
407 mt = mt or 'text/plain'
399
408
400 def lines():
409 def lines():
401 for l, t in enumerate(text.splitlines(1)):
410 for lineno, t in enumerate(text.splitlines(1)):
402 yield {"line": t,
411 yield {"line": t,
403 "linenumber": "% 6d" % (l + 1),
412 "lineid": "l%d" % (lineno + 1),
413 "linenumber": "% 6d" % (lineno + 1),
404 "parity": parity.next()}
414 "parity": parity.next()}
405
415
406 yield self.t("filerevision",
416 yield self.t("filerevision",
@@ -427,7 +437,7 b' class hgweb(object):'
427
437
428 def annotate(**map):
438 def annotate(**map):
429 last = None
439 last = None
430 for f, l in fctx.annotate(follow=True):
440 for lineno, (f, l) in enumerate(fctx.annotate(follow=True)):
431 fnode = f.filenode()
441 fnode = f.filenode()
432 name = self.repo.ui.shortuser(f.user())
442 name = self.repo.ui.shortuser(f.user())
433
443
@@ -439,7 +449,9 b' class hgweb(object):'
439 "rev": f.rev(),
449 "rev": f.rev(),
440 "author": name,
450 "author": name,
441 "file": f.path(),
451 "file": f.path(),
442 "line": l}
452 "line": l,
453 "lineid": "l%d" % (lineno + 1),
454 "linenumber": "% 6d" % (lineno + 1)}
443
455
444 yield self.t("fileannotate",
456 yield self.t("fileannotate",
445 file=f,
457 file=f,
@@ -22,12 +22,12 b' filerevision = filerevision.tmpl'
22 fileannotate = fileannotate.tmpl
22 fileannotate = fileannotate.tmpl
23 filediff = filediff.tmpl
23 filediff = filediff.tmpl
24 filelog = filelog.tmpl
24 filelog = filelog.tmpl
25 fileline = '<div style="font-family:monospace" class="parity#parity#"><pre><span class="linenr"> #linenumber#</span> #line|escape#</pre></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>#line|escape#</pre></td></tr>'
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;">#line|escape#</div>'
27 difflineplus = '<div style="color:#008800;"><a class="linenr" href="##lineid#" id="#lineid#">#linenumber#</a> #line|escape#</div>'
28 difflineminus = '<div style="color:#cc0000;">#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;">#line|escape#</div>'
29 difflineat = '<div style="color:#990099;"><a class="linenr" href="##lineid#" id="#lineid#">#linenumber#</a> #line|escape#</div>'
30 diffline = '<div>#line|escape#</div>'
30 diffline = '<div><a class="linenr" href="##lineid#" id="#lineid#">#linenumber#</a> #line|escape#</div>'
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>'
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 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>'
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 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>'
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 fileannotate = fileannotate.tmpl
21 fileannotate = fileannotate.tmpl
22 filediff = filediff.tmpl
22 filediff = filediff.tmpl
23 filelog = filelog.tmpl
23 filelog = filelog.tmpl
24 fileline = '<div class="parity#parity#"><span class="lineno">#linenumber#</span>#line|escape#</div>'
24 fileline = '<div class="parity#parity#"><a class="lineno" href="##lineid#" id="#lineid#">#linenumber#</a>#line|escape#</div>'
25 filelogentry = filelogentry.tmpl
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>'
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">#line|escape#</span>'
27 difflineplus = '<span class="plusline"><a class="lineno" href="##lineid#" id="#lineid#">#linenumber#</a>#line|escape#</span>'
28 difflineminus = '<span class="minusline">#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">#line|escape#</span>'
29 difflineat = '<span class="atline"><a class="lineno" href="##lineid#" id="#lineid#">#linenumber#</a>#line|escape#</span>'
30 diffline = '#line|escape#'
30 diffline = '<a class="lineno" href="##lineid#" id="#lineid#">#linenumber#</a>#line|escape#'
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>'
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 changesetparent = '<tr><th class="parent">parent #rev#:</th><td class="parent"><a href="#url#rev/#node|short#{sessionvars%urlparameter}">#node|short#</a></td></tr>'
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 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>'
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