diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3130,13 +3130,26 @@ def _performrevert(repo, parents, ctx, a """ parent, p2 = parents node = ctx.node() + excluded_files = [] + matcher_opts = {"exclude": excluded_files} + def checkout(f): fc = ctx[f] repo.wwrite(f, fc.data(), fc.flags()) audit_path = pathutil.pathauditor(repo.root) for f in actions['forget'][0]: - repo.dirstate.drop(f) + if interactive: + choice = \ + repo.ui.promptchoice( + _("forget added file %s (yn)?$$ &Yes $$ &No") + % f) + if choice == 0: + repo.dirstate.drop(f) + else: + excluded_files.append(repo.wjoin(f)) + else: + repo.dirstate.drop(f) for f in actions['remove'][0]: audit_path(f) try: @@ -3162,7 +3175,7 @@ def _performrevert(repo, parents, ctx, a if interactive: # Prompt the user for changes to revert torevert = [repo.wjoin(f) for f in actions['revert'][0]] - m = scmutil.match(ctx, torevert, {}) + m = scmutil.match(ctx, torevert, matcher_opts) diffopts = patch.difffeatureopts(repo.ui, whitespace=True) diffopts.nodates = True diffopts.git = True diff --git a/tests/test-revert-interactive.t b/tests/test-revert-interactive.t --- a/tests/test-revert-interactive.t +++ b/tests/test-revert-interactive.t @@ -15,6 +15,7 @@ 10 run the same test than 8 from within > interactive = true > [extensions] > record = + > purge = > EOF @@ -377,3 +378,26 @@ Check the experimental config to invert 5 d +lastline + + $ hg update -C . + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg purge + $ touch newfile + $ hg add newfile + $ hg status + A newfile + $ hg revert -i < n + > EOF + forgetting newfile + forget added file newfile (yn)? n + $ hg status + A newfile + $ hg revert -i < y + > EOF + forgetting newfile + forget added file newfile (yn)? y + $ hg status + ? newfile +