changeset 34092:8a8e7a94ba07

rebase: do not crash rebasing merge with a parent having hidden successor The added test will crash with previous code. Differential Revision: https://phab.mercurial-scm.org/D640
author Jun Wu <quark@fb.com>
date Wed, 06 Sep 2017 12:40:00 -0700
parents bbdca7e460c0
children 15ec3119d500
files hgext/rebase.py tests/test-rebase-obsolete.t
diffstat 2 files changed, 36 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Wed Sep 06 18:33:55 2017 -0700
+++ b/hgext/rebase.py	Wed Sep 06 12:40:00 2017 -0700
@@ -1072,7 +1072,8 @@
     The new parents of a merge is slightly more complicated. See the comment
     block below.
     """
-    cl = repo.changelog
+    # use unfiltered changelog since successorrevs may return filtered nodes
+    cl = repo.unfiltered().changelog
     def isancestor(a, b):
         # take revision numbers instead of nodes
         if a == b:
--- a/tests/test-rebase-obsolete.t	Wed Sep 06 18:33:55 2017 -0700
+++ b/tests/test-rebase-obsolete.t	Wed Sep 06 12:40:00 2017 -0700
@@ -1267,3 +1267,37 @@
   |/
   o  A
   
+Rebasing a merge with one of its parent having a hidden successor
+
+  $ hg init $TESTTMP/merge-p1-hidden-successor
+  $ cd $TESTTMP/merge-p1-hidden-successor
+
+  $ hg debugdrawdag <<'EOS'
+  >  E
+  >  |
+  > B3 B2 # amend: B1 -> B2 -> B3
+  >  |/   # B2 is hidden
+  >  |  D
+  >  |  |\
+  >  | B1 C
+  >  |/
+  >  A
+  > EOS
+
+  $ eval `hg tags -T '{tag}={node}\n'`
+  $ rm .hg/localtags
+
+  $ hg rebase -r $D -d $E
+  rebasing 5:9e62094e4d94 "D"
+
+  $ hg log -G
+  o    7:a699d059adcf D
+  |\
+  | o  6:ecc93090a95c E
+  | |
+  | o  4:0dc878468a23 B3
+  | |
+  o |  1:96cc3511f894 C
+   /
+  o  0:426bada5c675 A
+