comparison mercurial/templatekw.py @ 38007:009b424c9cb6

templatekw: drop deprecated showlist() and showdict() (API)
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 10 May 2018 22:00:41 -0400
parents 3ea3c96ada54
children ec37df9042f9
comparison
equal deleted inserted replaced
38006:88c4257ae465 38007:009b424c9cb6
35 hybriddict = templateutil.hybriddict 35 hybriddict = templateutil.hybriddict
36 hybridlist = templateutil.hybridlist 36 hybridlist = templateutil.hybridlist
37 compatdict = templateutil.compatdict 37 compatdict = templateutil.compatdict
38 compatlist = templateutil.compatlist 38 compatlist = templateutil.compatlist
39 _showcompatlist = templateutil._showcompatlist 39 _showcompatlist = templateutil._showcompatlist
40
41 def _showlist(name, values, templ, mapping, plural=None, separator=' '):
42 ui = mapping.get('ui')
43 if ui:
44 ui.deprecwarn("templatekw._showlist() is deprecated, use "
45 "templateutil._showcompatlist()", '4.6')
46 context = templ # this is actually a template context, not a templater
47 return _showcompatlist(context, mapping, name, values, plural, separator)
48
49 def showdict(name, data, mapping, plural=None, key='key', value='value',
50 fmt=None, separator=' '):
51 ui = mapping.get('ui')
52 if ui:
53 ui.deprecwarn("templatekw.showdict() is deprecated, use "
54 "templateutil.compatdict()", '4.6')
55 c = [{key: k, value: v} for k, v in data.iteritems()]
56 f = _showlist(name, c, mapping['templ'], mapping, plural, separator)
57 return hybriddict(data, key=key, value=value, fmt=fmt, gen=f)
58
59 def showlist(name, values, mapping, plural=None, element=None, separator=' '):
60 ui = mapping.get('ui')
61 if ui:
62 ui.deprecwarn("templatekw.showlist() is deprecated, use "
63 "templateutil.compatlist()", '4.6')
64 if not element:
65 element = name
66 f = _showlist(name, values, mapping['templ'], mapping, plural, separator)
67 return hybridlist(values, name=element, gen=f)
68 40
69 def getlatesttags(context, mapping, pattern=None): 41 def getlatesttags(context, mapping, pattern=None):
70 '''return date, distance and name for the latest tag of rev''' 42 '''return date, distance and name for the latest tag of rev'''
71 repo = context.resource(mapping, 'repo') 43 repo = context.resource(mapping, 'repo')
72 ctx = context.resource(mapping, 'ctx') 44 ctx = context.resource(mapping, 'ctx')