Patchwork D5803: revert: added prompt before undeleting a file in -i(issue6008)

login
register
mail settings
Submitter phabricator
Date Feb. 2, 2019, 8:06 p.m.
Message ID <931a4a3d9a2b6e3477f91c69eb988f84@localhost.localdomain>
Download mbox | patch
Permalink /patch/38331/
State Not Applicable
Headers show

Comments

phabricator - Feb. 2, 2019, 8:06 p.m.
taapas1128 updated this revision to Diff 13703.
taapas1128 retitled this revision from "revert: added prompt before undeleting a file(issue6008)" to "revert: added prompt before undeleting a file in -i(issue6008)".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5803?vs=13702&id=13703

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: mercurial-devel
Yuya Nishihara - Feb. 3, 2019, 2:35 a.m.
> +        if interactive:
> +            choice = repo.ui.promptchoice(
> +                _("Undelete file %s (Yn)?$$ &Yes $$ &No") % f)

Nit: "undelete" (no capital letter) per Mercurial's convention.

And I don't think "undelete" is good for user-facing messages. Perhaps, it
can be phrased as "add back removed file %s (Yn)?".
phabricator - Feb. 3, 2019, 2:36 a.m.
yuja added a comment.


  > +        if interactive:
  >  +            choice = repo.ui.promptchoice(
  >  +                _("Undelete file %s (Yn)?$$ &Yes $$ &No") % f)
  
  Nit: "undelete" (no capital letter) per Mercurial's convention.
  
  And I don't think "undelete" is good for user-facing messages. Perhaps, it
  can be phrased as "add back removed file %s (Yn)?".

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5803

To: taapas1128, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

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<<EOF
+  > y
+  > EOF
+  Undelete file a (Yn)? y
+  undeleting a
+  $ ls
+  a
+  $ hg rm a
+  $ hg revert -i<<EOF
+  > n
+  > EOF
+  Undelete file a (Yn)? n
+  $ ls
+  $ cd ..
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3200,9 +3200,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(
+                _("Undelete 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)