##// END OF EJS Templates
namespace: introduce logfmt to show l10n-ed messages for hg log correctly...
FUJIWARA Katsunori -
r23967:448bb32b stable
parent child Browse files
Show More
@@ -919,9 +919,8 b' class changeset_printer(object):'
919 # we will use the templatename as the color name since those two
919 # we will use the templatename as the color name since those two
920 # should be the same
920 # should be the same
921 for name in ns.names(self.repo, changenode):
921 for name in ns.names(self.repo, changenode):
922 # i18n: column positioning for "hg log"
922 self.ui.write(ns.logfmt % name,
923 name = _(("%s:" % ns.logname).ljust(13) + "%s\n") % name
923 label='log.%s' % ns.colorname)
924 self.ui.write("%s" % name, label='log.%s' % ns.colorname)
925 if self.ui.debugflag:
924 if self.ui.debugflag:
926 # i18n: column positioning for "hg log"
925 # i18n: column positioning for "hg log"
927 self.ui.write(_("phase: %s\n") % _(ctx.phasestr()),
926 self.ui.write(_("phase: %s\n") % _(ctx.phasestr()),
@@ -27,21 +27,30 b' class namespaces(object):'
27 bmknames = lambda repo: repo._bookmarks.keys()
27 bmknames = lambda repo: repo._bookmarks.keys()
28 bmknamemap = lambda repo, name: tolist(repo._bookmarks.get(name))
28 bmknamemap = lambda repo, name: tolist(repo._bookmarks.get(name))
29 bmknodemap = lambda repo, name: repo.nodebookmarks(name)
29 bmknodemap = lambda repo, name: repo.nodebookmarks(name)
30 n = namespace("bookmarks", templatename="bookmark", listnames=bmknames,
30 n = namespace("bookmarks", templatename="bookmark",
31 # i18n: column positioning for "hg log"
32 logfmt=_("bookmark: %s\n"),
33 listnames=bmknames,
31 namemap=bmknamemap, nodemap=bmknodemap)
34 namemap=bmknamemap, nodemap=bmknodemap)
32 self.addnamespace(n)
35 self.addnamespace(n)
33
36
34 tagnames = lambda repo: [t for t, n in repo.tagslist()]
37 tagnames = lambda repo: [t for t, n in repo.tagslist()]
35 tagnamemap = lambda repo, name: tolist(repo._tagscache.tags.get(name))
38 tagnamemap = lambda repo, name: tolist(repo._tagscache.tags.get(name))
36 tagnodemap = lambda repo, name: repo.nodetags(name)
39 tagnodemap = lambda repo, name: repo.nodetags(name)
37 n = namespace("tags", templatename="tag", listnames=tagnames,
40 n = namespace("tags", templatename="tag",
41 # i18n: column positioning for "hg log"
42 logfmt=_("tag: %s\n"),
43 listnames=tagnames,
38 namemap=tagnamemap, nodemap=tagnodemap)
44 namemap=tagnamemap, nodemap=tagnodemap)
39 self.addnamespace(n)
45 self.addnamespace(n)
40
46
41 bnames = lambda repo: repo.branchmap().keys()
47 bnames = lambda repo: repo.branchmap().keys()
42 bnamemap = lambda repo, name: tolist(repo.branchtip(name, True))
48 bnamemap = lambda repo, name: tolist(repo.branchtip(name, True))
43 bnodemap = lambda repo, node: [repo[node].branch()]
49 bnodemap = lambda repo, node: [repo[node].branch()]
44 n = namespace("branches", templatename="branch", listnames=bnames,
50 n = namespace("branches", templatename="branch",
51 # i18n: column positioning for "hg log"
52 logfmt=_("branch: %s\n"),
53 listnames=bnames,
45 namemap=bnamemap, nodemap=bnodemap)
54 namemap=bnamemap, nodemap=bnodemap)
46 self.addnamespace(n)
55 self.addnamespace(n)
47
56
@@ -121,7 +130,7 b' class namespace(object):'
121 """
130 """
122
131
123 def __init__(self, name, templatename=None, logname=None, colorname=None,
132 def __init__(self, name, templatename=None, logname=None, colorname=None,
124 listnames=None, namemap=None, nodemap=None):
133 logfmt=None, listnames=None, namemap=None, nodemap=None):
125 """create a namespace
134 """create a namespace
126
135
127 name: the namespace to be registered (in plural form)
136 name: the namespace to be registered (in plural form)
@@ -130,6 +139,8 b' class namespace(object):'
130 is used
139 is used
131 colorname: the name to use for colored log output; if not specified
140 colorname: the name to use for colored log output; if not specified
132 logname is used
141 logname is used
142 logfmt: the format to use for (l10n-ed) log output; if not specified
143 it is composed from logname
133 listnames: function to list all names
144 listnames: function to list all names
134 namemap: function that inputs a node, output name(s)
145 namemap: function that inputs a node, output name(s)
135 nodemap: function that inputs a name, output node(s)
146 nodemap: function that inputs a name, output node(s)
@@ -139,6 +150,7 b' class namespace(object):'
139 self.templatename = templatename
150 self.templatename = templatename
140 self.logname = logname
151 self.logname = logname
141 self.colorname = colorname
152 self.colorname = colorname
153 self.logfmt = logfmt
142 self.listnames = listnames
154 self.listnames = listnames
143 self.namemap = namemap
155 self.namemap = namemap
144 self.nodemap = nodemap
156 self.nodemap = nodemap
@@ -151,6 +163,11 b' class namespace(object):'
151 if self.colorname is None:
163 if self.colorname is None:
152 self.colorname = self.logname
164 self.colorname = self.logname
153
165
166 # if logfmt is not specified, compose it from logname as backup
167 if self.logfmt is None:
168 # i18n: column positioning for "hg log"
169 self.logfmt = ("%s:" % self.logname).ljust(13) + "%s\n"
170
154 def names(self, repo, node):
171 def names(self, repo, node):
155 """method that returns a (sorted) list of names in a namespace that
172 """method that returns a (sorted) list of names in a namespace that
156 match a given node"""
173 match a given node"""
General Comments 0
You need to be logged in to leave comments. Login now