Mercurial > hg
diff hgext/highlight/__init__.py @ 25602:85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
One of the features of hgweb is that current position in repo history is
remembered between separate requests. That is, links from /rev/<node_hash> lead
to /file/<node_hash> or /log/<node_hash>, so it's easy to dig deep into the
history. However, such links could only use node hashes and local revision
numbers, so while staying at one exact revision is easy, staying on top of the
changes is not, because hashes presumably can't change (local revision numbers
can, but probably not in a way you'd find useful for navigating).
So while you could use 'tip' or 'default' in a url, links on that page would be
permanent. This is not always desired (think /rev/tip or /graph/stable or
/log/@) and is sometimes just confusing (i.e. /log/<not the tip hash>, when
recent history is not displayed). And if user changed url deliberately to say
default instead of <some node hash>, the page ignores that fact and uses node
hash in its links, which means that navigation is, in a way, broken.
This new property, symrev, is used for storing current revision the way it was
specified, so then templates can use it in links and thus "not dereference" the
symbolic revision. It is an additional way to produce links, so not every link
needs to drop {node|short} in favor of {symrev}, many will still use node hash
(log and filelog entries, annotate lines, etc).
Some pages (e.g. summary, tags) always use the tip changeset for their context,
in such cases symrev is set to 'tip'. This is needed in case the pages want to
provide archive links.
highlight extension needs to be updated, since _filerevision now takes an
additional positional argument (signature "web, req, tmpl" is used by most of
webcommands.py functions).
More references to symbolic revisions and related gripes: issue2296, issue2826,
issue3594, issue3634.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Tue, 16 Jun 2015 02:07:25 +0800 |
parents | 80c5b2666a96 |
children | 3166bcc0c538 |
line wrap: on
line diff
--- 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))