Mercurial > hg
changeset 35609:c026547454dd
visibility: make the filtered message translatable
Introduce a filtered message table to ease translation of these messages.
Differential Revision: https://phab.mercurial-scm.org/D1852
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 12 Jan 2018 11:10:18 +0000 |
parents | fe4e1352c035 |
children | 22c42bfbe7ab |
files | mercurial/context.py mercurial/obsutil.py |
diffstat | 2 files changed, 21 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Fri Jan 12 11:09:04 2018 +0000 +++ b/mercurial/context.py Fri Jan 12 11:10:18 2018 +0000 @@ -442,8 +442,7 @@ # If the changeset is obsolete, enrich the message with the reason # that made this changeset not visible if ctx.obsolete(): - reason = obsutil._getfilteredreason(unfilteredrepo, ctx) - msg = _("hidden revision '%s' %s") % (changeid, reason) + msg = obsutil._getfilteredreason(unfilteredrepo, changeid, ctx) else: msg = _("hidden revision '%s'") % changeid
--- a/mercurial/obsutil.py Fri Jan 12 11:09:04 2018 +0000 +++ b/mercurial/obsutil.py Fri Jan 12 11:10:18 2018 +0000 @@ -865,7 +865,17 @@ return "".join(line) -def _getfilteredreason(unfilteredrepo, ctx): + +filteredmsgtable = { + "pruned": _("hidden revision '%s' is pruned"), + "diverged": _("hidden revision '%s' has diverged"), + "superseded": _("hidden revision '%s' was rewritten as: %s"), + "superseded_split": _("hidden revision '%s' was split as: %s"), + "superseded_split_several": _("hidden revision '%s' was split as: %s and " + "%d more"), +} + +def _getfilteredreason(unfilteredrepo, changeid, ctx): """return a human-friendly string on why a obsolete changeset is hidden """ successors = successorssets(unfilteredrepo, ctx.node()) @@ -873,11 +883,12 @@ # Be more precise in case the revision is superseded if fate == 'pruned': - reason = _('is pruned') + return filteredmsgtable['pruned'] % changeid elif fate == 'diverged': - reason = _('has diverged') + return filteredmsgtable['diverged'] % changeid elif fate == 'superseded': - reason = _("was rewritten as: %s") % nodemod.short(successors[0][0]) + single_successor = nodemod.short(successors[0][0]) + return filteredmsgtable['superseded'] % (changeid, single_successor) elif fate == 'superseded_split': succs = [] @@ -885,13 +896,11 @@ succs.append(nodemod.short(node_id)) if len(succs) <= 2: - reason = _("was split as: %s") % ", ".join(succs) + fmtsuccs = ', '.join(succs) + return filteredmsgtable['superseded_split'] % (changeid, fmtsuccs) else: - firstsuccessors = ", ".join(succs[:2]) + firstsuccessors = ', '.join(succs[:2]) remainingnumber = len(succs) - 2 - args = (firstsuccessors, remainingnumber) - successorsmsg = _("%s and %d more") % args - reason = _("was split as: %s") % successorsmsg - - return reason + args = (changeid, firstsuccessors, remainingnumber) + return filteredmsgtable['superseded_split_several'] % args