diff --git a/hgext/highlight/__init__.py b/hgext/highlight/__init__.py --- a/hgext/highlight/__init__.py +++ b/hgext/highlight/__init__.py @@ -30,7 +30,7 @@ from mercurial import extensions, encodi # 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 @@ def filerevision_highlight(orig, web, tm 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)) diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -100,7 +100,7 @@ def rawfile(web, req, tmpl): 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 @@ def _filerevision(web, tmpl, fctx): 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 @@ def file(web, req, tmpl): 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 @@ def _search(web, req, tmpl): 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 @@ def changelog(web, req, tmpl, shortlog=F 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 @@ def changelog(web, req, tmpl, shortlog=F 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 @@ def manifest(web, req, tmpl): 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 @@ def manifest(web, req, tmpl): return tmpl("manifest", rev=ctx.rev(), + symrev=symrev, node=hex(node), path=abspath, up=webutil.up(abspath), @@ -755,6 +764,7 @@ def summary(web, req, tmpl): branches=branches, shortlog=changelist, node=tip.hex(), + symrev='tip', archives=web.archivelist("tip")) @webcommand('filediff') @@ -803,6 +813,7 @@ def filediff(web, req, tmpl): 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 @@ def comparison(web, req, tmpl): 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 @@ def annotate(web, req, tmpl): 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 @@ def filelog(web, req, tmpl): 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 @@ def graph(web, req, tmpl): 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 @@ def graph(web, req, tmpl): 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, diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -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 @@ def changelistentry(web, ctx, tmpl): "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 @@ def changesetentry(web, req, tmpl, ctx): diff=diff, rev=ctx.rev(), node=ctx.hex(), + symrev=symrevorshortnode(req, ctx), parent=tuple(parents(ctx)), child=children(ctx), basenode=basectx.hex(),