Patchwork [2,of,5,STABLE] rebase: backed out changeset cf8ad0e6c0e4 (issue5610)

login
register
mail settings
Submitter Pierre-Yves David
Date June 27, 2017, 4:29 p.m.
Message ID <786d7282345f5ffa5348.1498580973@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21782/
State Accepted
Headers show

Comments

Pierre-Yves David - June 27, 2017, 4:29 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1498578024 -7200
#      Tue Jun 27 17:40:24 2017 +0200
# Branch stable
# Node ID 786d7282345f5ffa5348d3c2196f4d6a1bd8b3ce
# Parent  a702fdff7f7374d54bbf2411a500e31826c53119
# EXP-Topic hooks-regression
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 786d7282345f
rebase: backed out changeset cf8ad0e6c0e4 (issue5610)

Having a single transaction for rebase means the whole transaction get rollback
on error. To work around this a small hack as been added to detect merge
conflict and commit the work done so far before exiting. This hack works because
there are nothing transaction related going on during the merge phase.

However, if a hook blocks the rebase to create a changeset, it is too late to commit the
work done in the transaction before the problematic changeset was created. This
lead to the whole rebase so far being rolled back. Loosing merge resolution and
other work in the process. (note: rebase state will be fully lost too).

Since issue5610 is a pretty serious regression and the next stable release is a
couple day away, we are taking the backout route until we can figure out
something better to do.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -343,7 +343,7 @@  class rebaseruntime(object):
         if dest.closesbranch() and not self.keepbranchesf:
             self.ui.status(_('reopening closed branch head %s\n') % dest)
 
-    def _performrebase(self, tr):
+    def _performrebase(self):
         repo, ui, opts = self.repo, self.ui, self.opts
         if self.keepbranchesf:
             # insert _savebranch at the start of extrafns so if
@@ -393,7 +393,7 @@  class rebaseruntime(object):
                                              self.state,
                                              self.targetancestors,
                                              self.obsoletenotrebased)
-                self.storestatus(tr=tr)
+                self.storestatus()
                 storecollapsemsg(repo, self.collapsemsg)
                 if len(repo[None].parents()) == 2:
                     repo.ui.debug('resuming interrupted rebase\n')
@@ -721,12 +721,7 @@  def rebase(ui, repo, **opts):
             if retcode is not None:
                 return retcode
 
-        with repo.transaction('rebase') as tr:
-            try:
-                rbsrt._performrebase(tr)
-            except error.InterventionRequired:
-                tr.close()
-                raise
+        rbsrt._performrebase()
         rbsrt._finishrebase()
     finally:
         release(lock, wlock)
diff --git a/tests/test-rebase-abort.t b/tests/test-rebase-abort.t
--- a/tests/test-rebase-abort.t
+++ b/tests/test-rebase-abort.t
@@ -374,11 +374,10 @@  test aborting an interrupted series (iss
   $ hg --config extensions.n=$TESTDIR/failfilemerge.py rebase -s 3 -d tip
   rebasing 3:3a71550954f1 "b"
   rebasing 4:e80b69427d80 "c"
-  transaction abort!
-  rollback completed
   abort: ^C
   [255]
   $ hg rebase --abort
+  saved backup bundle to $TESTTMP/interrupted/.hg/strip-backup/3d8812cf300d-93041a90-backup.hg (glob)
   rebase aborted
   $ hg log -G --template "{rev} {desc} {bookmarks}"
   o  6 no-a
@@ -399,7 +398,7 @@  test aborting an interrupted series (iss
   parent: 0:df4f53cec30a 
    base
   branch: default
-  commit: 1 unknown (clean)
+  commit: (clean)
   update: 6 new changesets (update)
   phases: 7 draft
 
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -225,6 +225,7 @@  Check that the right ancestors is used w
   ignoring null merge rebase of 8
   rebasing 9:e31216eec445 "more changes to f1"
    future parents are 2 and -1
+  rebase status stored
    update to 2:4bc80088dc6b
   resolving manifests
    branchmerge: False, force: True, partial: False
@@ -250,6 +251,7 @@  Check that the right ancestors is used w
   rebased as 19c888675e13
   rebasing 10:2f2496ddf49d "merge" (tip)
    future parents are 11 and 7
+  rebase status stored
    already in target
    merge against 10:2f2496ddf49d
      detach base 9:e31216eec445
@@ -267,7 +269,6 @@  Check that the right ancestors is used w
   committing changelog
   rebased as 2a7f09cac94c
   rebase merging completed
-  rebase status stored
   update back to initial working directory parent
   resolving manifests
    branchmerge: False, force: False, partial: False