##// END OF EJS Templates
templatekw: stop using _showlist() which is about to be deprecated...
Yuya Nishihara -
r37087:724f2e21 default
parent child Browse files
Show More
@@ -367,7 +367,7 b' def succsandmarkers(context, mapping):'
367 yield item
367 yield item
368
368
369 # teach templater succsandmarkers is switched to (context, mapping) API
369 # teach templater succsandmarkers is switched to (context, mapping) API
370 succsandmarkers._requires = {'repo', 'ctx', 'templ'}
370 succsandmarkers._requires = {'repo', 'ctx'}
371
371
372 def whyunstable(context, mapping):
372 def whyunstable(context, mapping):
373 repo = context.resource(mapping, 'repo')
373 repo = context.resource(mapping, 'repo')
@@ -379,7 +379,7 b' def whyunstable(context, mapping):'
379 entry['divergentnodes'] = _siblings(entry['divergentnodes'])
379 entry['divergentnodes'] = _siblings(entry['divergentnodes'])
380 yield entry
380 yield entry
381
381
382 whyunstable._requires = {'repo', 'ctx', 'templ'}
382 whyunstable._requires = {'repo', 'ctx'}
383
383
384 def commonentry(repo, ctx):
384 def commonentry(repo, ctx):
385 node = ctx.node()
385 node = ctx.node()
@@ -231,18 +231,17 b' def showbranches(context, mapping):'
231 plural='branches')
231 plural='branches')
232 return compatlist(context, mapping, 'branch', [], plural='branches')
232 return compatlist(context, mapping, 'branch', [], plural='branches')
233
233
234 @templatekeyword('bookmarks', requires={'repo', 'ctx', 'templ'})
234 @templatekeyword('bookmarks', requires={'repo', 'ctx'})
235 def showbookmarks(context, mapping):
235 def showbookmarks(context, mapping):
236 """List of strings. Any bookmarks associated with the
236 """List of strings. Any bookmarks associated with the
237 changeset. Also sets 'active', the name of the active bookmark.
237 changeset. Also sets 'active', the name of the active bookmark.
238 """
238 """
239 repo = context.resource(mapping, 'repo')
239 repo = context.resource(mapping, 'repo')
240 ctx = context.resource(mapping, 'ctx')
240 ctx = context.resource(mapping, 'ctx')
241 templ = context.resource(mapping, 'templ')
242 bookmarks = ctx.bookmarks()
241 bookmarks = ctx.bookmarks()
243 active = repo._activebookmark
242 active = repo._activebookmark
244 makemap = lambda v: {'bookmark': v, 'active': active, 'current': active}
243 makemap = lambda v: {'bookmark': v, 'active': active, 'current': active}
245 f = _showlist('bookmark', bookmarks, templ, mapping)
244 f = _showcompatlist(context, mapping, 'bookmark', bookmarks)
246 return _hybrid(f, bookmarks, makemap, pycompat.identity)
245 return _hybrid(f, bookmarks, makemap, pycompat.identity)
247
246
248 @templatekeyword('children', requires={'ctx'})
247 @templatekeyword('children', requires={'ctx'})
@@ -304,17 +303,16 b' def showenvvars(context, mapping):'
304 env = util.sortdict((k, env[k]) for k in sorted(env))
303 env = util.sortdict((k, env[k]) for k in sorted(env))
305 return compatdict(context, mapping, 'envvar', env, plural='envvars')
304 return compatdict(context, mapping, 'envvar', env, plural='envvars')
306
305
307 @templatekeyword('extras', requires={'ctx', 'templ'})
306 @templatekeyword('extras', requires={'ctx'})
308 def showextras(context, mapping):
307 def showextras(context, mapping):
309 """List of dicts with key, value entries of the 'extras'
308 """List of dicts with key, value entries of the 'extras'
310 field of this changeset."""
309 field of this changeset."""
311 ctx = context.resource(mapping, 'ctx')
310 ctx = context.resource(mapping, 'ctx')
312 templ = context.resource(mapping, 'templ')
313 extras = ctx.extra()
311 extras = ctx.extra()
314 extras = util.sortdict((k, extras[k]) for k in sorted(extras))
312 extras = util.sortdict((k, extras[k]) for k in sorted(extras))
315 makemap = lambda k: {'key': k, 'value': extras[k]}
313 makemap = lambda k: {'key': k, 'value': extras[k]}
316 c = [makemap(k) for k in extras]
314 c = [makemap(k) for k in extras]
317 f = _showlist('extra', c, templ, mapping, plural='extras')
315 f = _showcompatlist(context, mapping, 'extra', c, plural='extras')
318 return _hybrid(f, extras, makemap,
316 return _hybrid(f, extras, makemap,
319 lambda k: '%s=%s' % (k, util.escapestr(extras[k])))
317 lambda k: '%s=%s' % (k, util.escapestr(extras[k])))
320
318
@@ -424,7 +422,7 b' def showindex(context, mapping):'
424 # just hosts documentation; should be overridden by template mapping
422 # just hosts documentation; should be overridden by template mapping
425 raise error.Abort(_("can't use index in this context"))
423 raise error.Abort(_("can't use index in this context"))
426
424
427 @templatekeyword('latesttag', requires={'repo', 'ctx', 'cache', 'templ'})
425 @templatekeyword('latesttag', requires={'repo', 'ctx', 'cache'})
428 def showlatesttag(context, mapping):
426 def showlatesttag(context, mapping):
429 """List of strings. The global tags on the most recent globally
427 """List of strings. The global tags on the most recent globally
430 tagged ancestor of this changeset. If no such tags exist, the list
428 tagged ancestor of this changeset. If no such tags exist, the list
@@ -447,8 +445,7 b' def showlatesttags(context, mapping, pat'
447 }
445 }
448
446
449 tags = latesttags[2]
447 tags = latesttags[2]
450 templ = context.resource(mapping, 'templ')
448 f = _showcompatlist(context, mapping, 'latesttag', tags, separator=':')
451 f = _showlist('latesttag', tags, templ, mapping, separator=':')
452 return _hybrid(f, tags, makemap, pycompat.identity)
449 return _hybrid(f, tags, makemap, pycompat.identity)
453
450
454 @templatekeyword('latesttagdistance', requires={'repo', 'ctx', 'cache'})
451 @templatekeyword('latesttagdistance', requires={'repo', 'ctx', 'cache'})
@@ -497,7 +494,7 b' def showmanifest(context, mapping):'
497 # rev and node are completely different from changeset's.
494 # rev and node are completely different from changeset's.
498 return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex})
495 return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex})
499
496
500 @templatekeyword('obsfate', requires={'ui', 'repo', 'ctx', 'templ'})
497 @templatekeyword('obsfate', requires={'ui', 'repo', 'ctx'})
501 def showobsfate(context, mapping):
498 def showobsfate(context, mapping):
502 # this function returns a list containing pre-formatted obsfate strings.
499 # this function returns a list containing pre-formatted obsfate strings.
503 #
500 #
@@ -522,13 +519,12 b' def shownames(context, mapping, namespac'
522 return compatlist(context, mapping, ns.templatename, names,
519 return compatlist(context, mapping, ns.templatename, names,
523 plural=namespace)
520 plural=namespace)
524
521
525 @templatekeyword('namespaces', requires={'repo', 'ctx', 'templ'})
522 @templatekeyword('namespaces', requires={'repo', 'ctx'})
526 def shownamespaces(context, mapping):
523 def shownamespaces(context, mapping):
527 """Dict of lists. Names attached to this changeset per
524 """Dict of lists. Names attached to this changeset per
528 namespace."""
525 namespace."""
529 repo = context.resource(mapping, 'repo')
526 repo = context.resource(mapping, 'repo')
530 ctx = context.resource(mapping, 'ctx')
527 ctx = context.resource(mapping, 'ctx')
531 templ = context.resource(mapping, 'templ')
532
528
533 namespaces = util.sortdict()
529 namespaces = util.sortdict()
534 def makensmapfn(ns):
530 def makensmapfn(ns):
@@ -537,10 +533,10 b' def shownamespaces(context, mapping):'
537
533
538 for k, ns in repo.names.iteritems():
534 for k, ns in repo.names.iteritems():
539 names = ns.names(repo, ctx.node())
535 names = ns.names(repo, ctx.node())
540 f = _showlist('name', names, templ, mapping)
536 f = _showcompatlist(context, mapping, 'name', names)
541 namespaces[k] = _hybrid(f, names, makensmapfn(ns), pycompat.identity)
537 namespaces[k] = _hybrid(f, names, makensmapfn(ns), pycompat.identity)
542
538
543 f = _showlist('namespace', list(namespaces), templ, mapping)
539 f = _showcompatlist(context, mapping, 'namespace', list(namespaces))
544
540
545 def makemap(ns):
541 def makemap(ns):
546 return {
542 return {
@@ -633,7 +629,7 b' def showsuccessorssets(context, mapping)'
633 return _hybrid(gen(data), data, lambda x: {'successorset': x},
629 return _hybrid(gen(data), data, lambda x: {'successorset': x},
634 pycompat.identity)
630 pycompat.identity)
635
631
636 @templatekeyword("succsandmarkers", requires={'repo', 'ctx', 'templ'})
632 @templatekeyword("succsandmarkers", requires={'repo', 'ctx'})
637 def showsuccsandmarkers(context, mapping):
633 def showsuccsandmarkers(context, mapping):
638 """Returns a list of dict for each final successor of ctx. The dict
634 """Returns a list of dict for each final successor of ctx. The dict
639 contains successors node id in "successors" keys and the list of
635 contains successors node id in "successors" keys and the list of
@@ -642,7 +638,6 b' def showsuccsandmarkers(context, mapping'
642 """
638 """
643 repo = context.resource(mapping, 'repo')
639 repo = context.resource(mapping, 'repo')
644 ctx = context.resource(mapping, 'ctx')
640 ctx = context.resource(mapping, 'ctx')
645 templ = context.resource(mapping, 'templ')
646
641
647 values = obsutil.successorsandmarkers(repo, ctx)
642 values = obsutil.successorsandmarkers(repo, ctx)
648
643
@@ -673,7 +668,7 b' def showsuccsandmarkers(context, mapping'
673
668
674 data.append({'successors': successors, 'markers': finalmarkers})
669 data.append({'successors': successors, 'markers': finalmarkers})
675
670
676 f = _showlist('succsandmarkers', data, templ, mapping)
671 f = _showcompatlist(context, mapping, 'succsandmarkers', data)
677 return _hybrid(f, data, lambda x: x, pycompat.identity)
672 return _hybrid(f, data, lambda x: x, pycompat.identity)
678
673
679 @templatekeyword('p1rev', requires={'ctx'})
674 @templatekeyword('p1rev', requires={'ctx'})
@@ -706,21 +701,20 b' def showp2node(context, mapping):'
706 ctx = context.resource(mapping, 'ctx')
701 ctx = context.resource(mapping, 'ctx')
707 return ctx.p2().hex()
702 return ctx.p2().hex()
708
703
709 @templatekeyword('parents', requires={'repo', 'ctx', 'templ'})
704 @templatekeyword('parents', requires={'repo', 'ctx'})
710 def showparents(context, mapping):
705 def showparents(context, mapping):
711 """List of strings. The parents of the changeset in "rev:node"
706 """List of strings. The parents of the changeset in "rev:node"
712 format. If the changeset has only one "natural" parent (the predecessor
707 format. If the changeset has only one "natural" parent (the predecessor
713 revision) nothing is shown."""
708 revision) nothing is shown."""
714 repo = context.resource(mapping, 'repo')
709 repo = context.resource(mapping, 'repo')
715 ctx = context.resource(mapping, 'ctx')
710 ctx = context.resource(mapping, 'ctx')
716 templ = context.resource(mapping, 'templ')
717 pctxs = scmutil.meaningfulparents(repo, ctx)
711 pctxs = scmutil.meaningfulparents(repo, ctx)
718 prevs = [p.rev() for p in pctxs]
712 prevs = [p.rev() for p in pctxs]
719 parents = [[('rev', p.rev()),
713 parents = [[('rev', p.rev()),
720 ('node', p.hex()),
714 ('node', p.hex()),
721 ('phase', p.phasestr())]
715 ('phase', p.phasestr())]
722 for p in pctxs]
716 for p in pctxs]
723 f = _showlist('parent', parents, templ, mapping)
717 f = _showcompatlist(context, mapping, 'parent', parents)
724 return _hybrid(f, prevs, lambda x: {'ctx': repo[x], 'revcache': {}},
718 return _hybrid(f, prevs, lambda x: {'ctx': repo[x], 'revcache': {}},
725 lambda x: scmutil.formatchangeid(repo[x]), keytype=int)
719 lambda x: scmutil.formatchangeid(repo[x]), keytype=int)
726
720
@@ -746,8 +740,7 b' def showrevslist(context, mapping, name,'
746 """helper to generate a list of revisions in which a mapped template will
740 """helper to generate a list of revisions in which a mapped template will
747 be evaluated"""
741 be evaluated"""
748 repo = context.resource(mapping, 'repo')
742 repo = context.resource(mapping, 'repo')
749 templ = context.resource(mapping, 'templ')
743 f = _showcompatlist(context, mapping, name, ['%d' % r for r in revs])
750 f = _showlist(name, ['%d' % r for r in revs], templ, mapping)
751 return _hybrid(f, revs,
744 return _hybrid(f, revs,
752 lambda x: {name: x, 'ctx': repo[x], 'revcache': {}},
745 lambda x: {name: x, 'ctx': repo[x], 'revcache': {}},
753 pycompat.identity, keytype=int)
746 pycompat.identity, keytype=int)
General Comments 0
You need to be logged in to leave comments. Login now