# HG changeset patch # User Denis Laxalde # Date 1488805881 -3600 # Node ID 3af9a9628ecf189a2784c6d7629ba8166fb4895e # Parent 6b098ac4542ebb97197688e91c64309678d72cb4 revert: always display hunks reversed when reverting to parent When reverting to the parent of working directory, operation is "discard" so we want hunks to be presented in the same order as the diff (i.e. "reversed"). So we do not query the experimental.revertalternateinteractivemode option in this case and always set "reversehunks" to True. diff -r 6b098ac4542e -r 3af9a9628ecf mercurial/cmdutil.py --- a/mercurial/cmdutil.py Fri Mar 03 14:08:20 2017 +0100 +++ b/mercurial/cmdutil.py Mon Mar 06 14:11:21 2017 +0100 @@ -3247,15 +3247,18 @@ diffopts = patch.difffeatureopts(repo.ui, whitespace=True) diffopts.nodates = True diffopts.git = True - reversehunks = repo.ui.configbool('experimental', - 'revertalternateinteractivemode', - True) + operation = 'discard' + reversehunks = True + if node != parent: + operation = 'revert' + reversehunks = repo.ui.configbool('experimental', + 'revertalternateinteractivemode', + True) if reversehunks: diff = patch.diff(repo, ctx.node(), None, m, opts=diffopts) else: diff = patch.diff(repo, None, ctx.node(), m, opts=diffopts) originalchunks = patch.parsepatch(diff) - operation = 'discard' if node == parent else 'revert' try: diff -r 6b098ac4542e -r 3af9a9628ecf tests/test-revert-interactive.t --- a/tests/test-revert-interactive.t Fri Mar 03 14:08:20 2017 +0100 +++ b/tests/test-revert-interactive.t Mon Mar 06 14:11:21 2017 +0100 @@ -380,29 +380,29 @@ 3 hunks, 3 lines changed examine changes to 'folder1/g'? [Ynesfdaq?] y - @@ -1,5 +1,4 @@ - -firstline + @@ -1,4 +1,5 @@ + +firstline c 1 2 3 discard change 1/3 to 'folder1/g'? [Ynesfdaq?] y - @@ -2,7 +1,7 @@ + @@ -1,7 +2,7 @@ c 1 2 3 - - 3 - +4 + -4 + + 3 5 d discard change 2/3 to 'folder1/g'? [Ynesfdaq?] y - @@ -7,3 +6,2 @@ + @@ -6,2 +7,3 @@ 5 d - -lastline + +lastline discard change 3/3 to 'folder1/g'? [Ynesfdaq?] n $ hg diff --nodates