comparison mercurial/patch.py @ 29326:d48fc6f318a3

patch: define full messages for interactive record/revert Followup 14eee72c8d52 to provide complete context for proper localization. Also update cmdutil.recordfilter docstring to remove recommendation that "operation" argument should be translated. Indeed, for record/revert, we either go to patch.filterpatch or crecord.filterpatch (in curses mode) ; the former now build the full ui message from the operation parameter and the latter does not use this parameter (removing in a followup patch). For shelve, operation is not specified and this thus falls back to "record".
author Denis Laxalde <denis.laxalde@logilab.fr>
date Tue, 07 Jun 2016 10:37:19 +0200
parents 14eee72c8d52
children 0d83ad967bf8
comparison
equal deleted inserted replaced
29325:4f2f8baba2ff 29326:d48fc6f318a3
976 return '<hunk %r@%d>' % (self.filename(), self.fromline) 976 return '<hunk %r@%d>' % (self.filename(), self.fromline)
977 977
978 def filterpatch(ui, headers, operation=None): 978 def filterpatch(ui, headers, operation=None):
979 """Interactively filter patch chunks into applied-only chunks""" 979 """Interactively filter patch chunks into applied-only chunks"""
980 if operation is None: 980 if operation is None:
981 operation = _('record') 981 operation = 'record'
982 messages = {
983 'multiple': {
984 'discard': _("discard change %d/%d to '%s'?"),
985 'record': _("record change %d/%d to '%s'?"),
986 'revert': _("revert change %d/%d to '%s'?"),
987 }[operation],
988 'single': {
989 'discard': _("discard this change to '%s'?"),
990 'record': _("record this change to '%s'?"),
991 'revert': _("revert this change to '%s'?"),
992 }[operation],
993 }
982 994
983 def prompt(skipfile, skipall, query, chunk): 995 def prompt(skipfile, skipall, query, chunk):
984 """prompt query, and process base inputs 996 """prompt query, and process base inputs
985 997
986 - y/n for the rest of file 998 - y/n for the rest of file
1107 continue 1119 continue
1108 for i, chunk in enumerate(h.hunks): 1120 for i, chunk in enumerate(h.hunks):
1109 if skipfile is None and skipall is None: 1121 if skipfile is None and skipall is None:
1110 chunk.pretty(ui) 1122 chunk.pretty(ui)
1111 if total == 1: 1123 if total == 1:
1112 msg = _("%s this change to '%s'?") % (operation, 1124 msg = messages['single'] % chunk.filename()
1113 chunk.filename())
1114 else: 1125 else:
1115 idx = pos - len(h.hunks) + i 1126 idx = pos - len(h.hunks) + i
1116 msg = _("%s change %d/%d to '%s'?") % (operation, idx, total, 1127 msg = messages['multiple'] % (idx, total, chunk.filename())
1117 chunk.filename())
1118 r, skipfile, skipall, newpatches = prompt(skipfile, 1128 r, skipfile, skipall, newpatches = prompt(skipfile,
1119 skipall, msg, chunk) 1129 skipall, msg, chunk)
1120 if r: 1130 if r:
1121 if fixoffset: 1131 if fixoffset:
1122 chunk = copy.copy(chunk) 1132 chunk = copy.copy(chunk)