Patchwork D2009: narrowtemplates: update to use registrar mechanism

login
register
mail settings
Submitter phabricator
Date Feb. 12, 2018, 8:23 p.m.
Message ID <7b42544cd5a2a0a3e6809b0979708dd2@localhost.localdomain>
Download mbox | patch
Permalink /patch/27692/
State Not Applicable
Headers show

Comments

phabricator - Feb. 12, 2018, 8:23 p.m.
durin42 updated this revision to Diff 5514.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2009?vs=5159&id=5514

REVISION DETAIL
  https://phab.mercurial-scm.org/D2009

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowtemplates.py

CHANGE DETAILS




To: durin42, #hg-reviewers, indygreg
Cc: mercurial-devel

Patch

diff --git a/hgext/narrow/narrowtemplates.py b/hgext/narrow/narrowtemplates.py
--- a/hgext/narrow/narrowtemplates.py
+++ b/hgext/narrow/narrowtemplates.py
@@ -8,24 +8,29 @@ 
 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 ''."""
     if _isellipsis(repo, ctx.rev()):
         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')
diff --git a/hgext/narrow/__init__.py b/hgext/narrow/__init__.py
--- a/hgext/narrow/__init__.py
+++ b/hgext/narrow/__init__.py
@@ -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