narrowtemplates: update to use registrar mechanism
It's worth considering at this point if we should just move the two
ellipsis functions to core tagged experimental or something, since
they're not really narrowing-specific...
Differential Revision: https://phab.mercurial-scm.org/D2009
--- a/hgext/narrow/__init__.py Fri Feb 02 10:37:29 2018 -0500
+++ b/hgext/narrow/__init__.py Fri Feb 02 10:51:47 2018 -0500
@@ -62,7 +62,6 @@
narrowrevlog.setup()
narrowbundle2.setup()
narrowmerge.setup()
- narrowtemplates.setup()
narrowcommands.setup()
narrowchangegroup.setup()
narrowwirepeer.uisetup()
@@ -91,3 +90,6 @@
extensions.wrapfunction(verifymod.verifier, '__init__', _verifierinit)
extensions.wrapfunction(hg, 'postshare', narrowrepo.wrappostshare)
extensions.wrapfunction(hg, 'copystore', narrowrepo.unsharenarrowspec)
+
+templatekeyword = narrowtemplates.templatekeyword
+revsetpredicate = narrowtemplates.revsetpredicate
--- a/hgext/narrow/narrowtemplates.py Fri Feb 02 10:37:29 2018 -0500
+++ b/hgext/narrow/narrowtemplates.py Fri Feb 02 10:51:47 2018 -0500
@@ -8,17 +8,21 @@
from __future__ import absolute_import
from mercurial import (
+ registrar,
revlog,
- revset,
- templatekw,
util,
)
+keywords = {}
+templatekeyword = registrar.templatekeyword(keywords)
+revsetpredicate = registrar.revsetpredicate()
+
def _isellipsis(repo, rev):
if repo.changelog.flags(rev) & revlog.REVIDX_ELLIPSIS:
return True
return False
+@templatekeyword('ellipsis')
def ellipsis(repo, ctx, templ, **args):
""":ellipsis: String. 'ellipsis' if the change is an ellipsis node,
else ''."""
@@ -26,6 +30,7 @@
return 'ellipsis'
return ''
+@templatekeyword('outsidenarrow')
def outsidenarrow(repo, ctx, templ, **args):
""":outsidenarrow: String. 'outsidenarrow' if the change affects no
tracked files, else ''."""
@@ -35,15 +40,9 @@
return 'outsidenarrow'
return ''
+@revsetpredicate('ellipsis')
def ellipsisrevset(repo, subset, x):
"""``ellipsis()``
Changesets that are ellipsis nodes.
"""
return subset.filter(lambda r: _isellipsis(repo, r))
-
-def setup():
- templatekw.keywords['ellipsis'] = ellipsis
- templatekw.keywords['outsidenarrow'] = outsidenarrow
-
- revset.symbols['ellipsis'] = ellipsisrevset
- revset.safesymbols.add('ellipsis')