Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 23772:07309e527df7
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).
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Fri, 17 Oct 2014 09:26:37 -0700 |
parents | b9d06fa10ef2 |
children | b95b9fd7ba29 |
comparison
equal
deleted
inserted
replaced
23771:9f81f9e5b47a | 23772:07309e527df7 |
---|---|
900 | 900 |
901 # i18n: column positioning for "hg log" | 901 # i18n: column positioning for "hg log" |
902 self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)), | 902 self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)), |
903 label='log.changeset changeset.%s' % ctx.phasestr()) | 903 label='log.changeset changeset.%s' % ctx.phasestr()) |
904 | 904 |
905 # branches are shown first before any other names due to backwards | |
906 # compatibility | |
905 branch = ctx.branch() | 907 branch = ctx.branch() |
906 # don't show the default branch name | 908 # don't show the default branch name |
907 if branch != 'default': | 909 if branch != 'default': |
908 # i18n: column positioning for "hg log" | 910 # i18n: column positioning for "hg log" |
909 self.ui.write(_("branch: %s\n") % branch, | 911 self.ui.write(_("branch: %s\n") % branch, |
910 label='log.branch') | 912 label='log.branch') |
911 for bookmark in self.repo.nodebookmarks(changenode): | 913 |
912 # i18n: column positioning for "hg log" | 914 for name, ns in self.repo.names.iteritems(): |
913 self.ui.write(_("bookmark: %s\n") % bookmark, | 915 # branches has special logic already handled above, so here we just |
914 label='log.bookmark') | 916 # skip it |
915 for tag in self.repo.nodetags(changenode): | 917 if name == 'branches': |
916 # i18n: column positioning for "hg log" | 918 continue |
917 self.ui.write(_("tag: %s\n") % tag, | 919 # we will use the templatename as the color name since those two |
918 label='log.tag') | 920 # should be the same |
921 for name in ns.names(self.repo, changenode): | |
922 # i18n: column positioning for "hg log" | |
923 tname = _(("%s:" % ns.templatename).ljust(13) + "%s\n") % name | |
924 self.ui.write("%s" % tname, label='log.%s' % ns.templatename) | |
919 if self.ui.debugflag: | 925 if self.ui.debugflag: |
920 # i18n: column positioning for "hg log" | 926 # i18n: column positioning for "hg log" |
921 self.ui.write(_("phase: %s\n") % _(ctx.phasestr()), | 927 self.ui.write(_("phase: %s\n") % _(ctx.phasestr()), |
922 label='log.phase') | 928 label='log.phase') |
923 for parent in parents: | 929 for parent in parents: |