##// 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 919 # we will use the templatename as the color name since those two
920 920 # should be the same
921 921 for name in ns.names(self.repo, changenode):
922 # i18n: column positioning for "hg log"
923 name = _(("%s:" % ns.logname).ljust(13) + "%s\n") % name
924 self.ui.write("%s" % name, label='log.%s' % ns.colorname)
922 self.ui.write(ns.logfmt % name,
923 label='log.%s' % ns.colorname)
925 924 if self.ui.debugflag:
926 925 # i18n: column positioning for "hg log"
927 926 self.ui.write(_("phase: %s\n") % _(ctx.phasestr()),
@@ -27,21 +27,30 b' class namespaces(object):'
27 27 bmknames = lambda repo: repo._bookmarks.keys()
28 28 bmknamemap = lambda repo, name: tolist(repo._bookmarks.get(name))
29 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 34 namemap=bmknamemap, nodemap=bmknodemap)
32 35 self.addnamespace(n)
33 36
34 37 tagnames = lambda repo: [t for t, n in repo.tagslist()]
35 38 tagnamemap = lambda repo, name: tolist(repo._tagscache.tags.get(name))
36 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 44 namemap=tagnamemap, nodemap=tagnodemap)
39 45 self.addnamespace(n)
40 46
41 47 bnames = lambda repo: repo.branchmap().keys()
42 48 bnamemap = lambda repo, name: tolist(repo.branchtip(name, True))
43 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 54 namemap=bnamemap, nodemap=bnodemap)
46 55 self.addnamespace(n)
47 56
@@ -121,7 +130,7 b' class namespace(object):'
121 130 """
122 131
123 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 134 """create a namespace
126 135
127 136 name: the namespace to be registered (in plural form)
@@ -130,6 +139,8 b' class namespace(object):'
130 139 is used
131 140 colorname: the name to use for colored log output; if not specified
132 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 144 listnames: function to list all names
134 145 namemap: function that inputs a node, output name(s)
135 146 nodemap: function that inputs a name, output node(s)
@@ -139,6 +150,7 b' class namespace(object):'
139 150 self.templatename = templatename
140 151 self.logname = logname
141 152 self.colorname = colorname
153 self.logfmt = logfmt
142 154 self.listnames = listnames
143 155 self.namemap = namemap
144 156 self.nodemap = nodemap
@@ -151,6 +163,11 b' class namespace(object):'
151 163 if self.colorname is None:
152 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 171 def names(self, repo, node):
155 172 """method that returns a (sorted) list of names in a namespace that
156 173 match a given node"""
General Comments 0
You need to be logged in to leave comments. Login now