diff mercurial/cmdutil.py @ 30541:66b162fa3ffa

revert: prompt before removing files in interactive mode Prior to this change, files to be removed (i.e. files added since the revision to revert to) were unconditionally removed despite the interactive mode. Now prompt before actually removing the files, as this is done for other actions (e.g. forget).
author Denis Laxalde <denis.laxalde@logilab.fr>
date Fri, 25 Nov 2016 09:10:30 +0100
parents 841092fd6b85
children c01033fb9864
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Fri Nov 25 09:09:31 2016 +0100
+++ b/mercurial/cmdutil.py	Fri Nov 25 09:10:30 2016 +0100
@@ -3167,6 +3167,13 @@
         fc = ctx[f]
         repo.wwrite(f, fc.data(), fc.flags())
 
+    def doremove(f):
+        try:
+            util.unlinkpath(repo.wjoin(f))
+        except OSError:
+            pass
+        repo.dirstate.remove(f)
+
     audit_path = pathutil.pathauditor(repo.root)
     for f in actions['forget'][0]:
         if interactive:
@@ -3180,11 +3187,15 @@
             repo.dirstate.drop(f)
     for f in actions['remove'][0]:
         audit_path(f)
-        try:
-            util.unlinkpath(repo.wjoin(f))
-        except OSError:
-            pass
-        repo.dirstate.remove(f)
+        if interactive:
+            choice = repo.ui.promptchoice(
+                _("remove added file %s (Yn)?$$ &Yes $$ &No") % f)
+            if choice == 0:
+                doremove(f)
+            else:
+                excluded_files.append(repo.wjoin(f))
+        else:
+            doremove(f)
     for f in actions['drop'][0]:
         audit_path(f)
         repo.dirstate.remove(f)