Mercurial > evolve
diff hgext3rd/topic/__init__.py @ 4087:7b129ce23fad
branching: merge back with stable
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 03 Sep 2018 23:30:28 +0200 |
parents | 8a357f05187d |
children | d3ea35ad88f3 |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Mon Sep 03 23:21:39 2018 +0200 +++ b/hgext3rd/topic/__init__.py Mon Sep 03 23:30:28 2018 +0200 @@ -134,6 +134,7 @@ registrar, scmutil, templatefilters, + templatekw, util, ) @@ -177,7 +178,7 @@ 'topic.active': 'green', } -__version__ = '0.11.0.dev' +__version__ = '0.12.0.dev' testedwith = '4.3.3 4.4.2 4.5.2 4.6.2 4.7' minimumhgversion = '4.3' @@ -227,7 +228,9 @@ default=None, ) +# we need to do old style declaration for <= 4.5 templatekeyword = registrar.templatekeyword() +post45template = 'requires=' in templatekeyword.__doc__ def _contexttopic(self, force=False): if not (force or self.mutable()): @@ -350,6 +353,8 @@ cmdutil.summaryhooks.add('topic', summaryhook) + if not post45template: + 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 @@ -521,11 +526,16 @@ 'topics', 'topic', namemap=_namemap, nodemap=_nodemap, listnames=lambda repo: repo.topics)) -@templatekeyword('topic', requires={'ctx'}) -def topickw(context, mapping): - """:topic: String. The topic of the changeset""" - ctx = context.resource(mapping, 'ctx') - return ctx.topic() +if post45template: + @templatekeyword('topic', requires={'ctx'}) + def topickw(context, mapping): + """:topic: String. The topic of the changeset""" + ctx = context.resource(mapping, 'ctx') + return ctx.topic() +else: + def topickw(**args): + """:topic: String. The topic of the changeset""" + return args['ctx'].topic() def wrapinit(orig, self, repo, *args, **kwargs): orig(self, repo, *args, **kwargs)