##// END OF EJS Templates
hgweb: provide symrev (symbolic revision) property to the templates...
av6 -
r25602:85fb416f default
parent child Browse files
Show More
@@ -30,7 +30,7 b' from mercurial import extensions, encodi'
30 # leave the attribute unspecified.
30 # leave the attribute unspecified.
31 testedwith = 'internal'
31 testedwith = 'internal'
32
32
33 def filerevision_highlight(orig, web, tmpl, fctx):
33 def filerevision_highlight(orig, web, req, tmpl, fctx):
34 mt = ''.join(tmpl('mimetype', encoding=encoding.encoding))
34 mt = ''.join(tmpl('mimetype', encoding=encoding.encoding))
35 # only pygmentize for mimetype containing 'html' so we both match
35 # only pygmentize for mimetype containing 'html' so we both match
36 # 'text/html' and possibly 'application/xhtml+xml' in the future
36 # 'text/html' and possibly 'application/xhtml+xml' in the future
@@ -42,7 +42,7 b' def filerevision_highlight(orig, web, tm'
42 if 'html' in mt:
42 if 'html' in mt:
43 style = web.config('web', 'pygments_style', 'colorful')
43 style = web.config('web', 'pygments_style', 'colorful')
44 highlight.pygmentize('fileline', fctx, style, tmpl)
44 highlight.pygmentize('fileline', fctx, style, tmpl)
45 return orig(web, tmpl, fctx)
45 return orig(web, req, tmpl, fctx)
46
46
47 def annotate_highlight(orig, web, req, tmpl):
47 def annotate_highlight(orig, web, req, tmpl):
48 mt = ''.join(tmpl('mimetype', encoding=encoding.encoding))
48 mt = ''.join(tmpl('mimetype', encoding=encoding.encoding))
@@ -100,7 +100,7 b' def rawfile(web, req, tmpl):'
100 req.respond(HTTP_OK, mt, path, body=text)
100 req.respond(HTTP_OK, mt, path, body=text)
101 return []
101 return []
102
102
103 def _filerevision(web, tmpl, fctx):
103 def _filerevision(web, req, tmpl, fctx):
104 f = fctx.path()
104 f = fctx.path()
105 text = fctx.data()
105 text = fctx.data()
106 parity = paritygen(web.stripecount)
106 parity = paritygen(web.stripecount)
@@ -121,6 +121,7 b' def _filerevision(web, tmpl, fctx):'
121 path=webutil.up(f),
121 path=webutil.up(f),
122 text=lines(),
122 text=lines(),
123 rev=fctx.rev(),
123 rev=fctx.rev(),
124 symrev=webutil.symrevorshortnode(req, fctx),
124 node=fctx.hex(),
125 node=fctx.hex(),
125 author=fctx.user(),
126 author=fctx.user(),
126 date=fctx.date(),
127 date=fctx.date(),
@@ -158,7 +159,7 b' def file(web, req, tmpl):'
158 if not path:
159 if not path:
159 return manifest(web, req, tmpl)
160 return manifest(web, req, tmpl)
160 try:
161 try:
161 return _filerevision(web, tmpl, webutil.filectx(web.repo, req))
162 return _filerevision(web, req, tmpl, webutil.filectx(web.repo, req))
162 except error.LookupError, inst:
163 except error.LookupError, inst:
163 try:
164 try:
164 return manifest(web, req, tmpl)
165 return manifest(web, req, tmpl)
@@ -316,7 +317,7 b' def _search(web, req, tmpl):'
316 tip = web.repo['tip']
317 tip = web.repo['tip']
317 parity = paritygen(web.stripecount)
318 parity = paritygen(web.stripecount)
318
319
319 return tmpl('search', query=query, node=tip.hex(),
320 return tmpl('search', query=query, node=tip.hex(), symrev='tip',
320 entries=changelist, archives=web.archivelist("tip"),
321 entries=changelist, archives=web.archivelist("tip"),
321 morevars=morevars, lessvars=lessvars,
322 morevars=morevars, lessvars=lessvars,
322 modedesc=searchfunc[1],
323 modedesc=searchfunc[1],
@@ -351,10 +352,12 b' def changelog(web, req, tmpl, shortlog=F'
351 query = ''
352 query = ''
352 if 'node' in req.form:
353 if 'node' in req.form:
353 ctx = webutil.changectx(web.repo, req)
354 ctx = webutil.changectx(web.repo, req)
355 symrev = webutil.symrevorshortnode(req, ctx)
354 elif 'rev' in req.form:
356 elif 'rev' in req.form:
355 return _search(web, req, tmpl)
357 return _search(web, req, tmpl)
356 else:
358 else:
357 ctx = web.repo['tip']
359 ctx = web.repo['tip']
360 symrev = 'tip'
358
361
359 def changelist():
362 def changelist():
360 revs = []
363 revs = []
@@ -403,7 +406,7 b' def changelog(web, req, tmpl, shortlog=F'
403 nextentry = []
406 nextentry = []
404
407
405 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
408 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
406 node=ctx.hex(), rev=pos, changesets=count,
409 node=ctx.hex(), rev=pos, symrev=symrev, changesets=count,
407 entries=entries,
410 entries=entries,
408 latestentry=latestentry, nextentry=nextentry,
411 latestentry=latestentry, nextentry=nextentry,
409 archives=web.archivelist("tip"), revcount=revcount,
412 archives=web.archivelist("tip"), revcount=revcount,
@@ -470,7 +473,12 b' def manifest(web, req, tmpl):'
470
473
471 The ``manifest`` template will be rendered for this handler.
474 The ``manifest`` template will be rendered for this handler.
472 """
475 """
476 if 'node' in req.form:
473 ctx = webutil.changectx(web.repo, req)
477 ctx = webutil.changectx(web.repo, req)
478 symrev = webutil.symrevorshortnode(req, ctx)
479 else:
480 ctx = web.repo['tip']
481 symrev = 'tip'
474 path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0])
482 path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0])
475 mf = ctx.manifest()
483 mf = ctx.manifest()
476 node = ctx.node()
484 node = ctx.node()
@@ -539,6 +547,7 b' def manifest(web, req, tmpl):'
539
547
540 return tmpl("manifest",
548 return tmpl("manifest",
541 rev=ctx.rev(),
549 rev=ctx.rev(),
550 symrev=symrev,
542 node=hex(node),
551 node=hex(node),
543 path=abspath,
552 path=abspath,
544 up=webutil.up(abspath),
553 up=webutil.up(abspath),
@@ -755,6 +764,7 b' def summary(web, req, tmpl):'
755 branches=branches,
764 branches=branches,
756 shortlog=changelist,
765 shortlog=changelist,
757 node=tip.hex(),
766 node=tip.hex(),
767 symrev='tip',
758 archives=web.archivelist("tip"))
768 archives=web.archivelist("tip"))
759
769
760 @webcommand('filediff')
770 @webcommand('filediff')
@@ -803,6 +813,7 b' def filediff(web, req, tmpl):'
803 file=path,
813 file=path,
804 node=hex(n),
814 node=hex(n),
805 rev=ctx.rev(),
815 rev=ctx.rev(),
816 symrev=webutil.symrevorshortnode(req, ctx),
806 date=ctx.date(),
817 date=ctx.date(),
807 desc=ctx.description(),
818 desc=ctx.description(),
808 extra=ctx.extra(),
819 extra=ctx.extra(),
@@ -877,6 +888,7 b' def comparison(web, req, tmpl):'
877 file=path,
888 file=path,
878 node=hex(ctx.node()),
889 node=hex(ctx.node()),
879 rev=ctx.rev(),
890 rev=ctx.rev(),
891 symrev=webutil.symrevorshortnode(req, ctx),
880 date=ctx.date(),
892 date=ctx.date(),
881 desc=ctx.description(),
893 desc=ctx.description(),
882 extra=ctx.extra(),
894 extra=ctx.extra(),
@@ -944,6 +956,7 b' def annotate(web, req, tmpl):'
944 annotate=annotate,
956 annotate=annotate,
945 path=webutil.up(f),
957 path=webutil.up(f),
946 rev=fctx.rev(),
958 rev=fctx.rev(),
959 symrev=webutil.symrevorshortnode(req, fctx),
947 node=fctx.hex(),
960 node=fctx.hex(),
948 author=fctx.user(),
961 author=fctx.user(),
949 date=fctx.date(),
962 date=fctx.date(),
@@ -1043,6 +1056,7 b' def filelog(web, req, tmpl):'
1043 revnav = webutil.filerevnav(web.repo, fctx.path())
1056 revnav = webutil.filerevnav(web.repo, fctx.path())
1044 nav = revnav.gen(end - 1, revcount, count)
1057 nav = revnav.gen(end - 1, revcount, count)
1045 return tmpl("filelog", file=f, node=fctx.hex(), nav=nav,
1058 return tmpl("filelog", file=f, node=fctx.hex(), nav=nav,
1059 symrev=webutil.symrevorshortnode(req, fctx),
1046 entries=entries,
1060 entries=entries,
1047 latestentry=latestentry,
1061 latestentry=latestentry,
1048 revcount=revcount, morevars=morevars, lessvars=lessvars)
1062 revcount=revcount, morevars=morevars, lessvars=lessvars)
@@ -1149,7 +1163,12 b' def graph(web, req, tmpl):'
1149 This handler will render the ``graph`` template.
1163 This handler will render the ``graph`` template.
1150 """
1164 """
1151
1165
1166 if 'node' in req.form:
1152 ctx = webutil.changectx(web.repo, req)
1167 ctx = webutil.changectx(web.repo, req)
1168 symrev = webutil.symrevorshortnode(req, ctx)
1169 else:
1170 ctx = web.repo['tip']
1171 symrev = 'tip'
1153 rev = ctx.rev()
1172 rev = ctx.rev()
1154
1173
1155 bg_height = 39
1174 bg_height = 39
@@ -1252,7 +1271,8 b' def graph(web, req, tmpl):'
1252 rows = len(tree)
1271 rows = len(tree)
1253 canvasheight = (rows + 1) * bg_height - 27
1272 canvasheight = (rows + 1) * bg_height - 27
1254
1273
1255 return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev,
1274 return tmpl('graph', rev=rev, symrev=symrev, revcount=revcount,
1275 uprev=uprev,
1256 lessvars=lessvars, morevars=morevars, downrev=downrev,
1276 lessvars=lessvars, morevars=morevars, downrev=downrev,
1257 cols=cols, rows=rows,
1277 cols=cols, rows=rows,
1258 canvaswidth=(cols + 1) * bg_height,
1278 canvaswidth=(cols + 1) * bg_height,
@@ -6,10 +6,10 b''
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8
8
9 import os, copy
9 import os, copy, urllib
10 from mercurial import match, patch, error, ui, util, pathutil, context
10 from mercurial import match, patch, error, ui, util, pathutil, context
11 from mercurial.i18n import _
11 from mercurial.i18n import _
12 from mercurial.node import hex, nullid
12 from mercurial.node import hex, nullid, short
13 from common import ErrorResponse, paritygen
13 from common import ErrorResponse, paritygen
14 from common import HTTP_NOT_FOUND
14 from common import HTTP_NOT_FOUND
15 import difflib
15 import difflib
@@ -279,6 +279,12 b' def changelistentry(web, ctx, tmpl):'
279 "branches": nodebranchdict(repo, ctx)
279 "branches": nodebranchdict(repo, ctx)
280 }
280 }
281
281
282 def symrevorshortnode(req, ctx):
283 if 'node' in req.form:
284 return urllib.quote(req.form['node'][0])
285 else:
286 return short(ctx.node())
287
282 def changesetentry(web, req, tmpl, ctx):
288 def changesetentry(web, req, tmpl, ctx):
283 '''Obtain a dictionary to be used to render the "changeset" template.'''
289 '''Obtain a dictionary to be used to render the "changeset" template.'''
284
290
@@ -314,6 +320,7 b' def changesetentry(web, req, tmpl, ctx):'
314 diff=diff,
320 diff=diff,
315 rev=ctx.rev(),
321 rev=ctx.rev(),
316 node=ctx.hex(),
322 node=ctx.hex(),
323 symrev=symrevorshortnode(req, ctx),
317 parent=tuple(parents(ctx)),
324 parent=tuple(parents(ctx)),
318 child=children(ctx),
325 child=children(ctx),
319 basenode=basectx.hex(),
326 basenode=basectx.hex(),
General Comments 0
You need to be logged in to leave comments. Login now