comparison hgext3rd/evolve/templatekw.py @ 2926:1abafae41fe2

evolve: use registrar.templatekeyword to register template keyword functions Now, using registrar.templatekeyword of Mercurial directly in evolve extension should be safe enough. because it has been available since Mercurial 3.8, and minimum Mercurial version for evolve extension is 3.8, too. BTW, this also fixes an issue of "hg help templates" output that template keywords "precursors" and "successors" are not displayed as same as others, because they do not have ":KEYWORD:" prefix in their docstring.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 07 Aug 2017 23:22:41 +0900
parents dfad30be866c
children
comparison
equal deleted inserted replaced
2925:9efedcedd9dd 2926:1abafae41fe2
26 ### template keywords 26 ### template keywords
27 # XXX it does not handle troubles well :-/ 27 # XXX it does not handle troubles well :-/
28 28
29 @eh.templatekw('obsolete') 29 @eh.templatekw('obsolete')
30 def obsoletekw(repo, ctx, templ, **args): 30 def obsoletekw(repo, ctx, templ, **args):
31 """:obsolete: String. Whether the changeset is ``obsolete``. 31 """String. Whether the changeset is ``obsolete``.
32 """ 32 """
33 if ctx.obsolete(): 33 if ctx.obsolete():
34 return 'obsolete' 34 return 'obsolete'
35 return '' 35 return ''
36 36
37 @eh.templatekw('troubles') 37 @eh.templatekw('troubles')
38 def showtroubles(**args): 38 def showtroubles(**args):
39 """:troubles: List of strings. Evolution troubles affecting the changeset 39 """List of strings. Evolution troubles affecting the changeset
40 (zero or more of "unstable", "divergent" or "bumped").""" 40 (zero or more of "unstable", "divergent" or "bumped")."""
41 ctx = args['ctx'] 41 ctx = args['ctx']
42 try: 42 try:
43 # specify plural= explicitly to trigger TypeError on hg < 4.2 43 # specify plural= explicitly to trigger TypeError on hg < 4.2
44 return templatekw.showlist('trouble', ctx.instabilities(), args, 44 return templatekw.showlist('trouble', ctx.instabilities(), args,