Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/obsutil.py @ 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 | 265cd9e19d26 |
children | 22c42bfbe7ab |
comparison
equal
deleted
inserted
replaced
35608:fe4e1352c035 | 35609:c026547454dd |
---|---|
863 fmtmax_date = util.datestr(max_date, '%Y-%m-%d %H:%M %1%2') | 863 fmtmax_date = util.datestr(max_date, '%Y-%m-%d %H:%M %1%2') |
864 line.append(" (between %s and %s)" % (fmtmin_date, fmtmax_date)) | 864 line.append(" (between %s and %s)" % (fmtmin_date, fmtmax_date)) |
865 | 865 |
866 return "".join(line) | 866 return "".join(line) |
867 | 867 |
868 def _getfilteredreason(unfilteredrepo, ctx): | 868 |
869 filteredmsgtable = { | |
870 "pruned": _("hidden revision '%s' is pruned"), | |
871 "diverged": _("hidden revision '%s' has diverged"), | |
872 "superseded": _("hidden revision '%s' was rewritten as: %s"), | |
873 "superseded_split": _("hidden revision '%s' was split as: %s"), | |
874 "superseded_split_several": _("hidden revision '%s' was split as: %s and " | |
875 "%d more"), | |
876 } | |
877 | |
878 def _getfilteredreason(unfilteredrepo, changeid, ctx): | |
869 """return a human-friendly string on why a obsolete changeset is hidden | 879 """return a human-friendly string on why a obsolete changeset is hidden |
870 """ | 880 """ |
871 successors = successorssets(unfilteredrepo, ctx.node()) | 881 successors = successorssets(unfilteredrepo, ctx.node()) |
872 fate = _getobsfate(successors) | 882 fate = _getobsfate(successors) |
873 | 883 |
874 # Be more precise in case the revision is superseded | 884 # Be more precise in case the revision is superseded |
875 if fate == 'pruned': | 885 if fate == 'pruned': |
876 reason = _('is pruned') | 886 return filteredmsgtable['pruned'] % changeid |
877 elif fate == 'diverged': | 887 elif fate == 'diverged': |
878 reason = _('has diverged') | 888 return filteredmsgtable['diverged'] % changeid |
879 elif fate == 'superseded': | 889 elif fate == 'superseded': |
880 reason = _("was rewritten as: %s") % nodemod.short(successors[0][0]) | 890 single_successor = nodemod.short(successors[0][0]) |
891 return filteredmsgtable['superseded'] % (changeid, single_successor) | |
881 elif fate == 'superseded_split': | 892 elif fate == 'superseded_split': |
882 | 893 |
883 succs = [] | 894 succs = [] |
884 for node_id in successors[0]: | 895 for node_id in successors[0]: |
885 succs.append(nodemod.short(node_id)) | 896 succs.append(nodemod.short(node_id)) |
886 | 897 |
887 if len(succs) <= 2: | 898 if len(succs) <= 2: |
888 reason = _("was split as: %s") % ", ".join(succs) | 899 fmtsuccs = ', '.join(succs) |
900 return filteredmsgtable['superseded_split'] % (changeid, fmtsuccs) | |
889 else: | 901 else: |
890 firstsuccessors = ", ".join(succs[:2]) | 902 firstsuccessors = ', '.join(succs[:2]) |
891 remainingnumber = len(succs) - 2 | 903 remainingnumber = len(succs) - 2 |
892 | 904 |
893 args = (firstsuccessors, remainingnumber) | 905 args = (changeid, firstsuccessors, remainingnumber) |
894 successorsmsg = _("%s and %d more") % args | 906 return filteredmsgtable['superseded_split_several'] % args |
895 reason = _("was split as: %s") % successorsmsg | |
896 | |
897 return reason |