revert: make revert --interactive use git style diff
authorLaurent Charignon <lcharignon@fb.com>
Thu, 21 May 2015 14:25:57 -0700
changeset 25258 f37a69ec3f47
parent 25257 07326d76f19d
child 25259 5b05f10c5024
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.
mercurial/cmdutil.py
tests/test-revert-interactive.t
--- a/mercurial/cmdutil.py	Thu May 21 14:32:14 2015 -0700
+++ b/mercurial/cmdutil.py	Thu May 21 14:25:57 2015 -0700
@@ -3127,7 +3127,10 @@
         # 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)
--- a/tests/test-revert-interactive.t	Thu May 21 14:32:14 2015 -0700
+++ b/tests/test-revert-interactive.t	Thu May 21 14:25:57 2015 -0700
@@ -52,7 +52,7 @@
   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 @@
   -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 @@
   -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 @@
   $ 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 @@
   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 @@
   -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 @@
   -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 @@
   > n
   > n
   > EOF
-  diff -r 59dd6e4ab63a f
+  diff --git a/f b/f
   2 hunks, 2 lines changed
   examine changes to 'f'? [Ynesfdaq?] y