Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmdutil.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 | 566daffc607d |
children | e45c6b153e51 |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Thu Apr 04 17:34:43 2019 -0700 +++ b/mercurial/cmdutil.py Thu Apr 04 11:35:18 2019 +0200 @@ -201,7 +201,8 @@ setattr(ui, 'write', wrap) return oldwrite -def filterchunks(ui, originalhunks, usecurses, testfile, operation=None): +def filterchunks(ui, originalhunks, usecurses, testfile, match, + operation=None): try: if usecurses: if testfile: @@ -216,9 +217,9 @@ ui.warn('%s\n' % e.message) ui.warn(_('falling back to text mode\n')) - return patch.filterpatch(ui, originalhunks, operation) - -def recordfilter(ui, originalhunks, operation=None): + return patch.filterpatch(ui, originalhunks, match, operation) + +def recordfilter(ui, originalhunks, match, operation=None): """ Prompts the user to filter the originalhunks and return a list of selected hunks. *operation* is used for to build ui messages to indicate the user what @@ -230,7 +231,7 @@ oldwrite = setupwrapcolorwrite(ui) try: newchunks, newopts = filterchunks(ui, originalhunks, usecurses, - testfile, operation) + testfile, match, operation) finally: ui.write = oldwrite return newchunks, newopts @@ -312,10 +313,11 @@ diffopts.showfunc = True originaldiff = patch.diff(repo, changes=status, opts=diffopts) originalchunks = patch.parsepatch(originaldiff) + match = scmutil.match(repo[None], pats) # 1. filter patch, since we are intending to apply subset of it try: - chunks, newopts = filterfn(ui, originalchunks) + chunks, newopts = filterfn(ui, originalchunks, match) except error.PatchError as err: raise error.Abort(_('error parsing patch: %s') % err) opts.update(newopts) @@ -3081,8 +3083,9 @@ prefetch(repo, [ctx.rev()], matchfiles(repo, [f for sublist in oplist for f in sublist])) + match = scmutil.match(repo[None], pats) _performrevert(repo, parents, ctx, names, uipathfn, actions, - interactive, tobackup) + match, interactive, tobackup) if targetsubs: # Revert the subrepos on the revert list @@ -3095,7 +3098,7 @@ % (sub, short(ctx.node()))) def _performrevert(repo, parents, ctx, names, uipathfn, actions, - interactive=False, tobackup=None): + match, interactive=False, tobackup=None): """function that actually perform all the actions computed for revert This is an independent function to let extension to plug in and react to @@ -3191,7 +3194,7 @@ try: - chunks, opts = recordfilter(repo.ui, originalchunks, + chunks, opts = recordfilter(repo.ui, originalchunks, match, operation=operation) if operation == 'discard': chunks = patch.reversehunks(chunks)