compat: use new style template keyword declaration
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 14 Aug 2018 19:15:35 +0200
changeset 3945 47dd383a9955
parent 3944 4ef3800c9bf8
child 3946 8fcee1e65e29
compat: use new style template keyword declaration
hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py	Tue Aug 14 18:32:30 2018 +0200
+++ b/hgext3rd/topic/__init__.py	Tue Aug 14 19:15:35 2018 +0200
@@ -132,7 +132,6 @@
     registrar,
     scmutil,
     templatefilters,
-    templatekw,
     util,
 )
 
@@ -231,6 +230,8 @@
                       default=None,
             )
 
+templatekeyword = registrar.templatekeyword()
+
 def _contexttopic(self, force=False):
     if not (force or self.mutable()):
         return ''
@@ -338,7 +339,6 @@
 
     cmdutil.summaryhooks.add('topic', summaryhook)
 
-    templatekw.keywords['topic'] = topickw
     # Wrap workingctx extra to return the topic name
     extensions.wrapfunction(context.workingctx, '__init__', wrapinit)
     # Wrap changelog.add to drop empty topic
@@ -510,9 +510,11 @@
             'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
             listnames=lambda repo: repo.topics))
 
-def topickw(**args):
+@templatekeyword('topic', requires={'ctx'})
+def topickw(context, mapping):
     """:topic: String. The topic of the changeset"""
-    return args['ctx'].topic()
+    ctx = context.resource(mapping, 'ctx')
+    return ctx.topic()
 
 def wrapinit(orig, self, repo, *args, **kwargs):
     orig(self, repo, *args, **kwargs)