##// END OF EJS Templates
templatekw: switch namespace template keywords to new API
Yuya Nishihara -
r36611:900e5ee4 default
parent child Browse files
Show More
@@ -89,9 +89,9 b' class namespaces(object):'
89 # we only generate a template keyword if one does not already exist
89 # we only generate a template keyword if one does not already exist
90 if namespace.name not in templatekw.keywords:
90 if namespace.name not in templatekw.keywords:
91 templatekeyword = registrar.templatekeyword(templatekw.keywords)
91 templatekeyword = registrar.templatekeyword(templatekw.keywords)
92 @templatekeyword(namespace.name)
92 @templatekeyword(namespace.name, requires={'repo', 'ctx', 'templ'})
93 def generatekw(**args):
93 def generatekw(context, mapping):
94 return templatekw.shownames(namespace.name, **args)
94 return templatekw.shownames(context, mapping, namespace.name)
95
95
96 def singlenode(self, repo, name):
96 def singlenode(self, repo, name):
97 """
97 """
@@ -676,22 +676,22 b' def showobsfate(**args):'
676
676
677 return showlist("fate", values, args)
677 return showlist("fate", values, args)
678
678
679 def shownames(namespace, **args):
679 def shownames(context, mapping, namespace):
680 """helper method to generate a template keyword for a namespace"""
680 """helper method to generate a template keyword for a namespace"""
681 args = pycompat.byteskwargs(args)
681 repo = context.resource(mapping, 'repo')
682 ctx = args['ctx']
682 ctx = context.resource(mapping, 'ctx')
683 repo = ctx.repo()
684 ns = repo.names[namespace]
683 ns = repo.names[namespace]
685 names = ns.names(repo, ctx.node())
684 names = ns.names(repo, ctx.node())
686 return showlist(ns.templatename, names, args, plural=namespace)
685 return compatlist(context, mapping, ns.templatename, names,
686 plural=namespace)
687
687
688 @templatekeyword('namespaces')
688 @templatekeyword('namespaces', requires={'repo', 'ctx', 'templ'})
689 def shownamespaces(**args):
689 def shownamespaces(context, mapping):
690 """Dict of lists. Names attached to this changeset per
690 """Dict of lists. Names attached to this changeset per
691 namespace."""
691 namespace."""
692 args = pycompat.byteskwargs(args)
692 repo = context.resource(mapping, 'repo')
693 ctx = args['ctx']
693 ctx = context.resource(mapping, 'ctx')
694 repo = ctx.repo()
694 templ = context.resource(mapping, 'templ')
695
695
696 namespaces = util.sortdict()
696 namespaces = util.sortdict()
697 def makensmapfn(ns):
697 def makensmapfn(ns):
@@ -700,10 +700,10 b' def shownamespaces(**args):'
700
700
701 for k, ns in repo.names.iteritems():
701 for k, ns in repo.names.iteritems():
702 names = ns.names(repo, ctx.node())
702 names = ns.names(repo, ctx.node())
703 f = _showlist('name', names, args['templ'], args)
703 f = _showlist('name', names, templ, mapping)
704 namespaces[k] = _hybrid(f, names, makensmapfn(ns), pycompat.identity)
704 namespaces[k] = _hybrid(f, names, makensmapfn(ns), pycompat.identity)
705
705
706 f = _showlist('namespace', list(namespaces), args['templ'], args)
706 f = _showlist('namespace', list(namespaces), templ, mapping)
707
707
708 def makemap(ns):
708 def makemap(ns):
709 return {
709 return {
@@ -933,10 +933,10 b' def showsubrepos(context, mapping):'
933 # don't remove "showtags" definition, even though namespaces will put
933 # don't remove "showtags" definition, even though namespaces will put
934 # a helper function for "tags" keyword into "keywords" map automatically,
934 # a helper function for "tags" keyword into "keywords" map automatically,
935 # because online help text is built without namespaces initialization
935 # because online help text is built without namespaces initialization
936 @templatekeyword('tags')
936 @templatekeyword('tags', requires={'repo', 'ctx', 'templ'})
937 def showtags(**args):
937 def showtags(context, mapping):
938 """List of strings. Any tags associated with the changeset."""
938 """List of strings. Any tags associated with the changeset."""
939 return shownames('tags', **args)
939 return shownames(context, mapping, 'tags')
940
940
941 @templatekeyword('termwidth', requires={'ui'})
941 @templatekeyword('termwidth', requires={'ui'})
942 def showtermwidth(context, mapping):
942 def showtermwidth(context, mapping):
General Comments 0
You need to be logged in to leave comments. Login now