##// END OF EJS Templates
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara -
r36616:c3f9d0c3 default
parent child Browse files
Show More
@@ -356,11 +356,12 b' def lfsfileset(mctx, x):'
356 356 return [f for f in mctx.subset
357 357 if wrapper.pointerfromctx(mctx.ctx, f, removed=True) is not None]
358 358
359 @templatekeyword('lfs_files')
360 def lfsfiles(repo, ctx, **args):
359 @templatekeyword('lfs_files', requires={'ctx', 'templ'})
360 def lfsfiles(context, mapping):
361 361 """List of strings. All files modified, added, or removed by this
362 362 changeset."""
363 args = pycompat.byteskwargs(args)
363 ctx = context.resource(mapping, 'ctx')
364 templ = context.resource(mapping, 'templ')
364 365
365 366 pointers = wrapper.pointersfromctx(ctx, removed=True) # {path: pointer}
366 367 files = sorted(pointers.keys())
@@ -378,7 +379,7 b' def lfsfiles(repo, ctx, **args):'
378 379 }
379 380
380 381 # TODO: make the separator ', '?
381 f = templatekw._showlist('lfs_file', files, args['templ'], args)
382 f = templatekw._showlist('lfs_file', files, templ, mapping)
382 383 return templatekw._hybrid(f, files, makemap, pycompat.identity)
383 384
384 385 @command('debuglfsupload',
@@ -401,17 +401,18 b' def showbranches(context, mapping):'
401 401 plural='branches')
402 402 return compatlist(context, mapping, 'branch', [], plural='branches')
403 403
404 @templatekeyword('bookmarks')
405 def showbookmarks(**args):
404 @templatekeyword('bookmarks', requires={'repo', 'ctx', 'templ'})
405 def showbookmarks(context, mapping):
406 406 """List of strings. Any bookmarks associated with the
407 407 changeset. Also sets 'active', the name of the active bookmark.
408 408 """
409 args = pycompat.byteskwargs(args)
410 repo = args['ctx']._repo
411 bookmarks = args['ctx'].bookmarks()
409 repo = context.resource(mapping, 'repo')
410 ctx = context.resource(mapping, 'ctx')
411 templ = context.resource(mapping, 'templ')
412 bookmarks = ctx.bookmarks()
412 413 active = repo._activebookmark
413 414 makemap = lambda v: {'bookmark': v, 'active': active, 'current': active}
414 f = _showlist('bookmark', bookmarks, args['templ'], args)
415 f = _showlist('bookmark', bookmarks, templ, mapping)
415 416 return _hybrid(f, bookmarks, makemap, pycompat.identity)
416 417
417 418 @templatekeyword('children', requires={'ctx', 'templ'})
@@ -473,16 +474,17 b' def showenvvars(context, mapping):'
473 474 env = util.sortdict((k, env[k]) for k in sorted(env))
474 475 return compatdict(context, mapping, 'envvar', env, plural='envvars')
475 476
476 @templatekeyword('extras')
477 def showextras(**args):
477 @templatekeyword('extras', requires={'ctx', 'templ'})
478 def showextras(context, mapping):
478 479 """List of dicts with key, value entries of the 'extras'
479 480 field of this changeset."""
480 args = pycompat.byteskwargs(args)
481 extras = args['ctx'].extra()
481 ctx = context.resource(mapping, 'ctx')
482 templ = context.resource(mapping, 'templ')
483 extras = ctx.extra()
482 484 extras = util.sortdict((k, extras[k]) for k in sorted(extras))
483 485 makemap = lambda k: {'key': k, 'value': extras[k]}
484 486 c = [makemap(k) for k in extras]
485 f = _showlist('extra', c, args['templ'], args, plural='extras')
487 f = _showlist('extra', c, templ, mapping, plural='extras')
486 488 return _hybrid(f, extras, makemap,
487 489 lambda k: '%s=%s' % (k, util.escapestr(extras[k])))
488 490
@@ -875,21 +877,21 b' def showp2node(context, mapping):'
875 877 ctx = context.resource(mapping, 'ctx')
876 878 return ctx.p2().hex()
877 879
878 @templatekeyword('parents')
879 def showparents(**args):
880 @templatekeyword('parents', requires={'repo', 'ctx', 'templ'})
881 def showparents(context, mapping):
880 882 """List of strings. The parents of the changeset in "rev:node"
881 883 format. If the changeset has only one "natural" parent (the predecessor
882 884 revision) nothing is shown."""
883 args = pycompat.byteskwargs(args)
884 repo = args['repo']
885 ctx = args['ctx']
885 repo = context.resource(mapping, 'repo')
886 ctx = context.resource(mapping, 'ctx')
887 templ = context.resource(mapping, 'templ')
886 888 pctxs = scmutil.meaningfulparents(repo, ctx)
887 889 prevs = [p.rev() for p in pctxs]
888 890 parents = [[('rev', p.rev()),
889 891 ('node', p.hex()),
890 892 ('phase', p.phasestr())]
891 893 for p in pctxs]
892 f = _showlist('parent', parents, args['templ'], args)
894 f = _showlist('parent', parents, templ, mapping)
893 895 return _hybrid(f, prevs, lambda x: {'ctx': repo[x], 'revcache': {}},
894 896 lambda x: scmutil.formatchangeid(repo[x]), keytype=int)
895 897
General Comments 0
You need to be logged in to leave comments. Login now