diff mercurial/cmdutil.py @ 31206:3af9a9628ecf

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.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Mon, 06 Mar 2017 14:11:21 +0100
parents 1ec89cf0ea49
children 21fa3d3688f3
line wrap: on
line diff
--- 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: