##// END OF EJS Templates
patch: take messages out of the function so that extensions can add entries...
Pulkit Goyal -
r34044:c0170d88 default
parent child Browse files
Show More
@@ -996,54 +996,55 b' class recordhunk(object):'
996 def __repr__(self):
996 def __repr__(self):
997 return '<hunk %r@%d>' % (self.filename(), self.fromline)
997 return '<hunk %r@%d>' % (self.filename(), self.fromline)
998
998
999 messages = {
1000 'multiple': {
1001 'discard': _("discard change %d/%d to '%s'?"),
1002 'record': _("record change %d/%d to '%s'?"),
1003 'revert': _("revert change %d/%d to '%s'?"),
1004 },
1005 'single': {
1006 'discard': _("discard this change to '%s'?"),
1007 'record': _("record this change to '%s'?"),
1008 'revert': _("revert this change to '%s'?"),
1009 },
1010 'help': {
1011 'discard': _('[Ynesfdaq?]'
1012 '$$ &Yes, discard this change'
1013 '$$ &No, skip this change'
1014 '$$ &Edit this change manually'
1015 '$$ &Skip remaining changes to this file'
1016 '$$ Discard remaining changes to this &file'
1017 '$$ &Done, skip remaining changes and files'
1018 '$$ Discard &all changes to all remaining files'
1019 '$$ &Quit, discarding no changes'
1020 '$$ &? (display help)'),
1021 'record': _('[Ynesfdaq?]'
1022 '$$ &Yes, record this change'
1023 '$$ &No, skip this change'
1024 '$$ &Edit this change manually'
1025 '$$ &Skip remaining changes to this file'
1026 '$$ Record remaining changes to this &file'
1027 '$$ &Done, skip remaining changes and files'
1028 '$$ Record &all changes to all remaining files'
1029 '$$ &Quit, recording no changes'
1030 '$$ &? (display help)'),
1031 'revert': _('[Ynesfdaq?]'
1032 '$$ &Yes, revert this change'
1033 '$$ &No, skip this change'
1034 '$$ &Edit this change manually'
1035 '$$ &Skip remaining changes to this file'
1036 '$$ Revert remaining changes to this &file'
1037 '$$ &Done, skip remaining changes and files'
1038 '$$ Revert &all changes to all remaining files'
1039 '$$ &Quit, reverting no changes'
1040 '$$ &? (display help)')
1041 }
1042 }
1043
999 def filterpatch(ui, headers, operation=None):
1044 def filterpatch(ui, headers, operation=None):
1000 """Interactively filter patch chunks into applied-only chunks"""
1045 """Interactively filter patch chunks into applied-only chunks"""
1001 if operation is None:
1046 if operation is None:
1002 operation = 'record'
1047 operation = 'record'
1003 messages = {
1004 'multiple': {
1005 'discard': _("discard change %d/%d to '%s'?"),
1006 'record': _("record change %d/%d to '%s'?"),
1007 'revert': _("revert change %d/%d to '%s'?"),
1008 }[operation],
1009 'single': {
1010 'discard': _("discard this change to '%s'?"),
1011 'record': _("record this change to '%s'?"),
1012 'revert': _("revert this change to '%s'?"),
1013 }[operation],
1014 'help': {
1015 'discard': _('[Ynesfdaq?]'
1016 '$$ &Yes, discard this change'
1017 '$$ &No, skip this change'
1018 '$$ &Edit this change manually'
1019 '$$ &Skip remaining changes to this file'
1020 '$$ Discard remaining changes to this &file'
1021 '$$ &Done, skip remaining changes and files'
1022 '$$ Discard &all changes to all remaining files'
1023 '$$ &Quit, discarding no changes'
1024 '$$ &? (display help)'),
1025 'record': _('[Ynesfdaq?]'
1026 '$$ &Yes, record this change'
1027 '$$ &No, skip this change'
1028 '$$ &Edit this change manually'
1029 '$$ &Skip remaining changes to this file'
1030 '$$ Record remaining changes to this &file'
1031 '$$ &Done, skip remaining changes and files'
1032 '$$ Record &all changes to all remaining files'
1033 '$$ &Quit, recording no changes'
1034 '$$ &? (display help)'),
1035 'revert': _('[Ynesfdaq?]'
1036 '$$ &Yes, revert this change'
1037 '$$ &No, skip this change'
1038 '$$ &Edit this change manually'
1039 '$$ &Skip remaining changes to this file'
1040 '$$ Revert remaining changes to this &file'
1041 '$$ &Done, skip remaining changes and files'
1042 '$$ Revert &all changes to all remaining files'
1043 '$$ &Quit, reverting no changes'
1044 '$$ &? (display help)')
1045 }[operation]
1046 }
1047
1048
1048 def prompt(skipfile, skipall, query, chunk):
1049 def prompt(skipfile, skipall, query, chunk):
1049 """prompt query, and process base inputs
1050 """prompt query, and process base inputs
@@ -1061,7 +1062,7 b' def filterpatch(ui, headers, operation=N'
1061 if skipfile is not None:
1062 if skipfile is not None:
1062 return skipfile, skipfile, skipall, newpatches
1063 return skipfile, skipfile, skipall, newpatches
1063 while True:
1064 while True:
1064 resps = messages['help']
1065 resps = messages['help'][operation]
1065 r = ui.promptchoice("%s %s" % (query, resps))
1066 r = ui.promptchoice("%s %s" % (query, resps))
1066 ui.write("\n")
1067 ui.write("\n")
1067 if r == 8: # ?
1068 if r == 8: # ?
@@ -1166,10 +1167,11 b' the hunk is left unchanged.'
1166 if skipfile is None and skipall is None:
1167 if skipfile is None and skipall is None:
1167 chunk.pretty(ui)
1168 chunk.pretty(ui)
1168 if total == 1:
1169 if total == 1:
1169 msg = messages['single'] % chunk.filename()
1170 msg = messages['single'][operation] % chunk.filename()
1170 else:
1171 else:
1171 idx = pos - len(h.hunks) + i
1172 idx = pos - len(h.hunks) + i
1172 msg = messages['multiple'] % (idx, total, chunk.filename())
1173 msg = messages['multiple'][operation] % (idx, total,
1174 chunk.filename())
1173 r, skipfile, skipall, newpatches = prompt(skipfile,
1175 r, skipfile, skipall, newpatches = prompt(skipfile,
1174 skipall, msg, chunk)
1176 skipall, msg, chunk)
1175 if r:
1177 if r:
General Comments 0
You need to be logged in to leave comments. Login now