[PATCH 2 of 2 V3] rebase: fix crash when rebase aborts while rebasing obsolete revisions

Laurent Charignon lcharignon at fb.com
Tue Mar 29 14:53:15 EDT 2016


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1459277441 25200
#      Tue Mar 29 11:50:41 2016 -0700
# Node ID 4637682a60b5dc020d8548a7608bf9468b578d68
# Parent  6763719b7f4410240a38f84aace80c3e81e9ff4b
rebase: fix crash when rebase aborts while rebasing obsolete revisions

Before this patch, rebase --continue would crash when trying to resume a rebase
of obsolete revisions whose successors were in the destination.
This patch adds logic to recompute the mapping when rebase is resumed. This
patch also adds a test that showcased the crash before the code change.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -282,6 +282,19 @@ def rebase(ui, repo, **opts):
             if abortf:
                 return abort(repo, originalwd, target, state,
                              activebookmark=activebookmark)
+
+            obsoletenotrebased = {}
+            if ui.configbool('experimental', 'rebaseskipobsolete',
+                             default=True):
+                rebaseobsrevs = set([r for r, status in state.items()
+                                     if status == revprecursor])
+                rebasesetrevs = set(state.keys())
+                obsoletenotrebased = _computeobsoletenotrebased(repo,
+                                                                rebaseobsrevs,
+                                                                target)
+                rebaseobsskipped = set(obsoletenotrebased)
+                _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs,
+                                rebaseobsskipped)
         else:
             dest, rebaseset = _definesets(ui, repo, destf, srcf, basef, revf)
             if dest is None:
diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -805,3 +805,59 @@ With experimental.allowdivergence=True, 
   phases: 8 draft
   divergent: 2 changesets
 
+rebase --continue + skipped rev because their successors are in destination
+we make a change in trunk and work on conflicting changes to make rebase abort.
+
+  $ hg log -G -r 17::
+  @  17:61bd55f69bc4 bar foo
+  |
+
+Create the two changes in trunk
+  $ printf "a" > willconflict
+  $ hg add willconflict
+  $ hg commit -m "willconflict first version"
+
+  $ printf "dummy" > C
+  $ hg commit -m "dummy change successor"
+
+Create the changes that we will rebase
+  $ hg update -C 17 -q
+  $ printf "b" > willconflict
+  $ hg add willconflict
+  $ hg commit -m "willconflict second version"
+  created new head
+  $ printf "dummy" > K
+  $ hg add K
+  $ hg commit -m "dummy change"
+  $ printf "dummy" > L
+  $ hg add L
+  $ hg commit -m "dummy change"
+  $ hg debugobsolete `hg log -r ".^" -T '{node}'` `hg log -r 19 -T '{node}'` --config experimental.evolution=all
+
+  $ hg log -G -r 17::
+  @  22:7bdc8a87673d dummy change
+  |
+  x  21:8b31da3c4919 dummy change
+  |
+  o  20:b82fb57ea638 willconflict second version
+  |
+  | o  19:601db7a18f51 dummy change successor
+  | |
+  | o  18:357ddf1602d5 willconflict first version
+  |/
+  o  17:61bd55f69bc4 bar foo
+  |
+  $ hg rebase -r ".^^ + .^ + ." -d 19
+  rebasing 20:b82fb57ea638 "willconflict second version"
+  merging willconflict
+  warning: conflicts while merging willconflict! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+
+  $ hg resolve --mark willconflict
+  (no more unresolved files)
+  continue: hg rebase --continue
+  $ hg rebase --continue
+  rebasing 20:b82fb57ea638 "willconflict second version"
+  note: not rebasing 21:8b31da3c4919 "dummy change", already in destination as 19:601db7a18f51 "dummy change successor"
+  rebasing 22:7bdc8a87673d "dummy change" (tip)


More information about the Mercurial-devel mailing list