From patchwork Sun Feb 3 12:48:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D5803: revert: added prompt before undeleting a file in -i(issue6008) From: phabricator X-Patchwork-Id: 38351 Message-Id: <8e771c049b60a7b62563161aa36ceaa4@localhost.localdomain> To: mercurial-devel@mercurial-scm.org Date: Sun, 3 Feb 2019 12:48:47 +0000 This revision was automatically updated to reflect the committed changes. Closed by commit rHGf3f6719951a3: revert: add prompt before undeleting a file in -i (issue6008) (authored by taapas1128, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5803?vs=13711&id=13720 REVISION DETAIL https://phab.mercurial-scm.org/D5803 AFFECTED FILES mercurial/cmdutil.py tests/test-revert-interactive.t CHANGE DETAILS To: taapas1128, #hg-reviewers Cc: yuja, mercurial-devel 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 @@ -424,3 +424,24 @@ b: no such file in rev b40d1912accf $ cd .. + +Prompt before undeleting file(issue6008) + $ hg init repo + $ cd repo + $ echo a > a + $ hg ci -qAm a + $ hg rm a + $ hg revert -i< y + > EOF + add back removed file a (Yn)? y + undeleting a + $ ls + a + $ hg rm a + $ hg revert -i< n + > EOF + add back removed file a (Yn)? n + $ ls + $ cd .. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3194,9 +3194,19 @@ if node == parent and p2 == nullid: normal = repo.dirstate.normal for f in actions['undelete'][0]: - prntstatusmsg('undelete', f) - checkout(f) - normal(f) + if interactive: + choice = repo.ui.promptchoice( + _("add back removed file %s (Yn)?$$ &Yes $$ &No") % f) + if choice == 0: + prntstatusmsg('undelete', f) + checkout(f) + normal(f) + else: + excluded_files.append(f) + else: + prntstatusmsg('undelete', f) + checkout(f) + normal(f) copied = copies.pathcopies(repo[parent], ctx)