rebase: fix crash when rebase aborts while rebasing obsolete revisions
authorLaurent Charignon <lcharignon@fb.com>
Tue, 29 Mar 2016 11:50:41 -0700
changeset 28686 b212e01fead0
parent 28685 6c4d23fe611c
child 28687 29c249dfb4ef
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.
hgext/rebase.py
tests/test-rebase-obsolete.t
--- a/hgext/rebase.py	Tue Mar 29 11:49:45 2016 -0700
+++ b/hgext/rebase.py	Tue Mar 29 11:50:41 2016 -0700
@@ -282,6 +282,19 @@
             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:
--- a/tests/test-rebase-obsolete.t	Tue Mar 29 11:49:45 2016 -0700
+++ b/tests/test-rebase-obsolete.t	Tue Mar 29 11:50:41 2016 -0700
@@ -805,3 +805,61 @@
   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)