Commit 2ac69ff5 authored by Denis Laxalde's avatar Denis Laxalde

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).
parent 841092fd6b85
......@@ -3167,6 +3167,13 @@ def _performrevert(repo, parents, ctx, actions, interactive=False,
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 @@ def _performrevert(repo, parents, ctx, actions, interactive=False,
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)
......
......@@ -46,6 +46,7 @@ Revert interactive tests
> y
> y
> y
> y
> n
> n
> EOF
......@@ -53,6 +54,7 @@ Revert interactive tests
reverting folder1/g (glob)
removing folder1/i (glob)
reverting folder2/h (glob)
remove added file folder1/i (Yn)? y
diff --git a/f b/f
2 hunks, 2 lines changed
examine changes to 'f'? [Ynesfdaq?] y
......@@ -174,6 +176,7 @@ Test --no-backup
$ hg update -C 6
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg revert -i -r 2 --all -- << EOF
> n
> y
> y
> y
......@@ -186,6 +189,7 @@ Test --no-backup
reverting folder1/g (glob)
removing folder1/i (glob)
reverting folder2/h (glob)
remove added file folder1/i (Yn)? n
diff --git a/f b/f
2 hunks, 2 lines changed
examine changes to 'f'? [Ynesfdaq?] y
......@@ -258,7 +262,6 @@ Test --no-backup
$ hg st
M f
M folder1/g
R folder1/i
$ hg revert --interactive f << EOF
> y
> y
......@@ -290,7 +293,6 @@ Test --no-backup
$ hg st
M f
M folder1/g
R folder1/i
? f.orig
$ cat f
a
......@@ -307,7 +309,7 @@ Test --no-backup
5
$ rm f.orig
$ hg update -C .
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
Check editing files newly added by a revert
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment