##// END OF EJS Templates
templatekw: add default styles for hybrid types (issue3887)...
Matt Mackall -
r18970:3cdb6f2f default
parent child Browse files
Show More
@@ -14,9 +14,13 b' import hbisect'
14 # "{files % '{file}\n'}" (hgweb-style with inlining and function support)
14 # "{files % '{file}\n'}" (hgweb-style with inlining and function support)
15
15
16 class _hybrid(object):
16 class _hybrid(object):
17 def __init__(self, gen, values):
17 def __init__(self, gen, values, joinfmt=None):
18 self.gen = gen
18 self.gen = gen
19 self.values = values
19 self.values = values
20 if joinfmt:
21 self.joinfmt = joinfmt
22 else:
23 self.joinfmt = lambda x: x.values()[0]
20 def __iter__(self):
24 def __iter__(self):
21 return self.gen
25 return self.gen
22 def __call__(self):
26 def __call__(self):
@@ -245,7 +249,7 b' def showfilecopies(**args):'
245
249
246 c = [{'name': x[0], 'source': x[1]} for x in copies]
250 c = [{'name': x[0], 'source': x[1]} for x in copies]
247 f = _showlist('file_copy', c, plural='file_copies', **args)
251 f = _showlist('file_copy', c, plural='file_copies', **args)
248 return _hybrid(f, c)
252 return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
249
253
250 # showfilecopiesswitch() displays file copies only if copy records are
254 # showfilecopiesswitch() displays file copies only if copy records are
251 # provided before calling the templater, usually with a --copies
255 # provided before calling the templater, usually with a --copies
@@ -257,7 +261,7 b' def showfilecopiesswitch(**args):'
257 copies = args['revcache'].get('copies') or []
261 copies = args['revcache'].get('copies') or []
258 c = [{'name': x[0], 'source': x[1]} for x in copies]
262 c = [{'name': x[0], 'source': x[1]} for x in copies]
259 f = _showlist('file_copy', c, plural='file_copies', **args)
263 f = _showlist('file_copy', c, plural='file_copies', **args)
260 return _hybrid(f, c)
264 return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
261
265
262 def showfiledels(**args):
266 def showfiledels(**args):
263 """:file_dels: List of strings. Files removed by this changeset."""
267 """:file_dels: List of strings. Files removed by this changeset."""
@@ -228,7 +228,8 b' def join(context, mapping, args):'
228
228
229 joinset = args[0][0](context, mapping, args[0][1])
229 joinset = args[0][0](context, mapping, args[0][1])
230 if util.safehasattr(joinset, '__call__'):
230 if util.safehasattr(joinset, '__call__'):
231 joinset = [x.values()[0] for x in joinset()]
231 jf = joinset.joinfmt
232 joinset = [jf(x) for x in joinset()]
232
233
233 joiner = " "
234 joiner = " "
234 if len(args) > 1:
235 if len(args) > 1:
@@ -43,6 +43,8 b' Second branch starting at nullrev:'
43 $ hg mv second fourth
43 $ hg mv second fourth
44 $ hg commit -m third -d "2020-01-01 10:01"
44 $ hg commit -m third -d "2020-01-01 10:01"
45
45
46 $ hg log --template '{join(file_copies, ",\n")}\n' -r .
47 fourth (second)
46 $ hg log --template '{file_copies % "{source} -> {name}\n"}' -r .
48 $ hg log --template '{file_copies % "{source} -> {name}\n"}' -r .
47 second -> fourth
49 second -> fourth
48
50
General Comments 0
You need to be logged in to leave comments. Login now