##// END OF EJS Templates
templatekw: have showlist() take mapping dict with no **kwargs expansion (API)...
Yuya Nishihara -
r32037:e5eab0fe default
parent child Browse files
Show More
@@ -339,7 +339,7 b' def shortdate(text):'
339 @templatefilter('splitlines')
339 @templatefilter('splitlines')
340 def splitlines(text):
340 def splitlines(text):
341 """Any text. Split text into a list of lines."""
341 """Any text. Split text into a list of lines."""
342 return templatekw.showlist('line', text.splitlines(), 'lines')
342 return templatekw.showlist('line', text.splitlines(), {}, plural='lines')
343
343
344 @templatefilter('stringescape')
344 @templatefilter('stringescape')
345 def stringescape(text):
345 def stringescape(text):
@@ -78,7 +78,7 b' def unwraphybrid(thing):'
78 return thing
78 return thing
79 return thing.gen
79 return thing.gen
80
80
81 def showlist(name, values, plural=None, element=None, separator=' ', **mapping):
81 def showlist(name, values, mapping, plural=None, element=None, separator=' '):
82 if not element:
82 if not element:
83 element = name
83 element = name
84 f = _showlist(name, values, mapping, plural, separator)
84 f = _showlist(name, values, mapping, plural, separator)
@@ -283,8 +283,8 b' def showbranches(**args):'
283 """
283 """
284 branch = args['ctx'].branch()
284 branch = args['ctx'].branch()
285 if branch != 'default':
285 if branch != 'default':
286 return showlist('branch', [branch], plural='branches', **args)
286 return showlist('branch', [branch], args, plural='branches')
287 return showlist('branch', [], plural='branches', **args)
287 return showlist('branch', [], args, plural='branches')
288
288
289 @templatekeyword('bookmarks')
289 @templatekeyword('bookmarks')
290 def showbookmarks(**args):
290 def showbookmarks(**args):
@@ -303,7 +303,7 b' def showchildren(**args):'
303 """List of strings. The children of the changeset."""
303 """List of strings. The children of the changeset."""
304 ctx = args['ctx']
304 ctx = args['ctx']
305 childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()]
305 childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()]
306 return showlist('children', childrevs, element='child', **args)
306 return showlist('children', childrevs, args, element='child')
307
307
308 # Deprecated, but kept alive for help generation a purpose.
308 # Deprecated, but kept alive for help generation a purpose.
309 @templatekeyword('currentbookmark')
309 @templatekeyword('currentbookmark')
@@ -373,8 +373,8 b' def showextras(**args):'
373 def showfileadds(**args):
373 def showfileadds(**args):
374 """List of strings. Files added by this changeset."""
374 """List of strings. Files added by this changeset."""
375 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
375 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
376 return showlist('file_add', getfiles(repo, ctx, revcache)[1],
376 return showlist('file_add', getfiles(repo, ctx, revcache)[1], args,
377 element='file', **args)
377 element='file')
378
378
379 @templatekeyword('file_copies')
379 @templatekeyword('file_copies')
380 def showfilecopies(**args):
380 def showfilecopies(**args):
@@ -420,22 +420,22 b' def showfilecopiesswitch(**args):'
420 def showfiledels(**args):
420 def showfiledels(**args):
421 """List of strings. Files removed by this changeset."""
421 """List of strings. Files removed by this changeset."""
422 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
422 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
423 return showlist('file_del', getfiles(repo, ctx, revcache)[2],
423 return showlist('file_del', getfiles(repo, ctx, revcache)[2], args,
424 element='file', **args)
424 element='file')
425
425
426 @templatekeyword('file_mods')
426 @templatekeyword('file_mods')
427 def showfilemods(**args):
427 def showfilemods(**args):
428 """List of strings. Files modified by this changeset."""
428 """List of strings. Files modified by this changeset."""
429 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
429 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
430 return showlist('file_mod', getfiles(repo, ctx, revcache)[0],
430 return showlist('file_mod', getfiles(repo, ctx, revcache)[0], args,
431 element='file', **args)
431 element='file')
432
432
433 @templatekeyword('files')
433 @templatekeyword('files')
434 def showfiles(**args):
434 def showfiles(**args):
435 """List of strings. All files modified, added, or removed by this
435 """List of strings. All files modified, added, or removed by this
436 changeset.
436 changeset.
437 """
437 """
438 return showlist('file', args['ctx'].files(), **args)
438 return showlist('file', args['ctx'].files(), args)
439
439
440 @templatekeyword('graphnode')
440 @templatekeyword('graphnode')
441 def showgraphnode(repo, ctx, **args):
441 def showgraphnode(repo, ctx, **args):
@@ -529,7 +529,7 b' def shownames(namespace, **args):'
529 repo = ctx.repo()
529 repo = ctx.repo()
530 ns = repo.names[namespace]
530 ns = repo.names[namespace]
531 names = ns.names(repo, ctx.node())
531 names = ns.names(repo, ctx.node())
532 return showlist(ns.templatename, names, plural=namespace, **args)
532 return showlist(ns.templatename, names, args, plural=namespace)
533
533
534 @templatekeyword('namespaces')
534 @templatekeyword('namespaces')
535 def shownamespaces(**args):
535 def shownamespaces(**args):
@@ -538,7 +538,7 b' def shownamespaces(**args):'
538 ctx = args['ctx']
538 ctx = args['ctx']
539 repo = ctx.repo()
539 repo = ctx.repo()
540 namespaces = util.sortdict((k, showlist('name', ns.names(repo, ctx.node()),
540 namespaces = util.sortdict((k, showlist('name', ns.names(repo, ctx.node()),
541 **args))
541 args))
542 for k, ns in repo.names.iteritems())
542 for k, ns in repo.names.iteritems())
543 f = _showlist('namespace', list(namespaces), args)
543 f = _showlist('namespace', list(namespaces), args)
544 return _hybrid(f, namespaces,
544 return _hybrid(f, namespaces,
@@ -634,7 +634,7 b' def showsubrepos(**args):'
634 ctx = args['ctx']
634 ctx = args['ctx']
635 substate = ctx.substate
635 substate = ctx.substate
636 if not substate:
636 if not substate:
637 return showlist('subrepo', [], **args)
637 return showlist('subrepo', [], args)
638 psubstate = ctx.parents()[0].substate or {}
638 psubstate = ctx.parents()[0].substate or {}
639 subrepos = []
639 subrepos = []
640 for sub in substate:
640 for sub in substate:
@@ -643,7 +643,7 b' def showsubrepos(**args):'
643 for sub in psubstate:
643 for sub in psubstate:
644 if sub not in substate:
644 if sub not in substate:
645 subrepos.append(sub) # removed in ctx
645 subrepos.append(sub) # removed in ctx
646 return showlist('subrepo', sorted(subrepos), **args)
646 return showlist('subrepo', sorted(subrepos), args)
647
647
648 # don't remove "showtags" definition, even though namespaces will put
648 # don't remove "showtags" definition, even though namespaces will put
649 # a helper function for "tags" keyword into "keywords" map automatically,
649 # a helper function for "tags" keyword into "keywords" map automatically,
@@ -670,7 +670,7 b' def showtroubles(**args):'
670
670
671 (EXPERIMENTAL)
671 (EXPERIMENTAL)
672 """
672 """
673 return showlist('trouble', args['ctx'].troubles(), **args)
673 return showlist('trouble', args['ctx'].troubles(), args)
674
674
675 # tell hggettext to extract docstrings from these functions:
675 # tell hggettext to extract docstrings from these functions:
676 i18nfunctions = keywords.values()
676 i18nfunctions = keywords.values()
@@ -595,7 +595,7 b' def files(context, mapping, args):'
595 ctx = mapping['ctx']
595 ctx = mapping['ctx']
596 m = ctx.match([raw])
596 m = ctx.match([raw])
597 files = list(ctx.matches(m))
597 files = list(ctx.matches(m))
598 return templatekw.showlist("file", files, **mapping)
598 return templatekw.showlist("file", files, mapping)
599
599
600 @templatefunc('fill(text[, width[, initialident[, hangindent]]])')
600 @templatefunc('fill(text[, width[, initialident[, hangindent]]])')
601 def fill(context, mapping, args):
601 def fill(context, mapping, args):
General Comments 0
You need to be logged in to leave comments. Login now