# HG changeset patch # User Anton Shestakov # Date 1583519793 -25200 # Node ID 9ac6779d608ce69166b5769b829c114dd544fe15 # Parent df5e6e3884bca018da1586c08d61b305738b3f4f topic: drop 4.5 compatibility for template keywords diff -r df5e6e3884bc -r 9ac6779d608c 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)