Commit 8bb77032 authored by Laurent Charignon's avatar Laurent Charignon

revert: make revert --interactive use git style diff

This allows us to use existing code to detect files that are newly added and
modified. In turn, this allows us to make revert --interactive support
editing newly added and modified files.
parent 07326d76f19d
......@@ -3127,7 +3127,10 @@ def _performrevert(repo, parents, ctx, actions, interactive=False):
# Prompt the user for changes to revert
torevert = [repo.wjoin(f) for f in actions['revert'][0]]
m = scmutil.match(ctx, torevert, {})
diff = patch.diff(repo, None, ctx.node(), m)
diffopts = patch.difffeatureopts(repo.ui, whitespace=True)
diffopts.nodates = True
diffopts.git = True
diff = patch.diff(repo, None, ctx.node(), m, opts=diffopts)
originalchunks = patch.parsepatch(diff)
try:
chunks = recordfilter(repo.ui, originalchunks)
......
......@@ -52,7 +52,7 @@ Revert interactive tests
reverting folder1/g (glob)
removing folder1/i (glob)
reverting folder2/h (glob)
diff -r 89ac3d72e4a4 f
diff --git a/f b/f
2 hunks, 2 lines changed
examine changes to 'f'? [Ynesfdaq?] y
......@@ -74,7 +74,7 @@ Revert interactive tests
-b
record change 2/6 to 'f'? [Ynesfdaq?] y
diff -r 89ac3d72e4a4 folder1/g
diff --git a/folder1/g b/folder1/g
2 hunks, 2 lines changed
examine changes to 'folder1/g'? [Ynesfdaq?] y
......@@ -96,7 +96,7 @@ Revert interactive tests
-d
record change 4/6 to 'folder1/g'? [Ynesfdaq?] n
diff -r 89ac3d72e4a4 folder2/h
diff --git a/folder2/h b/folder2/h
2 hunks, 2 lines changed
examine changes to 'folder2/h'? [Ynesfdaq?] n
......@@ -127,7 +127,7 @@ Test that --interactive lift the need for --all
$ echo q | hg revert -i -r 2
reverting folder1/g (glob)
reverting folder2/h (glob)
diff -r 89ac3d72e4a4 folder1/g
diff --git a/folder1/g b/folder1/g
1 hunks, 1 lines changed
examine changes to 'folder1/g'? [Ynesfdaq?] q
......@@ -151,7 +151,7 @@ Test that --interactive lift the need for --all
reverting folder1/g (glob)
removing folder1/i (glob)
reverting folder2/h (glob)
diff -r 89ac3d72e4a4 f
diff --git a/f b/f
2 hunks, 2 lines changed
examine changes to 'f'? [Ynesfdaq?] y
......@@ -173,7 +173,7 @@ Test that --interactive lift the need for --all
-b
record change 2/6 to 'f'? [Ynesfdaq?] y
diff -r 89ac3d72e4a4 folder1/g
diff --git a/folder1/g b/folder1/g
2 hunks, 2 lines changed
examine changes to 'folder1/g'? [Ynesfdaq?] y
......@@ -195,7 +195,7 @@ Test that --interactive lift the need for --all
-d
record change 4/6 to 'folder1/g'? [Ynesfdaq?] n
diff -r 89ac3d72e4a4 folder2/h
diff --git a/folder2/h b/folder2/h
2 hunks, 2 lines changed
examine changes to 'folder2/h'? [Ynesfdaq?] n
......@@ -230,7 +230,7 @@ Test that --interactive lift the need for --all
> n
> n
> EOF
diff -r 59dd6e4ab63a f
diff --git a/f b/f
2 hunks, 2 lines changed
examine changes to 'f'? [Ynesfdaq?] y
......
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