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