# HG changeset patch # User Boris Feld # Date 1495807205 -7200 # Node ID e6ecd35e99ece2c1ab75ca9a318937d947e01f7b # Parent 262d684851dc493db9c1143f48f8fa3aca1113d8 refactor: extract templates into a new file Extract evolve template from evolve/__init__.py to evolve/templatekw.py as more templates will come in the future. diff -r 262d684851dc -r e6ecd35e99ec hgext3rd/evolve/__init__.py --- a/hgext3rd/evolve/__init__.py Tue May 23 19:48:04 2017 +0200 +++ b/hgext3rd/evolve/__init__.py Fri May 26 16:00:05 2017 +0200 @@ -164,7 +164,6 @@ phases, revset, scmutil, - templatekw, obsolete ) @@ -181,7 +180,8 @@ obsexchange, safeguard, utility, - obshistory + obshistory, + templatekw ) __version__ = metadata.__version__ @@ -224,6 +224,7 @@ eh.merge(safeguard.eh) eh.merge(obscache.eh) eh.merge(obshistory.eh) +eh.merge(templatekw.eh) uisetup = eh.final_uisetup extsetup = eh.final_extsetup reposetup = eh.final_reposetup @@ -515,29 +516,6 @@ s.sort() return subset & s -### template keywords -# XXX it does not handle troubles well :-/ - -@eh.templatekw('obsolete') -def obsoletekw(repo, ctx, templ, **args): - """:obsolete: String. Whether the changeset is ``obsolete``. - """ - if ctx.obsolete(): - return 'obsolete' - return '' - -@eh.templatekw('troubles') -def showtroubles(**args): - """:troubles: 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.troubles(), args, - plural='troubles') - except TypeError: - return templatekw.showlist('trouble', ctx.troubles(), plural='troubles', - **args) ##################################################################### ### Various trouble warning ### diff -r 262d684851dc -r e6ecd35e99ec hgext3rd/evolve/templatekw.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hgext3rd/evolve/templatekw.py Fri May 26 16:00:05 2017 +0200 @@ -0,0 +1,43 @@ +# Copyright 2011 Peter Arrenbrecht +# Logilab SA +# Pierre-Yves David +# Patrick Mezard +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. +"""evolve templates +""" + +from . import ( + exthelper, +) + +from mercurial import ( + templatekw, +) + +eh = exthelper.exthelper() + +### template keywords +# XXX it does not handle troubles well :-/ + +@eh.templatekw('obsolete') +def obsoletekw(repo, ctx, templ, **args): + """:obsolete: String. Whether the changeset is ``obsolete``. + """ + if ctx.obsolete(): + return 'obsolete' + return '' + +@eh.templatekw('troubles') +def showtroubles(**args): + """:troubles: 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.troubles(), args, + plural='troubles') + except TypeError: + return templatekw.showlist('trouble', ctx.troubles(), plural='troubles', + **args)