Mercurial > evolve
changeset 3516:359734049764
compat: register a version of 'troubles' template that works with 4.6 API
Since showlist is deprecated, let us use compatlist.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 04 Mar 2018 17:09:41 -0500 |
parents | d5a824a5853f |
children | dc31ec3ef042 |
files | hgext3rd/evolve/templatekw.py |
diffstat | 1 files changed, 20 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/templatekw.py Sun Mar 04 17:07:53 2018 -0500 +++ b/hgext3rd/evolve/templatekw.py Sun Mar 04 17:09:41 2018 -0500 @@ -34,18 +34,26 @@ return 'obsolete' return '' -@eh.templatekw('troubles') -def showtroubles(**args): - """List of strings. Evolution troubles affecting the changeset - (zero or more of "unstable", "divergent" or "bumped").""" - ctx = args['ctx'] - try: - # specify plural= explicitly to trigger TypeError on hg < 4.2 - return templatekw.showlist('trouble', ctx.instabilities(), args, - plural='troubles') - except TypeError: - return templatekw.showlist('trouble', ctx.instabilities(), plural='troubles', - **args) +if util.safehasattr(templatekw, 'compatlist'): + @eh.templatekw('troubles', requires=set(['ctx', 'templ'])) + def showtroubles(context, mapping): + ctx = context.resource(mapping, 'ctx') + return templatekw.compatlist(context, mapping, 'trouble', + ctx.instabilities(), plural='troubles') +else: + # older template API in hg < 4.6 + @eh.templatekw('troubles') + def showtroubles(**args): + """List of strings. Evolution troubles affecting the changeset + (zero or more of "unstable", "divergent" or "bumped").""" + ctx = args['ctx'] + try: + # specify plural= explicitly to trigger TypeError on hg < 4.2 + return templatekw.showlist('trouble', ctx.instabilities(), args, + plural='troubles') + except TypeError: + return templatekw.showlist('trouble', ctx.instabilities(), plural='troubles', + **args) if util.safehasattr(templatekw, 'showpredecessors'): templatekw.keywords["precursors"] = templatekw.showpredecessors