topic: drop 4.5 compatibility for template keywords
authorAnton Shestakov <av6@dwimlabs.net>
Sat, 07 Mar 2020 01:36:33 +0700
changeset 5183 9ac6779d608c
parent 5182 df5e6e3884bc
child 5184 2ccd7c97ed59
topic: drop 4.5 compatibility for template keywords
hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py	Wed Mar 04 16:30:38 2020 +0100
+++ b/hgext3rd/topic/__init__.py	Sat Mar 07 01:36:33 2020 +0700
@@ -155,7 +155,6 @@
     registrar,
     scmutil,
     templatefilters,
-    templatekw,
     util,
 )
 
@@ -258,10 +257,6 @@
                       default=None,
             )
 
-# we need to do old style declaration for <= 4.5
-templatekeyword = registrar.templatekeyword()
-post45template = r'requires=' in templatekeyword.__doc__
-
 def _contexttopic(self, force=False):
     if not (force or self.mutable()):
         return b''
@@ -373,9 +368,6 @@
 
     cmdutil.summaryhooks.add(b'topic', summaryhook)
 
-    if not post45template:
-        templatekw.keywords[b'topic'] = topickw
-        templatekw.keywords[b'topicidx'] = topicidxkw
     # Wrap workingctx extra to return the topic name
     extensions.wrapfunction(context.workingctx, '__init__', wrapinit)
     # Wrap changelog.add to drop empty topic
@@ -592,26 +584,19 @@
             b'topics', b'topic', namemap=_namemap, nodemap=_nodemap,
             listnames=lambda repo: repo.topics))
 
-if post45template:
-    @templatekeyword(b'topic', requires={b'ctx'})
-    def topickw(context, mapping):
-        """:topic: String. The topic of the changeset"""
-        ctx = context.resource(mapping, b'ctx')
-        return ctx.topic()
+templatekeyword = registrar.templatekeyword()
 
-    @templatekeyword(b'topicidx', requires={b'ctx'})
-    def topicidxkw(context, mapping):
-        """:topicidx: Integer. Index of the changeset as a stack alias"""
-        ctx = context.resource(mapping, b'ctx')
-        return ctx.topicidx()
-else:
-    def topickw(**args):
-        """:topic: String. The topic of the changeset"""
-        return args[b'ctx'].topic()
+@templatekeyword(b'topic', requires={b'ctx'})
+def topickw(context, mapping):
+    """:topic: String. The topic of the changeset"""
+    ctx = context.resource(mapping, b'ctx')
+    return ctx.topic()
 
-    def topicidxkw(**args):
-        """:topicidx: Integer. Index of the changeset as a stack alias"""
-        return args[b'ctx'].topicidx()
+@templatekeyword(b'topicidx', requires={b'ctx'})
+def topicidxkw(context, mapping):
+    """:topicidx: Integer. Index of the changeset as a stack alias"""
+    ctx = context.resource(mapping, b'ctx')
+    return ctx.topicidx()
 
 def wrapinit(orig, self, repo, *args, **kwargs):
     orig(self, repo, *args, **kwargs)