# HG changeset patch # User Laurent Charignon # Date 1432243557 25200 # Node ID f37a69ec3f4717fdb4f00699ca06c225f106696c # Parent 07326d76f19d3f163b7182e750a2b029f5c45ca3 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. diff -r 07326d76f19d -r f37a69ec3f47 mercurial/cmdutil.py --- 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) diff -r 07326d76f19d -r f37a69ec3f47 tests/test-revert-interactive.t --- 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