Mercurial > public > mercurial-scm > hg
comparison mercurial/patch.py @ 42071:db72f9f6580e
interactive: do not prompt about files given in command line
For commit and revert commands with --interactive and explicit files
given in the command line, we now skip the invite to "examine changes to
<file> ? [Ynesfdaq?]". The reason for this is that, if <file> is
specified by the user, asking for confirmation is redundant.
In patch.filterpatch(), we now use an optional "match" argument to
conditionally call the prompt() function when entering a new "header"
item. We use .exact() method to compare with files from the "header" in
order to only consider (rel)path patterns.
Add tests with glob patterns for commit and revert, to make sure we
still ask to examine files in these cases.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Thu, 04 Apr 2019 11:35:18 +0200 |
parents | c1d83d916e85 |
children | f802a75da585 |
comparison
equal
deleted
inserted
replaced
42070:675775c33ab6 | 42071:db72f9f6580e |
---|---|
1063 '$$ &Quit, recording no changes' | 1063 '$$ &Quit, recording no changes' |
1064 '$$ &? (display help)'), | 1064 '$$ &? (display help)'), |
1065 } | 1065 } |
1066 } | 1066 } |
1067 | 1067 |
1068 def filterpatch(ui, headers, operation=None): | 1068 def filterpatch(ui, headers, match, operation=None): |
1069 """Interactively filter patch chunks into applied-only chunks""" | 1069 """Interactively filter patch chunks into applied-only chunks""" |
1070 messages = getmessages() | 1070 messages = getmessages() |
1071 | 1071 |
1072 if operation is None: | 1072 if operation is None: |
1073 operation = 'record' | 1073 operation = 'record' |
1180 if hdr in seen: | 1180 if hdr in seen: |
1181 continue | 1181 continue |
1182 seen.add(hdr) | 1182 seen.add(hdr) |
1183 if skipall is None: | 1183 if skipall is None: |
1184 h.pretty(ui) | 1184 h.pretty(ui) |
1185 files = h.files() | |
1185 msg = (_('examine changes to %s?') % | 1186 msg = (_('examine changes to %s?') % |
1186 _(' and ').join("'%s'" % f for f in h.files())) | 1187 _(' and ').join("'%s'" % f for f in files)) |
1187 r, skipfile, skipall, np = prompt(skipfile, skipall, msg, None) | 1188 if all(match.exact(f) for f in files): |
1189 r, skipall, np = True, None, None | |
1190 else: | |
1191 r, skipfile, skipall, np = prompt(skipfile, skipall, msg, None) | |
1188 if not r: | 1192 if not r: |
1189 continue | 1193 continue |
1190 applied[h.filename()] = [h] | 1194 applied[h.filename()] = [h] |
1191 if h.allhunks(): | 1195 if h.allhunks(): |
1192 applied[h.filename()] += h.hunks | 1196 applied[h.filename()] += h.hunks |