compat: register a version of 'troubles' template that works with 4.6 API
Since showlist is deprecated, let us use compatlist.
--- 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