# HG changeset patch # User Martin von Zweigbergk # Date 1648489390 25200 # Node ID 3f6ef67e7a606fbe1ff059ffde294df7ba216ac3 # Parent 9be7da3418853c434f345cd4afe4da9ae596869a revert: ask user to confirm before tracking new file when interactive If interactively reverting from a commit with `hg revert -i -r`, we would unconditionally add files from that commit that are not already tracked in the working copy. We have prompts for adding back files removed in the working copy, but that's specific to such files and does not apply to adding files from another revision. Differential Revision: https://phab.mercurial-scm.org/D12416 diff -r 9be7da341885 -r 3f6ef67e7a60 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Mon Mar 28 10:43:06 2022 -0700 +++ b/mercurial/cmdutil.py Mon Mar 28 10:43:10 2022 -0700 @@ -3752,6 +3752,12 @@ if f in newlyaddedandmodifiedfiles: continue + if interactive: + choice = repo.ui.promptchoice( + _(b"add new file %s (Yn)?$$ &Yes $$ &No") % uipathfn(f) + ) + if choice != 0: + continue prntstatusmsg(b'add', f) checkout(f) repo.dirstate.set_tracked(f) diff -r 9be7da341885 -r 3f6ef67e7a60 tests/test-revert-interactive.t --- a/tests/test-revert-interactive.t Mon Mar 28 10:43:06 2022 -0700 +++ b/tests/test-revert-interactive.t Mon Mar 28 10:43:10 2022 -0700 @@ -420,6 +420,19 @@ forgetting newfile $ hg status ? newfile + $ rm newfile + $ hg up 0 + 1 files updated, 0 files merged, 4 files removed, 0 files unresolved + $ hg status + $ hg revert -r 2 -i < y + > n + > EOF + add new file folder1/g (Yn)? y + adding folder1/g + add new file folder2/h (Yn)? n + $ hg status + A folder1/g When a line without EOL is selected during "revert -i" (issue5651)