--- a/hgext/highlight/__init__.py Tue Jun 16 23:06:57 2015 -0400
+++ b/hgext/highlight/__init__.py Tue Jun 16 02:07:25 2015 +0800
@@ -30,7 +30,7 @@
# leave the attribute unspecified.
testedwith = 'internal'
-def filerevision_highlight(orig, web, tmpl, fctx):
+def filerevision_highlight(orig, web, req, tmpl, fctx):
mt = ''.join(tmpl('mimetype', encoding=encoding.encoding))
# only pygmentize for mimetype containing 'html' so we both match
# 'text/html' and possibly 'application/xhtml+xml' in the future
@@ -42,7 +42,7 @@
if 'html' in mt:
style = web.config('web', 'pygments_style', 'colorful')
highlight.pygmentize('fileline', fctx, style, tmpl)
- return orig(web, tmpl, fctx)
+ return orig(web, req, tmpl, fctx)
def annotate_highlight(orig, web, req, tmpl):
mt = ''.join(tmpl('mimetype', encoding=encoding.encoding))
--- a/mercurial/hgweb/webcommands.py Tue Jun 16 23:06:57 2015 -0400
+++ b/mercurial/hgweb/webcommands.py Tue Jun 16 02:07:25 2015 +0800
@@ -100,7 +100,7 @@
req.respond(HTTP_OK, mt, path, body=text)
return []
-def _filerevision(web, tmpl, fctx):
+def _filerevision(web, req, tmpl, fctx):
f = fctx.path()
text = fctx.data()
parity = paritygen(web.stripecount)
@@ -121,6 +121,7 @@
path=webutil.up(f),
text=lines(),
rev=fctx.rev(),
+ symrev=webutil.symrevorshortnode(req, fctx),
node=fctx.hex(),
author=fctx.user(),
date=fctx.date(),
@@ -158,7 +159,7 @@
if not path:
return manifest(web, req, tmpl)
try:
- return _filerevision(web, tmpl, webutil.filectx(web.repo, req))
+ return _filerevision(web, req, tmpl, webutil.filectx(web.repo, req))
except error.LookupError, inst:
try:
return manifest(web, req, tmpl)
@@ -316,7 +317,7 @@
tip = web.repo['tip']
parity = paritygen(web.stripecount)
- return tmpl('search', query=query, node=tip.hex(),
+ return tmpl('search', query=query, node=tip.hex(), symrev='tip',
entries=changelist, archives=web.archivelist("tip"),
morevars=morevars, lessvars=lessvars,
modedesc=searchfunc[1],
@@ -351,10 +352,12 @@
query = ''
if 'node' in req.form:
ctx = webutil.changectx(web.repo, req)
+ symrev = webutil.symrevorshortnode(req, ctx)
elif 'rev' in req.form:
return _search(web, req, tmpl)
else:
ctx = web.repo['tip']
+ symrev = 'tip'
def changelist():
revs = []
@@ -403,7 +406,7 @@
nextentry = []
return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
- node=ctx.hex(), rev=pos, changesets=count,
+ node=ctx.hex(), rev=pos, symrev=symrev, changesets=count,
entries=entries,
latestentry=latestentry, nextentry=nextentry,
archives=web.archivelist("tip"), revcount=revcount,
@@ -470,7 +473,12 @@
The ``manifest`` template will be rendered for this handler.
"""
- ctx = webutil.changectx(web.repo, req)
+ if 'node' in req.form:
+ ctx = webutil.changectx(web.repo, req)
+ symrev = webutil.symrevorshortnode(req, ctx)
+ else:
+ ctx = web.repo['tip']
+ symrev = 'tip'
path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0])
mf = ctx.manifest()
node = ctx.node()
@@ -539,6 +547,7 @@
return tmpl("manifest",
rev=ctx.rev(),
+ symrev=symrev,
node=hex(node),
path=abspath,
up=webutil.up(abspath),
@@ -755,6 +764,7 @@
branches=branches,
shortlog=changelist,
node=tip.hex(),
+ symrev='tip',
archives=web.archivelist("tip"))
@webcommand('filediff')
@@ -803,6 +813,7 @@
file=path,
node=hex(n),
rev=ctx.rev(),
+ symrev=webutil.symrevorshortnode(req, ctx),
date=ctx.date(),
desc=ctx.description(),
extra=ctx.extra(),
@@ -877,6 +888,7 @@
file=path,
node=hex(ctx.node()),
rev=ctx.rev(),
+ symrev=webutil.symrevorshortnode(req, ctx),
date=ctx.date(),
desc=ctx.description(),
extra=ctx.extra(),
@@ -944,6 +956,7 @@
annotate=annotate,
path=webutil.up(f),
rev=fctx.rev(),
+ symrev=webutil.symrevorshortnode(req, fctx),
node=fctx.hex(),
author=fctx.user(),
date=fctx.date(),
@@ -1043,6 +1056,7 @@
revnav = webutil.filerevnav(web.repo, fctx.path())
nav = revnav.gen(end - 1, revcount, count)
return tmpl("filelog", file=f, node=fctx.hex(), nav=nav,
+ symrev=webutil.symrevorshortnode(req, fctx),
entries=entries,
latestentry=latestentry,
revcount=revcount, morevars=morevars, lessvars=lessvars)
@@ -1149,7 +1163,12 @@
This handler will render the ``graph`` template.
"""
- ctx = webutil.changectx(web.repo, req)
+ if 'node' in req.form:
+ ctx = webutil.changectx(web.repo, req)
+ symrev = webutil.symrevorshortnode(req, ctx)
+ else:
+ ctx = web.repo['tip']
+ symrev = 'tip'
rev = ctx.rev()
bg_height = 39
@@ -1252,7 +1271,8 @@
rows = len(tree)
canvasheight = (rows + 1) * bg_height - 27
- return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev,
+ return tmpl('graph', rev=rev, symrev=symrev, revcount=revcount,
+ uprev=uprev,
lessvars=lessvars, morevars=morevars, downrev=downrev,
cols=cols, rows=rows,
canvaswidth=(cols + 1) * bg_height,
--- a/mercurial/hgweb/webutil.py Tue Jun 16 23:06:57 2015 -0400
+++ b/mercurial/hgweb/webutil.py Tue Jun 16 02:07:25 2015 +0800
@@ -6,10 +6,10 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-import os, copy
+import os, copy, urllib
from mercurial import match, patch, error, ui, util, pathutil, context
from mercurial.i18n import _
-from mercurial.node import hex, nullid
+from mercurial.node import hex, nullid, short
from common import ErrorResponse, paritygen
from common import HTTP_NOT_FOUND
import difflib
@@ -279,6 +279,12 @@
"branches": nodebranchdict(repo, ctx)
}
+def symrevorshortnode(req, ctx):
+ if 'node' in req.form:
+ return urllib.quote(req.form['node'][0])
+ else:
+ return short(ctx.node())
+
def changesetentry(web, req, tmpl, ctx):
'''Obtain a dictionary to be used to render the "changeset" template.'''
@@ -314,6 +320,7 @@
diff=diff,
rev=ctx.rev(),
node=ctx.hex(),
+ symrev=symrevorshortnode(req, ctx),
parent=tuple(parents(ctx)),
child=children(ctx),
basenode=basectx.hex(),