comparison mercurial/cmdutil.py @ 35222:c7b45db8f317

log: translate column labels at once (issue5750) This makes sure that all columns are aligned. getlogcolumns() is hosted by templatekw so the namespaces module can see it. i18n/de.po is updated so test-log.t passes with no error. "obsolete:" and "instability:" are kept untranslated.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 02 Dec 2017 16:29:49 +0900
parents 1df2f0e1dfd2
children 6ba79cf34f5e
comparison
equal deleted inserted replaced
35221:1df2f0e1dfd2 35222:c7b45db8f317
1569 self.diffopts = diffopts 1569 self.diffopts = diffopts
1570 self.header = {} 1570 self.header = {}
1571 self.hunk = {} 1571 self.hunk = {}
1572 self.lastheader = None 1572 self.lastheader = None
1573 self.footer = None 1573 self.footer = None
1574 self._columns = templatekw.getlogcolumns()
1574 1575
1575 def flush(self, ctx): 1576 def flush(self, ctx):
1576 rev = ctx.rev() 1577 rev = ctx.rev()
1577 if rev in self.header: 1578 if rev in self.header:
1578 h = self.header[rev] 1579 h = self.header[rev]
1608 if self.ui.quiet: 1609 if self.ui.quiet:
1609 self.ui.write("%s\n" % scmutil.formatchangeid(ctx), 1610 self.ui.write("%s\n" % scmutil.formatchangeid(ctx),
1610 label='log.node') 1611 label='log.node')
1611 return 1612 return
1612 1613
1613 # i18n: column positioning for "hg log" 1614 columns = self._columns
1614 self.ui.write(_("changeset: %s\n") % scmutil.formatchangeid(ctx), 1615 self.ui.write(columns['changeset'] % scmutil.formatchangeid(ctx),
1615 label=_changesetlabels(ctx)) 1616 label=_changesetlabels(ctx))
1616 1617
1617 # branches are shown first before any other names due to backwards 1618 # branches are shown first before any other names due to backwards
1618 # compatibility 1619 # compatibility
1619 branch = ctx.branch() 1620 branch = ctx.branch()
1620 # don't show the default branch name 1621 # don't show the default branch name
1621 if branch != 'default': 1622 if branch != 'default':
1622 # i18n: column positioning for "hg log" 1623 self.ui.write(columns['branch'] % branch, label='log.branch')
1623 self.ui.write(_("branch: %s\n") % branch,
1624 label='log.branch')
1625 1624
1626 for nsname, ns in self.repo.names.iteritems(): 1625 for nsname, ns in self.repo.names.iteritems():
1627 # branches has special logic already handled above, so here we just 1626 # branches has special logic already handled above, so here we just
1628 # skip it 1627 # skip it
1629 if nsname == 'branches': 1628 if nsname == 'branches':
1632 # should be the same 1631 # should be the same
1633 for name in ns.names(self.repo, changenode): 1632 for name in ns.names(self.repo, changenode):
1634 self.ui.write(ns.logfmt % name, 1633 self.ui.write(ns.logfmt % name,
1635 label='log.%s' % ns.colorname) 1634 label='log.%s' % ns.colorname)
1636 if self.ui.debugflag: 1635 if self.ui.debugflag:
1637 # i18n: column positioning for "hg log" 1636 self.ui.write(columns['phase'] % ctx.phasestr(), label='log.phase')
1638 self.ui.write(_("phase: %s\n") % ctx.phasestr(),
1639 label='log.phase')
1640 for pctx in scmutil.meaningfulparents(self.repo, ctx): 1637 for pctx in scmutil.meaningfulparents(self.repo, ctx):
1641 label = 'log.parent changeset.%s' % pctx.phasestr() 1638 label = 'log.parent changeset.%s' % pctx.phasestr()
1642 # i18n: column positioning for "hg log" 1639 self.ui.write(columns['parent'] % scmutil.formatchangeid(pctx),
1643 self.ui.write(_("parent: %s\n") % scmutil.formatchangeid(pctx),
1644 label=label) 1640 label=label)
1645 1641
1646 if self.ui.debugflag and rev is not None: 1642 if self.ui.debugflag and rev is not None:
1647 mnode = ctx.manifestnode() 1643 mnode = ctx.manifestnode()
1648 mrev = self.repo.manifestlog._revlog.rev(mnode) 1644 mrev = self.repo.manifestlog._revlog.rev(mnode)
1649 # i18n: column positioning for "hg log" 1645 self.ui.write(columns['manifest']
1650 self.ui.write(_("manifest: %s\n")
1651 % scmutil.formatrevnode(self.ui, mrev, mnode), 1646 % scmutil.formatrevnode(self.ui, mrev, mnode),
1652 label='ui.debug log.manifest') 1647 label='ui.debug log.manifest')
1653 # i18n: column positioning for "hg log" 1648 self.ui.write(columns['user'] % ctx.user(), label='log.user')
1654 self.ui.write(_("user: %s\n") % ctx.user(), 1649 self.ui.write(columns['date'] % util.datestr(ctx.date()),
1655 label='log.user')
1656 # i18n: column positioning for "hg log"
1657 self.ui.write(_("date: %s\n") % util.datestr(ctx.date()),
1658 label='log.date') 1650 label='log.date')
1659 1651
1660 if ctx.isunstable(): 1652 if ctx.isunstable():
1661 # i18n: column positioning for "hg log"
1662 instabilities = ctx.instabilities() 1653 instabilities = ctx.instabilities()
1663 self.ui.write(_("instability: %s\n") % ', '.join(instabilities), 1654 self.ui.write(columns['instability'] % ', '.join(instabilities),
1664 label='log.instability') 1655 label='log.instability')
1665 1656
1666 elif ctx.obsolete(): 1657 elif ctx.obsolete():
1667 self._showobsfate(ctx) 1658 self._showobsfate(ctx)
1668 1659
1669 self._exthook(ctx) 1660 self._exthook(ctx)
1670 1661
1671 if self.ui.debugflag: 1662 if self.ui.debugflag:
1672 files = ctx.p1().status(ctx)[:3] 1663 files = ctx.p1().status(ctx)[:3]
1673 for key, value in zip([# i18n: column positioning for "hg log" 1664 for key, value in zip(['files', 'files+', 'files-'], files):
1674 _("files:"),
1675 # i18n: column positioning for "hg log"
1676 _("files+:"),
1677 # i18n: column positioning for "hg log"
1678 _("files-:")], files):
1679 if value: 1665 if value:
1680 self.ui.write("%-12s %s\n" % (key, " ".join(value)), 1666 self.ui.write(columns[key] % " ".join(value),
1681 label='ui.debug log.files') 1667 label='ui.debug log.files')
1682 elif ctx.files() and self.ui.verbose: 1668 elif ctx.files() and self.ui.verbose:
1683 # i18n: column positioning for "hg log" 1669 self.ui.write(columns['files'] % " ".join(ctx.files()),
1684 self.ui.write(_("files: %s\n") % " ".join(ctx.files()),
1685 label='ui.note log.files') 1670 label='ui.note log.files')
1686 if copies and self.ui.verbose: 1671 if copies and self.ui.verbose:
1687 copies = ['%s (%s)' % c for c in copies] 1672 copies = ['%s (%s)' % c for c in copies]
1688 # i18n: column positioning for "hg log" 1673 self.ui.write(columns['copies'] % ' '.join(copies),
1689 self.ui.write(_("copies: %s\n") % ' '.join(copies),
1690 label='ui.note log.copies') 1674 label='ui.note log.copies')
1691 1675
1692 extra = ctx.extra() 1676 extra = ctx.extra()
1693 if extra and self.ui.debugflag: 1677 if extra and self.ui.debugflag:
1694 for key, value in sorted(extra.items()): 1678 for key, value in sorted(extra.items()):
1695 # i18n: column positioning for "hg log" 1679 self.ui.write(columns['extra'] % (key, util.escapestr(value)),
1696 self.ui.write(_("extra: %s=%s\n")
1697 % (key, util.escapestr(value)),
1698 label='ui.debug log.extra') 1680 label='ui.debug log.extra')
1699 1681
1700 description = ctx.description().strip() 1682 description = ctx.description().strip()
1701 if description: 1683 if description:
1702 if self.ui.verbose: 1684 if self.ui.verbose:
1704 label='ui.note log.description') 1686 label='ui.note log.description')
1705 self.ui.write(description, 1687 self.ui.write(description,
1706 label='ui.note log.description') 1688 label='ui.note log.description')
1707 self.ui.write("\n\n") 1689 self.ui.write("\n\n")
1708 else: 1690 else:
1709 # i18n: column positioning for "hg log" 1691 self.ui.write(columns['summary'] % description.splitlines()[0],
1710 self.ui.write(_("summary: %s\n") %
1711 description.splitlines()[0],
1712 label='log.summary') 1692 label='log.summary')
1713 self.ui.write("\n") 1693 self.ui.write("\n")
1714 1694
1715 self.showpatch(ctx, matchfn, hunksfilterfn=hunksfilterfn) 1695 self.showpatch(ctx, matchfn, hunksfilterfn=hunksfilterfn)
1716 1696
1717 def _showobsfate(self, ctx): 1697 def _showobsfate(self, ctx):
1718 obsfate = templatekw.showobsfate(repo=self.repo, ctx=ctx, ui=self.ui) 1698 obsfate = templatekw.showobsfate(repo=self.repo, ctx=ctx, ui=self.ui)
1719 1699
1720 if obsfate: 1700 if obsfate:
1721 for obsfateline in obsfate: 1701 for obsfateline in obsfate:
1722 # i18n: column positioning for "hg log" 1702 self.ui.write(self._columns['obsolete'] % obsfateline,
1723 self.ui.write(_("obsolete: %s\n") % obsfateline,
1724 label='log.obsfate') 1703 label='log.obsfate')
1725 1704
1726 def _exthook(self, ctx): 1705 def _exthook(self, ctx):
1727 '''empty method used by extension as a hook point 1706 '''empty method used by extension as a hook point
1728 ''' 1707 '''