changeset 6161:bc1ba9124799

Reverse the way backout is doing the merge Currently, backout is creating a backout revision as a child node of the backed out node and will leave you at this new head. This has several drawbacks: * this changes the current head * when there is a long history between the backed out node and the current head, this will generate a huge number of diffs that are scary at first sight, and not very natural to review before commit. The change consists to switch back to the original node as soon as the backout node (which becomes the new tip) has been created. Then the --merge option can just merge this new tip in the current node. * the current head/node is not changed from the user's point of view * even without using the --merge option, the backout revision is still easy to locate, as this is the tip * the merge is much more intuitive as diffs of the merge is right you are looking to backout
author Gilles Moris <gilles.moris@free.fr>
date Thu, 21 Feb 2008 08:52:52 +0100
parents 3ee3bc5d06c5
children 554715e584e6
files mercurial/commands.py tests/test-backout tests/test-backout.out tests/test-parse-date.out
diffstat 4 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Feb 21 16:22:31 2008 -0300
+++ b/mercurial/commands.py	Thu Feb 21 08:52:52 2008 +0100
@@ -177,10 +177,8 @@
     changeset is a child of the backed out changeset.
 
     If you back out a changeset other than the tip, a new head is
-    created.  This head is the parent of the working directory.  If
-    you back out an old changeset, your working directory will appear
-    old after the backout.  You should merge the backout changeset
-    with another head.
+    created.  This head will be the new tip and you should merge this
+    backout changeset with another head (current one by default).
 
     The --merge option remembers the parent of the working directory
     before starting the backout, then merges the new head with that
@@ -243,9 +241,10 @@
     ui.status(_('changeset %s backs out changeset %s\n') %
               (nice(repo.changelog.tip()), nice(node)))
     if op1 != node:
+        hg.clean(repo, op1, show_stats=False)
         if opts['merge']:
-            ui.status(_('merging with changeset %s\n') % nice(op1))
-            hg.merge(repo, hex(op1))
+            ui.status(_('merging with changeset %s\n') % nice(repo.changelog.tip()))
+            hg.merge(repo, hex(repo.changelog.tip()))
         else:
             ui.status(_('the backout changeset is a new head - '
                         'do not forget to merge\n'))
--- a/tests/test-backout	Thu Feb 21 16:22:31 2008 -0300
+++ b/tests/test-backout	Thu Feb 21 08:52:52 2008 +0100
@@ -59,9 +59,10 @@
 cd merge
 
 echo line 1 > a
+echo line 2 >> a
 hg commit -d '0 0' -A -m a
-
-echo line 2 >> a
+# remove line 1
+echo line 2 > a
 hg commit -d '1 0' -m b
 
 echo line 3 >> a
@@ -69,6 +70,7 @@
 
 hg backout --merge -d '3 0' 1
 hg commit -d '4 0' -m d
+# check line 1 is back
 cat a
 
 echo '# backout should not back out subsequent changesets'
@@ -82,6 +84,8 @@
 hg commit -d '2 0' -A -m c
 hg backout -d '3 0' 1
 hg locate b
+hg update -C tip
+hg locate b
 
 cd ..
 hg init m
--- a/tests/test-backout.out	Thu Feb 21 16:22:31 2008 -0300
+++ b/tests/test-backout.out	Thu Feb 21 08:52:52 2008 +0100
@@ -25,12 +25,14 @@
 # backout with merge
 adding a
 reverting a
-changeset 3:3eb045e364a4 backs out changeset 1:314f55b1bf23
-merging with changeset 2:b66ea5b77abb
+changeset 3:26b8ccb9ad91 backs out changeset 1:5a50a024c182
+merging with changeset 3:26b8ccb9ad91
 merging a
 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 line 1
+line 2
+line 3
 # backout should not back out subsequent changesets
 adding a
 adding b
@@ -38,6 +40,8 @@
 changeset 3:3202beb76721 backs out changeset 1:22bca4c721e5
 the backout changeset is a new head - do not forget to merge
 (use "backout --merge" if you want to auto-merge)
+b
+1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 adding a
 adding b
 adding c
--- a/tests/test-parse-date.out	Thu Feb 21 16:22:31 2008 -0300
+++ b/tests/test-parse-date.out	Thu Feb 21 08:52:52 2008 +0100
@@ -1,6 +1,6 @@
 reverting a
 changeset 3:107ce1ee2b43 backs out changeset 1:25a1420a55f8
-merging with changeset 2:e6c3abc120e7
+merging with changeset 3:107ce1ee2b43
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 abort: invalid date: 'should fail'