# HG changeset patch # User Sean Farley # Date 2014-10-17 16:26:37 # Node ID 07309e527df705743ea9864108a501763918b9a3 # Parent 9f81f9e5b47a569b5de2e26b09834970fca7dcfb log: use new namespaces api to display names The only caveat here is that branches must be displayed first due to backwards compatibility. The order of namespaces is defined to be the 'update' order which, unfortunately, is not the same as log output order. It's worth mentioning that the log output is still translated the same as before since we are formating our strings the same way: # i18n: column positioning for "hg log" _("bookmark: %s\n") % bookmark becomes tname = _(("%s:" % ns.templatename).ljust(13) + "%s\n") % name when name == 'bookmark'. The ljust(13) keeps the strings and whitespace equal. Adding a new namespace is even easier now because the log output code doesn't need to change. A future programmer would just need to add the string to the corresponding .po file (which is the same as they would have had to do previously). diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -902,20 +902,26 @@ class changeset_printer(object): self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)), label='log.changeset changeset.%s' % ctx.phasestr()) + # branches are shown first before any other names due to backwards + # compatibility branch = ctx.branch() # don't show the default branch name if branch != 'default': # i18n: column positioning for "hg log" self.ui.write(_("branch: %s\n") % branch, label='log.branch') - for bookmark in self.repo.nodebookmarks(changenode): - # i18n: column positioning for "hg log" - self.ui.write(_("bookmark: %s\n") % bookmark, - label='log.bookmark') - for tag in self.repo.nodetags(changenode): - # i18n: column positioning for "hg log" - self.ui.write(_("tag: %s\n") % tag, - label='log.tag') + + for name, ns in self.repo.names.iteritems(): + # branches has special logic already handled above, so here we just + # skip it + if name == 'branches': + continue + # we will use the templatename as the color name since those two + # should be the same + for name in ns.names(self.repo, changenode): + # i18n: column positioning for "hg log" + tname = _(("%s:" % ns.templatename).ljust(13) + "%s\n") % name + self.ui.write("%s" % tname, label='log.%s' % ns.templatename) if self.ui.debugflag: # i18n: column positioning for "hg log" self.ui.write(_("phase: %s\n") % _(ctx.phasestr()),