Patchwork D8736: tests: make drawdag try to draw nodes in alphabetical order

login
register
mail settings
Submitter phabricator
Date July 14, 2020, 5:12 a.m.
Message ID <differential-rev-PHID-DREV-jwymf6wpxdzpfxcu7fqn-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46721/
State Superseded
Headers show

Comments

phabricator - July 14, 2020, 5:12 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  drawdag currently adds nodes in alphabetical order, but "layer by
  layer" in a BFS traversal. I find that that makes it harder to reason
  about and convince drawdag to add in the order I want it to draw. This
  patch makes it so we don't do the "layer by layer" thing and we
  instead add the first possible node in alphabetical order every time.
  
  I apologize for the impact on the test cases.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8736

AFFECTED FILES
  tests/drawdag.py
  tests/test-drawdag.t
  tests/test-obsolete-divergent.t
  tests/test-phases-exchange.t
  tests/test-rebase-base-flag.t
  tests/test-rebase-brute-force.t
  tests/test-rebase-collapse.t
  tests/test-rebase-dest.t
  tests/test-rebase-legacy.t
  tests/test-rebase-newancestor.t
  tests/test-rebase-obsolete.t
  tests/test-rebase-partial.t
  tests/test-rebase-transaction.t
  tests/test-revset2.t
  tests/test-strip.t
  tests/test-template-graph.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-template-graph.t b/tests/test-template-graph.t
--- a/tests/test-template-graph.t
+++ b/tests/test-template-graph.t
@@ -38,26 +38,26 @@ 
   $ hg log -Gq -T'{rev} {tags}\n'
   o    11 l tip
   |\
-  | o    10 i
+  | o    10 k
   | |\
-  o \ \    9 k
-  |\ \ \
-  +-----o  8 g
-  | | |
-  | o |  7 j
-  | | |
-  | | o  6 h
+  | | o  9 j
   | | |
-  o | |  5 e
-  |/ /
-  | o  4 f
+  o | |    8 i
+  |\ \ \
+  | o | |  7 h
+  | | | |
+  o---+ |  6 g
+   / / /
+  o | |  5 f
+  | | |
+  | o |  4 e
+  | |/
+  | o  3 d
+  |/|
+  o |  2 c
   | |
-  o |  3 d
-  |\|
-  | o  2 c
-  | |
-  | o  1 b
-  |
+  o |  1 b
+   /
   o  0 a
   
 
@@ -124,98 +124,99 @@ 
   $ cd a
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+i"))}\n' -r 'c+i'
-  o  10 i: 2
+  o  8 i: 2
   :
   o  2 c:
   |
   ~
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+h+i"))}\n' -r 'c+h+i'
-  o    10 i: 6
+  o    8 i: 7
   |\
-  o :  6 h: 2
+  o :  7 h: 2
   :/
   o  2 c:
   |
   ~
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+h+l"))}\n' -r 'c+h+l'
-  o    11 l tip: 6
+  o    11 l tip: 7
   :\
-  : o  6 h: 2
+  : o  7 h: 2
   :/
   o  2 c:
   |
   ~
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+f+l"))}\n' -r 'c+f+l'
-  o    11 l tip: 4
+  o    11 l tip: 5
   :\
-  : o  4 f: 2
+  : o  5 f: 2
   :/
   o  2 c:
   |
   ~
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+h+i+k"))}\n' -r 'c+h+i+k'
-  o    10 i: 6
-  |\
-  | : o  9 k: 2
-  | :/
-  o :  6 h: 2
+  o  10 k: 2
+  :
+  : o  8 i: 7
+  :/|
+  : o  7 h: 2
   :/
   o  2 c:
   |
   ~
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+d+h+i+k"))}\n' -r 'c+d+h+i+k'
-  o    10 i: 6 3
-  |\
-  | : o  9 k: 3
-  | :/
-  o :  6 h: 2
+  o  10 k: 3
+  :
+  : o  8 i: 7 3
+  :/|
+  : o  7 h: 2
   : :
-  : o  3 d: 2
-  :/|
-  : ~
+  o :  3 d: 2
+  |\:
+  ~ :
+   /
   o  2 c:
   |
   ~
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+j+k+i"))}\n' -r 'c+j+k+i'
-  o  10 i: 2
-  :
-  : o  9 k: 7
-  :/|
-  : o  7 j: 2
+  o    10 k: 9
+  |\
+  o :  9 j: 2
+  :/
+  : o  8 i: 2
   :/
   o  2 c:
   |
   ~
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("c+e+f+j"))}\n' -r 'c+e+f+j'
-  o  7 j: 2
+  o  9 j: 2
   :
-  : o  5 e: 2
+  : o  5 f: 2
   :/
-  : o  4 f: 2
+  : o  4 e: 2
   :/
   o  2 c:
   |
   ~
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("b+e+f+j"))}\n' -r 'b+e+f+j'
-  o  7 j: 1
+  o  9 j: 1
   :
-  : o  5 e: 1
+  : o  5 f: 1
   :/
-  : o  4 f: 1
+  : o  4 e: 1
   :/
   o  1 b:
   
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("a+c+f+g+j+l"))}\n' -r 'a+c+f+g+j+l'
-  o    11 l tip: 4 8 7
+  o    11 l tip: 5 6 9
   :\
   : \
   : :\
@@ -223,11 +224,11 @@ 
   : : :\
   : : : \
   : : : :\
-  : o---+ :  8 g: 0 2
-  : :/ / /
-  : +---o  7 j: 0 2
-  : : :/
-  o---+  4 f: 2
+  : : +---o  9 j: 0 2
+  : : : :/
+  : o---+  6 g: 0 2
+  : :/ /
+  o---+  5 f: 2
    / /
   : o  2 c:
   : |
@@ -236,21 +237,21 @@ 
   
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("b+i+l"))}\n' -r 'b+i+l'
-  o    11 l tip: 10
+  o    11 l tip: 8
   |\
-  o :  10 i: 1
+  o :  8 i: 1
   :/
   o  1 b:
   
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("b+i+j+l"))}\n' -r 'b+i+j+l'
-  o    11 l tip: 10 7
+  o    11 l tip: 8 9
   |\
   | \
   | :\
-  o : :  10 i: 1
-  :/ /
-  : o  7 j: 1
+  | : o  9 j: 1
+  | :/
+  o :  8 i: 1
   :/
   o  1 b:
   
@@ -258,7 +259,7 @@ 
 null in subset:
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("null+a+c+f"))}\n' -r 'null+a+c+f'
-  o  4 f: 2
+  o  5 f: 2
   |
   o  2 c: -1
   :
@@ -268,7 +269,7 @@ 
   
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("null+a+b+c+f"))}\n' -r 'null+a+b+c+f'
-  o  4 f: 2
+  o  5 f: 2
   |
   o  2 c: 1
   |
@@ -284,12 +285,12 @@ 
   $ hg update -qC i
 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("f+k+wdir()"))}\n' -r 'f+k+wdir()'
-  o  2147483647 : 4
+  o  2147483647 : 5
   :
-  : o    9 k:
+  : o    10 k:
   : |\
   : ~ ~
-  o  4 f:
+  o  5 f:
   |
   ~
 
@@ -298,14 +299,14 @@ 
 Revisions not in subset:
 
   $ hg log -T '{rev} {tags}: {subsetparents(rev, revset("a+c+f+g+j+l"))}\n'
-  11 l tip: 4 8 7
-  10 i: 
-  9 k: 
-  8 g: 0 2
-  7 j: 0 2
-  6 h: 
-  5 e: 
-  4 f: 2
+  11 l tip: 5 6 9
+  10 k: 
+  9 j: 0 2
+  8 i: 
+  7 h: 
+  6 g: 0 2
+  5 f: 2
+  4 e: 
   3 d: 
   2 c: 
   1 b: 
@@ -313,13 +314,13 @@ 
 
   $ hg log -T '{rev} {tags}: {subsetparents(rev, revset("b+c"))}\n'
   11 l tip: 
-  10 i: 
-  9 k: 
-  8 g: 
-  7 j: 
-  6 h: 
-  5 e: 
-  4 f: 
+  10 k: 
+  9 j: 
+  8 i: 
+  7 h: 
+  6 g: 
+  5 f: 
+  4 e: 
   3 d: 
   2 c: 1
   1 b: 
@@ -335,14 +336,14 @@ 
 
   $ hg log -T '{rev} {tags}: {subsetparents(rev, revset("null:wdir()"))}\n' -r'reverse(null:wdir())'
   2147483647 : -1
-  11 l tip: 10 9
-  10 i: 6 8
-  9 k: 5 7
-  8 g: 5
-  7 j: 3
-  6 h: 4
-  5 e: 3
-  4 f: 2
+  11 l tip: 8 10
+  10 k: 4 9
+  9 j: 3
+  8 i: 7 6
+  7 h: 5
+  6 g: 4
+  5 f: 2
+  4 e: 3
   3 d: 0 2
   2 c: 1
   1 b: -1
@@ -354,26 +355,26 @@ 
   $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("%d:%d", rev, rev - 1))}\n'
   o    11 l tip: 10
   |\
-  | o    10 i:
+  | o    10 k: 9
   | |\
-  o \ \    9 k:
-  |\ \ \
-  +-----o  8 g:
-  | | |
-  | o |  7 j:
-  | | |
-  | | o  6 h:
+  | | o  9 j:
   | | |
-  o | |  5 e:
-  |/ /
-  | o  4 f:
+  o | |    8 i: 7
+  |\ \ \
+  | o | |  7 h:
+  | | | |
+  o---+ |  6 g:
+   / / /
+  o | |  5 f:
+  | | |
+  | o |  4 e: 3
+  | |/
+  | o  3 d: 2
+  |/|
+  o |  2 c: 1
   | |
-  o |  3 d: 2
-  |\|
-  | o  2 c: 1
-  | |
-  | o  1 b:
-  |
+  o |  1 b:
+   /
   o  0 a: -1
   
 
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -1255,18 +1255,18 @@ 
   > EOF
   $ hg testdelayedstrip --config extensions.t=$TESTTMP/delayedstrip.py
   warning: orphaned descendants detected, not stripping 08ebfeb61bac, 112478962961, 7fb047a69f22
-  saved backup bundle to $TESTTMP/delayedstrip/.hg/strip-backup/f585351a92f8-17475721-I.hg
+  saved backup bundle to $TESTTMP/delayedstrip/.hg/strip-backup/48b9aae0607f-17475721-I.hg
 
   $ hg log -G -T '{rev}:{node|short} {desc}' -r 'sort(all(), topo)'
   @  6:2f2d51af6205 J
   |
-  o  3:08ebfeb61bac I
+  o  5:08ebfeb61bac I
   |
-  | o  5:64a8289d2492 F
+  | o  4:64a8289d2492 F
   | |
-  | o  2:7fb047a69f22 E
+  | o  3:7fb047a69f22 E
   |/
-  | o  4:26805aba1e60 C
+  | o  2:26805aba1e60 C
   | |
   | o  1:112478962961 B
   |/
@@ -1310,35 +1310,35 @@ 
   > EOF
   $ hg testnodescleanup --config extensions.t=$TESTTMP/scmutilcleanup.py
   warning: orphaned descendants detected, not stripping 112478962961, 1fc8102cda62, 26805aba1e60
-  saved backup bundle to $TESTTMP/scmutilcleanup/.hg/strip-backup/f585351a92f8-73fb7c03-replace.hg
+  saved backup bundle to $TESTTMP/scmutilcleanup/.hg/strip-backup/48b9aae0607f-73fb7c03-replace.hg
 
   $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
-  o  8:1473d4b996d1 G2 b-F@divergent3 b-G
+  o  8:d11b3456a873 F2 b-F
   |
-  | o  7:d11b3456a873 F2 b-F
-  | |
-  | o  5:5cb05ba470a7 H
-  |/|
-  | o  3:7fb047a69f22 E b-F@divergent1
+  o    5:5cb05ba470a7 H
+  |\
+  | | o  7:1473d4b996d1 G2 b-F@divergent3 b-G
+  | |/
+  | o  4:1fc8102cda62 G
+  |
+  o  3:7fb047a69f22 E b-F@divergent1
+  |
+  | o  6:7c78f703e465 D2 b-D
   | |
-  | | o  6:7c78f703e465 D2 b-D
-  | | |
-  | | o  4:26805aba1e60 C
-  | | |
-  | | o  2:112478962961 B
-  | |/
-  o |  1:1fc8102cda62 G
-   /
+  | o  2:26805aba1e60 C
+  | |
+  | o  1:112478962961 B
+  |/
   o  0:426bada5c675 A b-B b-C b-I
   
   $ hg bookmark
      b-B                       0:426bada5c675
      b-C                       0:426bada5c675
      b-D                       6:7c78f703e465
-     b-F                       7:d11b3456a873
+     b-F                       8:d11b3456a873
      b-F@divergent1            3:7fb047a69f22
-     b-F@divergent3            8:1473d4b996d1
-     b-G                       8:1473d4b996d1
+     b-F@divergent3            7:1473d4b996d1
+     b-G                       7:1473d4b996d1
      b-I                       0:426bada5c675
      b-Z                       -1:000000000000
 
@@ -1357,32 +1357,32 @@ 
 
   $ rm .hg/localtags
   $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
-  *  12:1473d4b996d1 G2 b-F@divergent3 b-G
+  *  12:d11b3456a873 F2 b-F
   |
-  | *  11:d11b3456a873 F2 b-F
-  | |
-  | *  8:5cb05ba470a7 H
-  |/|
-  | o  4:7fb047a69f22 E b-F@divergent1
+  *    7:5cb05ba470a7 H
+  |\
+  | | *  11:1473d4b996d1 G2 b-F@divergent3 b-G
+  | |/
+  | x  6:1fc8102cda62 G
+  |
+  o  4:7fb047a69f22 E b-F@divergent1
+  |
+  | *  10:7c78f703e465 D2 b-D
   | |
-  | | *  10:7c78f703e465 D2 b-D
-  | | |
-  | | x  6:26805aba1e60 C
-  | | |
-  | | x  3:112478962961 B
-  | |/
-  x |  1:1fc8102cda62 G
-   /
+  | x  2:26805aba1e60 C
+  | |
+  | x  1:112478962961 B
+  |/
   o  0:426bada5c675 A b-B b-C b-I
   
   $ hg debugobsolete
-  1fc8102cda6204549f031015641606ccf5513ec3 1473d4b996d1d1b121de6b39fab6a04fbf9d873e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'replace', 'user': 'test'}
+  f585351a92f85104bff7c284233c338b10eb1df7 7c78f703e465d73102cc8780667ce269c5208a40 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'replace', 'user': 'test'}
   64a8289d249234b9886244d379f15e6b650b28e3 d11b3456a873daec7c7bc53e5622e8df6d741bd2 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'replace', 'user': 'test'}
-  f585351a92f85104bff7c284233c338b10eb1df7 7c78f703e465d73102cc8780667ce269c5208a40 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'replace', 'user': 'test'}
+  1fc8102cda6204549f031015641606ccf5513ec3 1473d4b996d1d1b121de6b39fab6a04fbf9d873e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'replace', 'user': 'test'}
+  112478962961147124edd43549aedd1a335e44bf 0 {426bada5c67598ca65036d57d9e4b64b0c1ce7a0} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
+  26805aba1e600a82e93661149f2313866a221a7b 0 {112478962961147124edd43549aedd1a335e44bf} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
+  08ebfeb61bac6e3f12079de774d285a0d6689eba 0 {426bada5c67598ca65036d57d9e4b64b0c1ce7a0} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
   48b9aae0607f43ff110d84e6883c151942add5ab 0 {0000000000000000000000000000000000000000} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
-  112478962961147124edd43549aedd1a335e44bf 0 {426bada5c67598ca65036d57d9e4b64b0c1ce7a0} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
-  08ebfeb61bac6e3f12079de774d285a0d6689eba 0 {426bada5c67598ca65036d57d9e4b64b0c1ce7a0} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
-  26805aba1e600a82e93661149f2313866a221a7b 0 {112478962961147124edd43549aedd1a335e44bf} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
   $ cd ..
 
 Test that obsmarkers are restored even when not using generaldelta
diff --git a/tests/test-revset2.t b/tests/test-revset2.t
--- a/tests/test-revset2.t
+++ b/tests/test-revset2.t
@@ -1683,8 +1683,8 @@ 
 
   $ hg log -r 'successors(B+A)-contentdivergent()' -T '{desc}\n'
   A
+  B
   Z
-  B
 
   $ hg log -r 'successors(B+A)-contentdivergent()-obsolete()' -T '{desc}\n'
   Z
@@ -1713,19 +1713,19 @@ 
   $ hg log -G -T '{rev} {desc} {phase}' -r 'sort(all(), topo, topo.firstbranch=P5)'
   o  8 P5 public
   |
-  | o  10 S1 secret
+  | o  9 S1 secret
   | |
   | o  7 D3 draft
   |/
-  | o  9 S2 secret
+  | o  10 S2 secret
   |/
   o  6 P4 public
   |
   o  5 P3 public
   |
-  o  3 P2 public
+  o  4 P2 public
   |
-  | o  4 D2 draft
+  | o  3 D2 draft
   | |
   | o  2 D1 draft
   |/
diff --git a/tests/test-rebase-transaction.t b/tests/test-rebase-transaction.t
--- a/tests/test-rebase-transaction.t
+++ b/tests/test-rebase-transaction.t
@@ -104,21 +104,21 @@ 
   > EOF
   $ hg rebase --collapse -b D -d Z
   rebasing 1:112478962961 "B" (B)
-  rebasing 3:c26739dbe603 "C" (C)
+  rebasing 2:c26739dbe603 "C" (C)
   merging conflict
   warning: conflicts while merging conflict! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
   $ hg tglog
-  o  5: D
+  @  5: Z
   |
-  | @  4: Z
+  o  4: Y
+  |
+  | o  3: D
   | |
-  % |  3: C
+  | %  2: C
   | |
-  | o  2: Y
-  | |
-  o |  1: B
+  | o  1: B
   |/
   o  0: A
   
@@ -133,8 +133,8 @@ 
   continue: hg rebase --continue
   $ hg continue
   already rebased 1:112478962961 "B" (B) as 79bc8f4973ce
-  rebasing 3:c26739dbe603 "C" (C)
-  rebasing 5:d24bb333861c "D" (D tip)
+  rebasing 2:c26739dbe603 "C" (C)
+  rebasing 3:d24bb333861c "D" (D)
   saved backup bundle to $TESTTMP/collapse-conflict/.hg/strip-backup/112478962961-b5b34645-rebase.hg
   $ hg tglog
   o  3: Collapsed revision
@@ -166,29 +166,29 @@ 
   > EOF
   $ HGEDITOR=false hg --config ui.interactive=1 rebase --collapse -b D -d Z
   rebasing 1:112478962961 "B" (B)
-  rebasing 3:26805aba1e60 "C" (C)
-  rebasing 5:f585351a92f8 "D" (D tip)
+  rebasing 2:26805aba1e60 "C" (C)
+  rebasing 3:f585351a92f8 "D" (D)
   transaction abort!
   rollback completed
   abort: edit failed: false exited with status 1
   [255]
   $ hg tglog
-  o  5: D
+  o  5: Z
   |
-  | o  4: Z
+  o  4: Y
+  |
+  | o  3: D
   | |
-  o |  3: C
+  | o  2: C
   | |
-  | o  2: Y
-  | |
-  o |  1: B
+  | o  1: B
   |/
   o  0: A
   
   $ hg continue
   rebasing 1:112478962961 "B" (B)
-  rebasing 3:26805aba1e60 "C" (C)
-  rebasing 5:f585351a92f8 "D" (D tip)
+  rebasing 2:26805aba1e60 "C" (C)
+  rebasing 3:f585351a92f8 "D" (D)
   saved backup bundle to $TESTTMP/collapse-cancel-editor/.hg/strip-backup/112478962961-cb2a9b47-rebase.hg
   $ hg tglog
   o  3: Collapsed revision
diff --git a/tests/test-rebase-partial.t b/tests/test-rebase-partial.t
--- a/tests/test-rebase-partial.t
+++ b/tests/test-rebase-partial.t
@@ -35,13 +35,13 @@ 
   > |/
   > A
   > EOF
-  rebasing 2:b18e25de2cf5 "D" (D)
-  already rebased 3:26805aba1e60 "C" (C tip)
+  already rebased 2:26805aba1e60 "C" (C)
+  rebasing 3:b18e25de2cf5 "D" (D tip)
   o  4: fe3b4c6498fa D
   |
-  | o  3: 26805aba1e60 C
-  |/
-  | x  2: b18e25de2cf5 D
+  | x  3: b18e25de2cf5 D
+  | |
+  +---o  2: 26805aba1e60 C
   | |
   o |  1: 112478962961 B
   |/
@@ -56,14 +56,14 @@ 
   > |/
   > A
   > EOF
-  rebasing 2:b18e25de2cf5 "D" (D)
-  rebasing 3:26805aba1e60 "C" (C tip)
-  o  4: a2493f4ace65 Collapsed revision
+  rebasing 2:26805aba1e60 "C" (C)
+  rebasing 3:b18e25de2cf5 "D" (D tip)
+  o  4: 43ff9c6a4b68 Collapsed revision
+  |  * C
   |  * D
-  |  * C
-  | x  3: 26805aba1e60 C
-  |/
-  | x  2: b18e25de2cf5 D
+  | x  3: b18e25de2cf5 D
+  | |
+  +---x  2: 26805aba1e60 C
   | |
   o |  1: 112478962961 B
   |/
@@ -81,7 +81,8 @@ 
   > A
   > EOF
   $ hg rebase -r C+D -d B
-  rebasing 2:ef8c0fe0897b "D" (D)
+  already rebased 2:79f6d6ab7b14 "C" (C)
+  rebasing 3:ef8c0fe0897b "D" (D tip)
   merging file
   warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see hg resolve, then hg rebase --continue)
@@ -89,11 +90,11 @@ 
   $ hg rebase --abort
   rebase aborted
   $ hg tglog
-  o  3: 79f6d6ab7b14 C
+  o  3: ef8c0fe0897b D
   |
-  | o  2: ef8c0fe0897b D
+  | o  2: 79f6d6ab7b14 C
   | |
-  o |  1: 594087dbaf71 B
+  | o  1: 594087dbaf71 B
   |/
   o  0: 426bada5c675 A
   
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
@@ -557,9 +557,9 @@ 
 
   $ hg rebase -d G -r 'B + D + F'
   rebasing 1:112478962961 "B" (B)
-  rebasing 2:b18e25de2cf5 "D" (D)
-  rebasing 6:f15c3adaf214 "F" (F tip)
-  abort: cannot rebase 6:f15c3adaf214 without moving at least one of its parents
+  rebasing 3:b18e25de2cf5 "D" (D)
+  rebasing 5:f15c3adaf214 "F" (F)
+  abort: cannot rebase 5:f15c3adaf214 without moving at least one of its parents
   [255]
 
   $ cd ..
@@ -1074,19 +1074,19 @@ 
   > EOF
   1 new orphan changesets
   $ hg log -G -r 'a'::
-  *  7:1143e9adc121 f
+  o  7:630d7c95eff7 x
   |
-  | o  6:d60ebfa0f1cb e
-  | |
-  | o  5:027ad6c5830d d'
+  | *  6:1143e9adc121 f
   | |
-  x |  4:76be324c128b d (rewritten using replace as 5:027ad6c5830d)
-  |/
-  o  3:a82ac2b38757 c
-  |
-  | o  2:630d7c95eff7 x
+  | | o  5:d60ebfa0f1cb e
+  | | |
+  | | o  4:027ad6c5830d d'
+  | | |
+  | x |  3:76be324c128b d (rewritten using replace as 4:027ad6c5830d)
+  | |/
+  | o  2:a82ac2b38757 c
   | |
-  o |  1:488e1b7e7341 b
+  | o  1:488e1b7e7341 b
   |/
   o  0:b173517d0057 a
   
@@ -1097,10 +1097,10 @@ 
 
   $ hg rebase -b 'e' -d 'x'
   rebasing 1:488e1b7e7341 "b" (b)
-  rebasing 3:a82ac2b38757 "c" (c)
-  rebasing 5:027ad6c5830d "d'" (d')
-  rebasing 6:d60ebfa0f1cb "e" (e)
-  note: not rebasing 4:76be324c128b "d" (d) and its descendants as this would cause divergence
+  rebasing 2:a82ac2b38757 "c" (c)
+  rebasing 4:027ad6c5830d "d'" (d')
+  rebasing 5:d60ebfa0f1cb "e" (e)
+  note: not rebasing 3:76be324c128b "d" (d) and its descendants as this would cause divergence
   $ hg log -G -r 'a'::
   o  11:eb6d63fc4ed5 e
   |
@@ -1110,17 +1110,17 @@ 
   |
   o  8:67e8f4a16c49 b
   |
-  | *  7:1143e9adc121 f
+  o  7:630d7c95eff7 x
+  |
+  | *  6:1143e9adc121 f
   | |
-  | | x  6:d60ebfa0f1cb e (rewritten using rebase as 11:eb6d63fc4ed5)
-  | | |
-  | | x  5:027ad6c5830d d' (rewritten using rebase as 10:44d8c724a70c)
+  | | x  5:d60ebfa0f1cb e (rewritten using rebase as 11:eb6d63fc4ed5)
   | | |
-  | x |  4:76be324c128b d (rewritten using replace as 5:027ad6c5830d)
+  | | x  4:027ad6c5830d d' (rewritten using rebase as 10:44d8c724a70c)
+  | | |
+  | x |  3:76be324c128b d (rewritten using replace as 4:027ad6c5830d)
   | |/
-  | x  3:a82ac2b38757 c (rewritten using rebase as 9:d008e6b4d3fd)
-  | |
-  o |  2:630d7c95eff7 x
+  | x  2:a82ac2b38757 c (rewritten using rebase as 9:d008e6b4d3fd)
   | |
   | x  1:488e1b7e7341 b (rewritten using rebase as 8:67e8f4a16c49)
   |/
@@ -1128,19 +1128,19 @@ 
   
   $ hg strip -r 8:
   $ hg log -G -r 'a'::
-  *  7:1143e9adc121 f
+  o  7:630d7c95eff7 x
   |
-  | o  6:d60ebfa0f1cb e
-  | |
-  | o  5:027ad6c5830d d'
+  | *  6:1143e9adc121 f
   | |
-  x |  4:76be324c128b d (rewritten using replace as 5:027ad6c5830d)
-  |/
-  o  3:a82ac2b38757 c
-  |
-  | o  2:630d7c95eff7 x
+  | | o  5:d60ebfa0f1cb e
+  | | |
+  | | o  4:027ad6c5830d d'
+  | | |
+  | x |  3:76be324c128b d (rewritten using replace as 4:027ad6c5830d)
+  | |/
+  | o  2:a82ac2b38757 c
   | |
-  o |  1:488e1b7e7341 b
+  | o  1:488e1b7e7341 b
   |/
   o  0:b173517d0057 a
   
@@ -1154,9 +1154,9 @@ 
   (to force the rebase please set experimental.evolution.allowdivergence=True)
   [255]
   $ hg rebase --config experimental.evolution.allowdivergence=true -r 'c'::'f' -d 'x'
-  rebasing 3:a82ac2b38757 "c" (c)
-  rebasing 4:76be324c128b "d" (d)
-  rebasing 7:1143e9adc121 "f" (f tip)
+  rebasing 2:a82ac2b38757 "c" (c)
+  rebasing 3:76be324c128b "d" (d)
+  rebasing 6:1143e9adc121 "f" (f)
   1 new orphan changesets
   2 new content-divergent changesets
   $ hg log -G -r 'a':: -T instabilities
@@ -1166,17 +1166,17 @@ 
   |
   o  8:6a0376de376e c
   |
-  | x  7:1143e9adc121 f
+  o  7:630d7c95eff7 x
+  |
+  | x  6:1143e9adc121 f
   | |
-  | | *  6:d60ebfa0f1cb e (orphan)
-  | | |
-  | | *  5:027ad6c5830d d' (orphan content-divergent)
+  | | *  5:d60ebfa0f1cb e (orphan)
   | | |
-  | x |  4:76be324c128b d
+  | | *  4:027ad6c5830d d' (orphan content-divergent)
+  | | |
+  | x |  3:76be324c128b d
   | |/
-  | x  3:a82ac2b38757 c
-  | |
-  o |  2:630d7c95eff7 x
+  | x  2:a82ac2b38757 c
   | |
   | o  1:488e1b7e7341 b
   |/
@@ -1187,9 +1187,9 @@ 
 (Not skipping obsoletes means that divergence is allowed.)
 
   $ hg rebase --config experimental.rebaseskipobsolete=false -r 'c'::'f' -d 'x'
-  rebasing 3:a82ac2b38757 "c" (c)
-  rebasing 4:76be324c128b "d" (d)
-  rebasing 7:1143e9adc121 "f" (f tip)
+  rebasing 2:a82ac2b38757 "c" (c)
+  rebasing 3:76be324c128b "d" (d)
+  rebasing 6:1143e9adc121 "f" (f)
   1 new orphan changesets
   2 new content-divergent changesets
 
@@ -1212,31 +1212,31 @@ 
   > EOF
   1 new orphan changesets
   $ hg log -G -r 'a':
-  *  8:2876ce66c6eb g
+  o  8:630d7c95eff7 x
   |
-  | o  7:3ffec603ab53 f
-  | |
-  x |  6:e36fae928aec e (rewritten using replace as 5:63324dc512ea)
-  | |
-  | o  5:63324dc512ea e'
+  | *  7:2876ce66c6eb g
   | |
-  o |  4:76be324c128b d
-  |/
-  o  3:a82ac2b38757 c
-  |
-  | o  2:630d7c95eff7 x
+  | | o  6:3ffec603ab53 f
+  | | |
+  | | o  5:63324dc512ea e'
+  | | |
+  | x |  4:e36fae928aec e (rewritten using replace as 5:63324dc512ea)
+  | | |
+  | o |  3:76be324c128b d
+  | |/
+  | o  2:a82ac2b38757 c
   | |
-  o |  1:488e1b7e7341 b
+  | o  1:488e1b7e7341 b
   |/
   o  0:b173517d0057 a
   
   $ hg rebase -b 'f' -d 'x'
   rebasing 1:488e1b7e7341 "b" (b)
-  rebasing 3:a82ac2b38757 "c" (c)
+  rebasing 2:a82ac2b38757 "c" (c)
   rebasing 5:63324dc512ea "e'" (e')
-  rebasing 7:3ffec603ab53 "f" (f)
-  rebasing 4:76be324c128b "d" (d)
-  note: not rebasing 6:e36fae928aec "e" (e) and its descendants as this would cause divergence
+  rebasing 6:3ffec603ab53 "f" (f)
+  rebasing 3:76be324c128b "d" (d)
+  note: not rebasing 4:e36fae928aec "e" (e) and its descendants as this would cause divergence
   $ hg log -G -r 'a':
   o  13:a1707a5b7c2c d
   |
@@ -1248,19 +1248,19 @@ 
   |
   o  9:67e8f4a16c49 b
   |
-  | *  8:2876ce66c6eb g
+  o  8:630d7c95eff7 x
+  |
+  | *  7:2876ce66c6eb g
   | |
-  | | x  7:3ffec603ab53 f (rewritten using rebase as 12:ef6251596616)
-  | | |
-  | x |  6:e36fae928aec e (rewritten using replace as 5:63324dc512ea)
+  | | x  6:3ffec603ab53 f (rewritten using rebase as 12:ef6251596616)
   | | |
   | | x  5:63324dc512ea e' (rewritten using rebase as 11:b6f172e64af9)
   | | |
-  | x |  4:76be324c128b d (rewritten using rebase as 13:a1707a5b7c2c)
+  | x |  4:e36fae928aec e (rewritten using replace as 5:63324dc512ea)
+  | | |
+  | x |  3:76be324c128b d (rewritten using rebase as 13:a1707a5b7c2c)
   | |/
-  | x  3:a82ac2b38757 c (rewritten using rebase as 10:d008e6b4d3fd)
-  | |
-  o |  2:630d7c95eff7 x
+  | x  2:a82ac2b38757 c (rewritten using rebase as 10:d008e6b4d3fd)
   | |
   | x  1:488e1b7e7341 b (rewritten using rebase as 9:67e8f4a16c49)
   |/
@@ -1389,21 +1389,21 @@ 
   1 new orphan changesets
 
   $ hg rebase -d C -s D
-  note: not rebasing 2:b18e25de2cf5 "D" (D), already in destination as 1:112478962961 "B" (B)
+  note: not rebasing 3:b18e25de2cf5 "D" (D), already in destination as 1:112478962961 "B" (B)
   rebasing 5:66f1a38021c9 "F" (F tip)
 
   $ hg log -G
   o    6:0913febf6439 F
   |\
-  +---x  5:66f1a38021c9 F (rewritten using rebase as 6:0913febf6439)
-  | | |
-  | o |  4:26805aba1e60 C
+  | | x  5:66f1a38021c9 F (rewritten using rebase as 6:0913febf6439)
+  | |/|
+  | o |  4:7fb047a69f22 E
   | | |
-  o | |  3:7fb047a69f22 E
-  | | |
-  +---x  2:b18e25de2cf5 D (rewritten using replace as 1:112478962961)
+  | | x  3:b18e25de2cf5 D (rewritten using replace as 1:112478962961)
+  | |/
+  o |  2:26805aba1e60 C
   | |
-  | o  1:112478962961 B
+  o |  1:112478962961 B
   |/
   o  0:426bada5c675 A
   
@@ -1424,20 +1424,20 @@ 
   1 new orphan changesets
 
   $ hg rebase -d C -s E
-  note: not rebasing 3:7fb047a69f22 "E" (E), already in destination as 1:112478962961 "B" (B)
+  note: not rebasing 4:7fb047a69f22 "E" (E), already in destination as 1:112478962961 "B" (B)
   rebasing 5:66f1a38021c9 "F" (F tip)
   $ hg log -G
   o    6:c6ab0cc6d220 F
   |\
-  +---x  5:66f1a38021c9 F (rewritten using rebase as 6:c6ab0cc6d220)
-  | | |
-  | o |  4:26805aba1e60 C
+  | | x  5:66f1a38021c9 F (rewritten using rebase as 6:c6ab0cc6d220)
+  | |/|
+  | | x  4:7fb047a69f22 E (rewritten using replace as 1:112478962961)
   | | |
-  | | x  3:7fb047a69f22 E (rewritten using replace as 1:112478962961)
-  | | |
-  o---+  2:b18e25de2cf5 D
-   / /
-  o /  1:112478962961 B
+  | o |  3:b18e25de2cf5 D
+  | |/
+  o |  2:26805aba1e60 C
+  | |
+  o |  1:112478962961 B
   |/
   o  0:426bada5c675 A
   
@@ -1458,8 +1458,8 @@ 
   1 new orphan changesets
 
   $ hg rebase -d C -b F
-  rebasing 2:b18e25de2cf5 "D" (D)
-  note: not rebasing 3:7fb047a69f22 "E" (E), already in destination as 1:112478962961 "B" (B)
+  rebasing 3:b18e25de2cf5 "D" (D)
+  note: not rebasing 4:7fb047a69f22 "E" (E), already in destination as 1:112478962961 "B" (B)
   rebasing 5:66f1a38021c9 "F" (F tip)
   note: not rebasing 5:66f1a38021c9 "F" (F tip), its destination already has all its changes
   $ hg log -G
@@ -1467,13 +1467,13 @@ 
   |
   | x    5:66f1a38021c9 F (pruned using rebase)
   | |\
-  o | |  4:26805aba1e60 C
-  | | |
-  | | x  3:7fb047a69f22 E (rewritten using replace as 1:112478962961)
+  | | x  4:7fb047a69f22 E (rewritten using replace as 1:112478962961)
   | | |
-  | x |  2:b18e25de2cf5 D (rewritten using rebase as 6:8f47515dda15)
+  | x |  3:b18e25de2cf5 D (rewritten using rebase as 6:8f47515dda15)
   | |/
-  o /  1:112478962961 B
+  o |  2:26805aba1e60 C
+  | |
+  o |  1:112478962961 B
   |/
   o  0:426bada5c675 A
   
@@ -1494,8 +1494,8 @@ 
   1 new orphan changesets
 
   $ hg rebase -d C -b F
-  note: not rebasing 2:b18e25de2cf5 "D" (D), already in destination as 1:112478962961 "B" (B)
-  rebasing 3:7fb047a69f22 "E" (E)
+  note: not rebasing 3:b18e25de2cf5 "D" (D), already in destination as 1:112478962961 "B" (B)
+  rebasing 4:7fb047a69f22 "E" (E)
   rebasing 5:66f1a38021c9 "F" (F tip)
   note: not rebasing 5:66f1a38021c9 "F" (F tip), its destination already has all its changes
 
@@ -1504,13 +1504,13 @@ 
   |
   | x    5:66f1a38021c9 F (pruned using rebase)
   | |\
-  o | |  4:26805aba1e60 C
-  | | |
-  | | x  3:7fb047a69f22 E (rewritten using rebase as 6:533690786a86)
+  | | x  4:7fb047a69f22 E (rewritten using rebase as 6:533690786a86)
   | | |
-  | x |  2:b18e25de2cf5 D (rewritten using replace as 1:112478962961)
+  | x |  3:b18e25de2cf5 D (rewritten using replace as 1:112478962961)
   | |/
-  o /  1:112478962961 B
+  o |  2:26805aba1e60 C
+  | |
+  o |  1:112478962961 B
   |/
   o  0:426bada5c675 A
   
@@ -1532,7 +1532,7 @@ 
 
   $ hg rebase -d D -s B
   rebasing 1:112478962961 "B" (B)
-  note: not rebasing 3:26805aba1e60 "C" (C) and its descendants as this would cause divergence
+  note: not rebasing 2:26805aba1e60 "C" (C) and its descendants as this would cause divergence
 
   $ cd ..
 
@@ -1561,7 +1561,6 @@ 
 
 This strip seems to be the key to avoid an early divergence warning.
   $ hg --config extensions.strip= --hidden strip -qr H
-  1 new orphan changesets
 
   $ hg rebase -b 'desc("D")' -d 'desc("J")'
   abort: this rebase will cause divergences from: 112478962961
@@ -1582,9 +1581,9 @@ 
   1 new orphan changesets
   $ hg rebase -r A+B+E -d F
   note: not rebasing 4:a3d17304151f "A" (A), already in destination as 0:96cc3511f894 "C" (C)
-  note: not rebasing 5:b23a2cc00842 "B" (B), already in destination as 1:058c1e1fb10a "D" (D)
+  note: not rebasing 6:b23a2cc00842 "B" (B), already in destination as 1:058c1e1fb10a "D" (D)
   rebasing 7:dac5d11c5a7d "E" (E tip)
-  abort: rebasing 7:dac5d11c5a7d will include unwanted changes from 3:59c792af609c, 5:b23a2cc00842 or 2:ba2b7fa7166d, 4:a3d17304151f
+  abort: rebasing 7:dac5d11c5a7d will include unwanted changes from 5:59c792af609c, 6:b23a2cc00842 or 3:ba2b7fa7166d, 4:a3d17304151f
   [255]
   $ cd ..
 
@@ -1707,19 +1706,19 @@ 
   $ hg bookmark book -i
   $ hg rebase -r B+D1 -d E
   rebasing 1:112478962961 "B" (B)
-  note: not rebasing 5:15ecf15e0114 "D1" (book D1 tip), already in destination as 2:0807738e0be9 "D2" (D2)
+  note: not rebasing 3:15ecf15e0114 "D1" (book D1), already in destination as 4:0807738e0be9 "D2" (D2)
   1 new orphan changesets
   $ hg log -G -T '{desc} {bookmarks}'
   @  B book
   |
+  o  E
+  |
+  o  D2
+  |
   | x  D1
   | |
-  o |  E
-  | |
   | *  C
   | |
-  o |  D2
-  | |
   | x  B
   |/
   o  A
@@ -1753,10 +1752,10 @@ 
   |\
   | o  6:ecc93090a95c E
   | |
-  | o  4:0dc878468a23 B3
-  | |
-  o |  1:96cc3511f894 C
+  o |  4:96cc3511f894 C
    /
+  o  3:0dc878468a23 B3
+  |
   o  0:426bada5c675 A
   
 For some reasons (--hidden, rebaseskipobsolete=0, directaccess, etc.),
@@ -1793,12 +1792,12 @@ 
   $ cp -R . $TESTTMP/hidden-state2
 
   $ hg log -G
-  @  2:b18e25de2cf5 D
+  @  3:b18e25de2cf5 D
   |
   o  0:426bada5c675 A
   
   $ hg summary
-  parent: 2:b18e25de2cf5 tip
+  parent: 3:b18e25de2cf5 tip
    D
   branch: default
   commit: 1 modified, 1 added, 1 unknown, 1 unresolved
@@ -1817,13 +1816,13 @@ 
   continue: hg rebase --continue
   $ hg rebase --continue
   rebasing 1:2ec65233581b "B"
-  rebasing 3:7829726be4dc "C" (tip)
+  rebasing 2:7829726be4dc "C"
   $ hg log -G
   @  5:1964d5d5b547 C
   |
   o  4:68deb90c12a2 B
   |
-  o  2:b18e25de2cf5 D
+  o  3:b18e25de2cf5 D
   |
   o  0:426bada5c675 A
   
diff --git a/tests/test-rebase-newancestor.t b/tests/test-rebase-newancestor.t
--- a/tests/test-rebase-newancestor.t
+++ b/tests/test-rebase-newancestor.t
@@ -310,10 +310,10 @@ 
   > R
   > EOS
   $ hg rebase -r D+E+F -d Z
-  rebasing 5:5f2c926dfecf "D" (D)
-  rebasing 6:b296604d9846 "E" (E)
-  rebasing 7:caa9781e507d "F" (F tip)
-  abort: rebasing 7:caa9781e507d will include unwanted changes from 4:d6003a550c2c or 3:c1e6b162678d
+  rebasing 4:5f2c926dfecf "D" (D)
+  rebasing 5:b296604d9846 "E" (E)
+  rebasing 6:caa9781e507d "F" (F)
+  abort: rebasing 6:caa9781e507d will include unwanted changes from 3:d6003a550c2c or 2:c1e6b162678d
   [255]
 
 The warning does not get printed if there is no unwanted change detected:
@@ -330,9 +330,9 @@ 
   > R
   > EOS
   $ hg rebase -r B+C+D -d Z
-  rebasing 3:c1e6b162678d "B" (B)
-  rebasing 4:d6003a550c2c "C" (C)
-  rebasing 5:c8f78076273e "D" (D tip)
+  rebasing 2:c1e6b162678d "B" (B)
+  rebasing 3:d6003a550c2c "C" (C)
+  rebasing 4:c8f78076273e "D" (D)
   saved backup bundle to $TESTTMP/dual-merge-base2/.hg/strip-backup/d6003a550c2c-6f1424b6-rebase.hg
   $ hg manifest -r 'desc(D)'
   B
@@ -352,8 +352,8 @@ 
   > B C Z
   > EOS
   $ hg rebase -r D+F -d Z
-  rebasing 3:004dc1679908 "D" (D)
-  rebasing 5:4be4cbf6f206 "F" (F tip)
+  rebasing 2:004dc1679908 "D" (D)
+  rebasing 4:4be4cbf6f206 "F" (F)
   saved backup bundle to $TESTTMP/chosen-merge-base1/.hg/strip-backup/004dc1679908-06a66a3c-rebase.hg
   $ hg manifest -r 'desc(F)'
   C
@@ -373,8 +373,8 @@ 
   > B C Z
   > EOS
   $ hg rebase -r E+F -d Z
-  rebasing 4:974e4943c210 "E" (E)
-  rebasing 5:4be4cbf6f206 "F" (F tip)
+  rebasing 3:974e4943c210 "E" (E)
+  rebasing 4:4be4cbf6f206 "F" (F)
   saved backup bundle to $TESTTMP/chosen-merge-base2/.hg/strip-backup/974e4943c210-b2874da5-rebase.hg
   $ hg manifest -r 'desc(F)'
   B
diff --git a/tests/test-rebase-legacy.t b/tests/test-rebase-legacy.t
--- a/tests/test-rebase-legacy.t
+++ b/tests/test-rebase-legacy.t
@@ -54,13 +54,13 @@ 
 #endif
 
   $ hg continue
-  rebasing 4:c1e6b162678d "B" (B)
-  rebasing 8:6f7a236de685 "D" (D)
-  rebasing 2:de008c61a447 "E" (E)
+  rebasing 2:c1e6b162678d "B" (B)
+  rebasing 4:6f7a236de685 "D" (D)
+  rebasing 5:de008c61a447 "E" (E)
   rebasing 7:d2fa1c02b240 "G" (G)
-  rebasing 9:6582e6951a9c "H" (H tip)
+  rebasing 8:6582e6951a9c "H" (H)
   warning: orphaned descendants detected, not stripping c1e6b162678d, de008c61a447
-  saved backup bundle to $TESTTMP/.hg/strip-backup/6f7a236de685-9880a3dc-rebase.hg
+  saved backup bundle to $TESTTMP/.hg/strip-backup/d2fa1c02b240-9880a3dc-rebase.hg
 
   $ hg log -G -T '{rev}:{node|short} {desc}\n'
   o  11:721b8da0a708 H
@@ -73,15 +73,15 @@ 
   | |
   | o  7:eac96551b107 B
   |/
-  | o  6:bd5548558fcf C
+  o  6:f424eb6a8c01 Z
+  |
+  | o  5:aeba276fcb7d F
   | |
-  | | o  5:aeba276fcb7d F
-  | | |
-  | o |  4:c1e6b162678d B
-  | | |
-  o | |  3:f424eb6a8c01 Z
-  | | |
-  +---o  2:de008c61a447 E
+  | o  4:de008c61a447 E
+  |/
+  | o  3:bd5548558fcf C
+  | |
+  | o  2:c1e6b162678d B
   | |
   | o  1:21a6c4502885 A
   |/
diff --git a/tests/test-rebase-dest.t b/tests/test-rebase-dest.t
--- a/tests/test-rebase-dest.t
+++ b/tests/test-rebase-dest.t
@@ -227,9 +227,9 @@ 
   > |  |
   > A  D
   > EOS
-  rebasing 2:112478962961 "B" (B)
-  rebasing 4:26805aba1e60 "C" (C)
-  rebasing 3:cd488e83d208 "E" (E)
+  rebasing 1:112478962961 "B" (B)
+  rebasing 2:26805aba1e60 "C" (C)
+  rebasing 4:cd488e83d208 "E" (E)
   rebasing 5:0069ba24938a "F" (F tip)
   o  9: d150ff263fc8 F
   |
@@ -239,7 +239,7 @@ 
   | |
   | o  6: d0071c3b0c88 B
   | |
-  | o  1: 058c1e1fb10a D
+  | o  3: 058c1e1fb10a D
   |
   o  0: 426bada5c675 A
   
@@ -254,18 +254,18 @@ 
   > |\|
   > A D
   > EOS
-  rebasing 3:a4256619d830 "B" (B)
-  rebasing 6:8e139e245220 "C" (C tip)
+  rebasing 2:a4256619d830 "B" (B)
+  rebasing 5:8e139e245220 "C" (C)
   o    8: d7d1169e9b1c C
   |\
   | o    7: 2ed0c8546285 B
   | |\
-  o | |  5: 8fdb2c1feb20 G
+  o | |  6: 8fdb2c1feb20 G
   | | |
-  | | o  4: cd488e83d208 E
-  | | |
-  o | |  2: a6661b868de9 F
+  o | |  4: a6661b868de9 F
    / /
+  | o  3: cd488e83d208 E
+  | |
   | o  1: 058c1e1fb10a D
   |
   o  0: 426bada5c675 A
@@ -283,14 +283,14 @@ 
   >   |/
   >   A
   > EOS
-  rebasing 4:33441538d4aa "F" (F)
+  rebasing 5:33441538d4aa "F" (F)
   rebasing 6:cf43ad9da869 "G" (G)
   rebasing 7:eef94f3b5f03 "H" (H tip)
   o  10: b3d84c6666cf H
   |
-  | o  5: f585351a92f8 D
+  | o  3: f585351a92f8 D
   |/
-  o  3: 26805aba1e60 C
+  o  2: 26805aba1e60 C
   |
   | o  9: f7c28a1a15e2 G
   |/
@@ -298,7 +298,7 @@ 
   |
   | o  8: 02aa697facf7 F
   |/
-  | o  2: 7fb047a69f22 E
+  | o  4: 7fb047a69f22 E
   |/
   o  0: 426bada5c675 A
   
@@ -380,17 +380,17 @@ 
   >  \| |
   >   A H
   > EOS
-  rebasing 4:701514e1408d "I" (I)
+  rebasing 8:701514e1408d "I" (I)
   rebasing 0:426bada5c675 "A" (A)
-  rebasing 1:e7050b6e5048 "H" (H)
-  rebasing 5:26805aba1e60 "C" (C)
-  rebasing 7:cf89f86b485b "J" (J)
-  rebasing 2:112478962961 "B" (B)
-  rebasing 3:7fb047a69f22 "E" (E)
-  rebasing 8:f585351a92f8 "D" (D)
+  rebasing 7:e7050b6e5048 "H" (H)
+  rebasing 2:26805aba1e60 "C" (C)
+  rebasing 9:cf89f86b485b "J" (J)
+  rebasing 1:112478962961 "B" (B)
+  rebasing 4:7fb047a69f22 "E" (E)
+  rebasing 3:f585351a92f8 "D" (D)
   rebasing 10:ae41898d7875 "K" (K tip)
-  rebasing 9:711f53bbef0b "G" (G)
-  rebasing 6:64a8289d2492 "F" (F)
+  rebasing 6:711f53bbef0b "G" (G)
+  rebasing 5:64a8289d2492 "F" (F)
   o  21: 3735afb3713a F
   |
   o  20: 07698142d7a7 G
@@ -434,11 +434,11 @@ 
   > EOF
   6 new orphan changesets
   rebasing 16:5c432343bf59 "J" (J tip)
-  rebasing 3:26805aba1e60 "C" (C)
-  rebasing 6:f585351a92f8 "D" (D)
-  rebasing 10:ffebc37c5d0b "E3" (E3)
-  rebasing 13:fb184bcfeee8 "F2" (F2)
-  rebasing 11:dc838ab4c0da "G" (G)
+  rebasing 2:26805aba1e60 "C" (C)
+  rebasing 3:f585351a92f8 "D" (D)
+  rebasing 6:ffebc37c5d0b "E3" (E3)
+  rebasing 8:fb184bcfeee8 "F2" (F2)
+  rebasing 9:dc838ab4c0da "G" (G)
   o  22: 174f63d574a8 G
   |
   o  21: c9d9fbe76705 F2
@@ -453,13 +453,13 @@ 
   |
   o  15: eb74780f5094 I2
   |
-  o  12: 78309edd643f H
+  o  13: 78309edd643f H
   |
-  o  5: 4b4531bd8e1d B2
+  o  12: 4b4531bd8e1d B2
   |
-  o  4: 337c285c272b N
+  o  11: 337c285c272b N
   |
-  o  2: 699bc4b6fa22 M
+  o  10: 699bc4b6fa22 M
   |
   o  0: 426bada5c675 A
   
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -36,8 +36,8 @@ 
   > EOF
   $ HGEDITOR="sh $TESTTMP/editor.sh" hg rebase --collapse --keepbranches -e --source B --dest F
   rebasing 1:112478962961 "B" (B)
-  rebasing 3:26805aba1e60 "C" (C)
-  rebasing 5:f585351a92f8 "D" (D tip)
+  rebasing 2:26805aba1e60 "C" (C)
+  rebasing 3:f585351a92f8 "D" (D)
   ==== before editing
   Collapsed revision
   * B
@@ -142,7 +142,7 @@ 
   > EOF
   $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg rebase --source B --collapse -m 'custom message' -e --dest D
   rebasing 1:112478962961 "B" (B)
-  rebasing 3:26805aba1e60 "C" (C tip)
+  rebasing 2:26805aba1e60 "C" (C)
   HGEDITFORM=rebase.collapse
   saved backup bundle to $TESTTMP/message/.hg/strip-backup/112478962961-f4131707-rebase.hg
 
@@ -179,15 +179,15 @@ 
   > EOF
 
   $ hg rebase -s C --dest H --collapse
-  abort: unable to collapse on top of 3, there is more than one external parent: 1, 6
+  abort: unable to collapse on top of 7, there is more than one external parent: 1, 5
   [255]
 
 Rebase and collapse - E onto H:
 
   $ hg rebase -s E --dest H --collapse # root (E) is not a merge
-  rebasing 5:49cb92066bfd "E" (E)
-  rebasing 6:11abe3fb10b8 "F" (F)
-  rebasing 7:64e264db77f0 "G" (G tip)
+  rebasing 4:49cb92066bfd "E" (E)
+  rebasing 5:11abe3fb10b8 "F" (F)
+  rebasing 6:64e264db77f0 "G" (G)
   saved backup bundle to $TESTTMP/multiple-external-parents/.hg/strip-backup/49cb92066bfd-ee8a8a79-rebase.hg
 
   $ hg tglog
@@ -195,13 +195,13 @@ 
   |\   * E
   | |  * F
   | |  * G'
-  | o    4: 4e4f9194f9f1 'D'
-  | |\
-  o | |  3: 575c4b5ec114 'H'
-  | | |
-  +---o  2: dc0947a82db8 'C'
+  | o  4: 575c4b5ec114 'H'
   | |
-  | o  1: 112478962961 'B'
+  o |    3: 4e4f9194f9f1 'D'
+  |\ \
+  | o |  2: dc0947a82db8 'C'
+  | |/
+  o /  1: 112478962961 'B'
   |/
   o  0: 426bada5c675 'A'
   
@@ -241,27 +241,25 @@ 
   > EOF
 
   $ hg heads --template="{rev}:{node} {branch}\n"
-  7:64e264db77f061f16d9132b70c5a58e2461fb630 default
-  3:575c4b5ec114d64b681d33f8792853568bfb2b2c default
+  7:575c4b5ec114d64b681d33f8792853568bfb2b2c default
+  6:64e264db77f061f16d9132b70c5a58e2461fb630 default
 
   $ cat $TESTTMP/branch-heads/.hg/cache/branch2-served
-  64e264db77f061f16d9132b70c5a58e2461fb630 7
+  575c4b5ec114d64b681d33f8792853568bfb2b2c 7
+  64e264db77f061f16d9132b70c5a58e2461fb630 o default
   575c4b5ec114d64b681d33f8792853568bfb2b2c o default
-  64e264db77f061f16d9132b70c5a58e2461fb630 o default
 
   $ hg strip 4
-  saved backup bundle to $TESTTMP/branch-heads/.hg/strip-backup/4e4f9194f9f1-5ec4b5e6-backup.hg
+  saved backup bundle to $TESTTMP/branch-heads/.hg/strip-backup/49cb92066bfd-ee8a8a79-backup.hg
 
   $ cat $TESTTMP/branch-heads/.hg/cache/branch2-served
-  11abe3fb10b8689b560681094b17fe161871d043 5
-  dc0947a82db884575bb76ea10ac97b08536bfa03 o default
+  575c4b5ec114d64b681d33f8792853568bfb2b2c 4
+  4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4 o default
   575c4b5ec114d64b681d33f8792853568bfb2b2c o default
-  11abe3fb10b8689b560681094b17fe161871d043 o default
 
   $ hg heads --template="{rev}:{node} {branch}\n"
-  5:11abe3fb10b8689b560681094b17fe161871d043 default
-  3:575c4b5ec114d64b681d33f8792853568bfb2b2c default
-  2:dc0947a82db884575bb76ea10ac97b08536bfa03 default
+  4:575c4b5ec114d64b681d33f8792853568bfb2b2c default
+  3:4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4 default
 
   $ cd ..
 
@@ -287,7 +285,7 @@ 
   > EOF
 
   $ hg rebase -s F --dest I --collapse # root (F) is not a merge
-  rebasing 6:c82b08f646f1 "F" (F)
+  rebasing 5:c82b08f646f1 "F" (F)
   file 'E' was deleted in local [dest] but was modified in other [source].
   You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
   What do you want to do? u
@@ -299,9 +297,9 @@ 
   (no more unresolved files)
   continue: hg rebase --continue
   $ hg rebase -c
-  rebasing 6:c82b08f646f1 "F" (F)
-  rebasing 7:a6db7fa104e1 "G" (G)
-  rebasing 8:e1d201b72d91 "H" (H tip)
+  rebasing 5:c82b08f646f1 "F" (F)
+  rebasing 6:a6db7fa104e1 "G" (G)
+  rebasing 7:e1d201b72d91 "H" (H)
   saved backup bundle to $TESTTMP/external-parent/.hg/strip-backup/c82b08f646f1-f2721fbf-rebase.hg
 
   $ hg tglog
@@ -309,13 +307,13 @@ 
   |\   * F
   | |  * G
   | |  * H'
-  | | o  5: 49cb92066bfd 'E'
+  | o  5: 08ebfeb61bac 'I'
+  | |
+  | | o  4: 49cb92066bfd 'E'
   | | |
-  | o |  4: 09143c0bf13e 'D'
-  | |\|
-  o | |  3: 08ebfeb61bac 'I'
+  o---+  3: 09143c0bf13e 'D'
   | | |
-  | o |  2: dc0947a82db8 'C'
+  o | |  2: dc0947a82db8 'C'
   |/ /
   | o  1: 112478962961 'B'
   |/
@@ -385,7 +383,7 @@ 
 
 BROKEN: should be allowed
   $ hg rebase --collapse -r 'B+D+F' -d G
-  abort: unable to collapse on top of 2, there is more than one external parent: 3, 5
+  abort: unable to collapse on top of 6, there is more than one external parent: 2, 4
   [255]
   $ cd ..
 
@@ -403,7 +401,7 @@ 
   > EOF
 
   $ hg rebase --collapse -d H -s 'B+F'
-  abort: unable to collapse on top of 5, there is more than one external parent: 1, 3
+  abort: unable to collapse on top of 7, there is more than one external parent: 2, 4
   [255]
   $ cd ..
 
@@ -425,9 +423,9 @@ 
 
   $ hg rebase -s B --collapse --dest F
   rebasing 1:112478962961 "B" (B)
-  rebasing 3:26805aba1e60 "C" (C)
-  rebasing 4:be0ef73c17ad "D" (D)
-  rebasing 5:02c4367d6973 "E" (E tip)
+  rebasing 2:26805aba1e60 "C" (C)
+  rebasing 3:be0ef73c17ad "D" (D)
+  rebasing 4:02c4367d6973 "E" (E)
   saved backup bundle to $TESTTMP/internal-merge/.hg/strip-backup/112478962961-1dfb057b-rebase.hg
 
   $ hg tglog
@@ -708,16 +706,16 @@ 
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
   $ hg tglog
-  o  3: 63668d570d21 'C'
+  @  3: 82b8abf9c185 'D'
   |
-  | @  2: 82b8abf9c185 'D'
+  | o  2: 63668d570d21 'C'
   | |
-  % |  1: f899f3910ce7 'B'
+  | %  1: f899f3910ce7 'B'
   |/
   o  0: 4a2df7238c3b 'A'
   
   $ cat A
-  <<<<<<< dest:   82b8abf9c185 D - test: D
+  <<<<<<< dest:   82b8abf9c185 D tip - test: D
   D
   ||||||| base
   A
@@ -730,47 +728,47 @@ 
   continue: hg rebase --continue
   $ hg rebase --continue
   rebasing 1:f899f3910ce7 "B" (B)
-  rebasing 3:63668d570d21 "C" (C tip)
+  rebasing 2:63668d570d21 "C" (C)
   merging A
   warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
   $ hg tglog
-  %  3: 63668d570d21 'C'
+  @  3: 82b8abf9c185 'D'
   |
-  | @  2: 82b8abf9c185 'D'
+  | %  2: 63668d570d21 'C'
   | |
-  o |  1: f899f3910ce7 'B'
+  | o  1: f899f3910ce7 'B'
   |/
   o  0: 4a2df7238c3b 'A'
   
   $ cat A
-  <<<<<<< dest:   82b8abf9c185 D - test: D
+  <<<<<<< dest:   82b8abf9c185 D tip - test: D
   BC
   ||||||| base
   B
   =======
   C
-  >>>>>>> source: 63668d570d21 C tip - test: C
+  >>>>>>> source: 63668d570d21 C - test: C
   $ echo BD > A
   $ hg resolve -m
   (no more unresolved files)
   continue: hg rebase --continue
   $ HGEDITOR=false hg rebase --continue --config ui.interactive=1
   already rebased 1:f899f3910ce7 "B" (B) as 82b8abf9c185
-  rebasing 3:63668d570d21 "C" (C tip)
+  rebasing 2:63668d570d21 "C" (C)
   abort: edit failed: false exited with status 1
   [255]
   $ hg tglog
-  %  3: 63668d570d21 'C'
+  @  3: 82b8abf9c185 'D'
   |
-  | @  2: 82b8abf9c185 'D'
+  | %  2: 63668d570d21 'C'
   | |
-  o |  1: f899f3910ce7 'B'
+  | o  1: f899f3910ce7 'B'
   |/
   o  0: 4a2df7238c3b 'A'
   
   $ hg rebase --continue
   already rebased 1:f899f3910ce7 "B" (B) as 82b8abf9c185
-  already rebased 3:63668d570d21 "C" (C tip) as 82b8abf9c185
+  already rebased 2:63668d570d21 "C" (C) as 82b8abf9c185
   saved backup bundle to $TESTTMP/aborted-editor/.hg/strip-backup/f899f3910ce7-7cab5e15-rebase.hg
diff --git a/tests/test-rebase-brute-force.t b/tests/test-rebase-brute-force.t
--- a/tests/test-rebase-brute-force.t
+++ b/tests/test-rebase-brute-force.t
@@ -24,7 +24,7 @@ 
      A: A':Z
      B: B':Z
     AB: A':Z B':Z
-     C: ABORT: cannot rebase 3:a35c07e8a2a4 without moving at least one of its parents
+     C: ABORT: cannot rebase 2:a35c07e8a2a4 without moving at least one of its parents
     AC: A':Z C':A'B
     BC: B':Z C':B'A
    ABC: A':Z B':Z C':A'B'
@@ -32,7 +32,7 @@ 
     AD: A':Z D':Z
     BD: B':Z D':B'
    ABD: A':Z B':Z D':B'
-    CD: ABORT: cannot rebase 3:a35c07e8a2a4 without moving at least one of its parents
+    CD: ABORT: cannot rebase 2:a35c07e8a2a4 without moving at least one of its parents
    ACD: A':Z C':A'B D':Z
    BCD: B':Z C':B'A D':B'
   ABCD: A':Z B':Z C':A'B' D':B'
diff --git a/tests/test-rebase-base-flag.t b/tests/test-rebase-base-flag.t
--- a/tests/test-rebase-base-flag.t
+++ b/tests/test-rebase-base-flag.t
@@ -37,8 +37,8 @@ 
   >   R
   > EOS
   rebasing 3:d6003a550c2c "C" (C)
-  rebasing 5:4526cf523425 "D" (D)
-  rebasing 6:b296604d9846 "E" (E tip)
+  rebasing 4:4526cf523425 "D" (D)
+  rebasing 5:b296604d9846 "E" (E)
   o  6: 4870f5e7df37 E
   |
   | o  5: dc999528138a D
@@ -68,7 +68,7 @@ 
   > EOS
   rebasing 2:c1e6b162678d "B" (B)
   rebasing 3:d6003a550c2c "C" (C)
-  rebasing 6:54c8f00cb91c "E" (E tip)
+  rebasing 5:54c8f00cb91c "E" (E)
   o    6: 00598421b616 E
   |\
   | o  5: 6b3e11729672 C
@@ -95,7 +95,7 @@ 
   >   R
   > EOS
   rebasing 2:c1e6b162678d "B" (B)
-  rebasing 5:54c8f00cb91c "E" (E tip)
+  rebasing 4:54c8f00cb91c "E" (E)
   o    5: e583bf3ff54c E
   |\
   | o  4: 85260910e847 B
@@ -121,7 +121,7 @@ 
   > EOS
   rebasing 2:c1e6b162678d "B" (B)
   rebasing 3:d6003a550c2c "C" (C)
-  rebasing 5:54c8f00cb91c "E" (E tip)
+  rebasing 4:54c8f00cb91c "E" (E)
   o    5: 00598421b616 E
   |\
   | o  4: 6b3e11729672 C
@@ -168,11 +168,11 @@ 
   >   R
   > EOS
   rebasing 3:a113dbaa660a "B1" (B1)
-  rebasing 5:06ce7b1cc8c2 "B2" (B2)
+  rebasing 4:06ce7b1cc8c2 "B2" (B2)
   rebasing 6:0ac98cce32d3 "C1" (C1)
-  rebasing 8:781512f5e33d "C2" (C2)
+  rebasing 7:781512f5e33d "C2" (C2)
   rebasing 9:428d8c18f641 "E1" (E1)
-  rebasing 11:e1bf82f6b6df "E2" (E2)
+  rebasing 10:e1bf82f6b6df "E2" (E2)
   o  12: e4a37b6fdbd2 E2
   |
   o  11: 9675bea983df E1
@@ -211,18 +211,18 @@ 
   >   A   A   A
   > EOS
   rebasing 2:dc0947a82db8 "C" (C)
-  rebasing 8:4e4f9194f9f1 "D" (D)
-  rebasing 9:03ca77807e91 "E" (E)
-  rebasing 10:afc707c82df0 "F" (F)
-  rebasing 13:690dfff91e9e "G" (G)
-  rebasing 14:2893b886bb10 "H" (H)
-  rebasing 3:08ebfeb61bac "I" (I)
-  rebasing 4:a0a5005cec67 "J" (J)
-  rebasing 5:83780307a7e8 "K" (K)
-  rebasing 6:e131637a1cb6 "L" (L)
-  rebasing 11:d1f6d0c3c7e4 "M" (M)
-  rebasing 12:7aaec6f81888 "N" (N)
-  rebasing 15:325bc8f1760d "P" (P tip)
+  rebasing 3:4e4f9194f9f1 "D" (D)
+  rebasing 4:03ca77807e91 "E" (E)
+  rebasing 5:afc707c82df0 "F" (F)
+  rebasing 6:690dfff91e9e "G" (G)
+  rebasing 7:2893b886bb10 "H" (H)
+  rebasing 8:08ebfeb61bac "I" (I)
+  rebasing 9:a0a5005cec67 "J" (J)
+  rebasing 10:83780307a7e8 "K" (K)
+  rebasing 11:e131637a1cb6 "L" (L)
+  rebasing 12:d1f6d0c3c7e4 "M" (M)
+  rebasing 13:7aaec6f81888 "N" (N)
+  rebasing 14:325bc8f1760d "P" (P)
   o    15: 6ef6a0ea3b18 P
   |\
   | o    14: 20ba3610a7e5 N
@@ -269,25 +269,25 @@ 
   > M0
   > EOF
   rebasing 4:8817fae53c94 "C0" (C0)
-  rebasing 6:06ca5dfe3b5b "B2" (B2)
-  rebasing 7:73508237b032 "C1" (C1)
-  rebasing 9:fdb955e2faed "A2" (A2)
-  rebasing 11:4e449bd1a643 "A3" (A3)
-  rebasing 10:0a33b0519128 "B1" (B1)
-  rebasing 12:209327807c3a "B3" (B3 tip)
+  rebasing 5:73508237b032 "C1" (C1)
+  rebasing 6:fdb955e2faed "A2" (A2)
+  rebasing 7:4e449bd1a643 "A3" (A3)
+  rebasing 8:0a33b0519128 "B1" (B1)
+  rebasing 10:06ca5dfe3b5b "B2" (B2)
+  rebasing 11:209327807c3a "B3" (B3)
   o    12: ceb984566332 B3
   |\
-  | o  11: 19d93caac497 B1
+  | o  11: 74275896650e B2
+  | |
+  o |  10: 19d93caac497 B1
   | |
-  | | o    10: 058e73d3916b A3
+  | | o    9: 058e73d3916b A3
   | | |\
-  | +---o  9: 0ba13ad72234 A2
+  +-----o  8: 0ba13ad72234 A2
   | | |
-  | o |  8: c122c2af10c6 C1
+  o | |  7: c122c2af10c6 C1
   | | |
-  o | |  7: 74275896650e B2
-  | | |
-  | o |  6: 455ba9bd3ea2 C0
+  o | |  6: 455ba9bd3ea2 C0
   |/ /
   o |  5: b3d7d2fda53b Z
   | |
@@ -318,7 +318,7 @@ 
   >  \|\|
   >   C A
   > EOF
-  rebasing 2:112478962961 "B" (B)
+  rebasing 1:112478962961 "B" (B)
   rebasing 3:b70f76719894 "D" (D)
   o  4: 511efad7bf13 D
   |
@@ -350,7 +350,7 @@ 
   >   A C
   > EOF
   rebasing 2:f675d5a1c6a4 "B" (B)
-  rebasing 5:f68696fe6af8 "E" (E tip)
+  rebasing 4:f68696fe6af8 "E" (E)
   o    5: f6e6f5081554 E
   |\
   | o    4: 30cabcba27be B
diff --git a/tests/test-phases-exchange.t b/tests/test-phases-exchange.t
--- a/tests/test-phases-exchange.t
+++ b/tests/test-phases-exchange.t
@@ -1422,7 +1422,7 @@ 
   test-debug-phase: move rev 0: 1 -> 0
   test-debug-phase: move rev 1: 1 -> 0
   test-debug-phase: move rev 2: 1 -> 0
-  test-debug-phase: move rev 4: 1 -> 0
+  test-debug-phase: move rev 3: 1 -> 0
 
   $ hg log -G -T '{shortest(node, 5)} {phase}'
   o  bb947 draft
@@ -1431,9 +1431,9 @@ 
   |/|
   o |  13b7b draft
   | |
-  | o  f5853 public
+  o |  c67c4 draft
   | |
-  o |  c67c4 draft
+  | o  f5853 public
   | |
   | o  26805 public
   |/
@@ -1458,8 +1458,8 @@ 
   test-debug-phase: new rev 0:  x -> 0
   test-debug-phase: new rev 1:  x -> 0
   test-debug-phase: new rev 2:  x -> 0
-  test-debug-phase: new rev 3:  x -> 1
-  test-debug-phase: new rev 4:  x -> 0
+  test-debug-phase: new rev 3:  x -> 0
+  test-debug-phase: new rev 4:  x -> 1
   test-debug-phase: new rev 5:  x -> 1
   test-debug-phase: new rev 6:  x -> 1
   test-debug-phase: new rev 7:  x -> 1
@@ -1471,9 +1471,9 @@ 
   |/|
   o |  13b7b draft
   | |
-  | o  f5853 public
+  o |  c67c4 draft
   | |
-  o |  c67c4 draft
+  | o  f5853 public
   | |
   | o  26805 public
   |/
@@ -1500,8 +1500,8 @@ 
   test-debug-phase: new rev 0:  x -> 0
   test-debug-phase: new rev 1:  x -> 0
   test-debug-phase: new rev 2:  x -> 0
-  test-debug-phase: new rev 3:  x -> 1
-  test-debug-phase: new rev 4:  x -> 0
+  test-debug-phase: new rev 3:  x -> 0
+  test-debug-phase: new rev 4:  x -> 1
   test-debug-phase: new rev 5:  x -> 1
   test-debug-phase: new rev 6:  x -> 1
   test-debug-phase: new rev 7:  x -> 1
@@ -1513,9 +1513,9 @@ 
   |/|
   o |  13b7b draft
   | |
-  | o  f5853 public
+  o |  c67c4 draft
   | |
-  o |  c67c4 draft
+  | o  f5853 public
   | |
   | o  26805 public
   |/
@@ -1542,8 +1542,8 @@ 
   test-debug-phase: new rev 0:  x -> 0
   test-debug-phase: new rev 1:  x -> 0
   test-debug-phase: new rev 2:  x -> 0
-  test-debug-phase: new rev 3:  x -> 1
-  test-debug-phase: new rev 4:  x -> 0
+  test-debug-phase: new rev 3:  x -> 0
+  test-debug-phase: new rev 4:  x -> 1
   test-debug-phase: new rev 5:  x -> 1
   test-debug-phase: new rev 6:  x -> 1
   test-debug-phase: new rev 7:  x -> 1
@@ -1555,9 +1555,9 @@ 
   |/|
   o |  13b7b draft
   | |
-  | o  f5853 public
+  o |  c67c4 draft
   | |
-  o |  c67c4 draft
+  | o  f5853 public
   | |
   | o  26805 public
   |/
diff --git a/tests/test-obsolete-divergent.t b/tests/test-obsolete-divergent.t
--- a/tests/test-obsolete-divergent.t
+++ b/tests/test-obsolete-divergent.t
@@ -756,7 +756,7 @@ 
   |
   | *  4:70d5a63ca112 B4 content-divergent
   | |
-  | o  1:48b9aae0607f Z
+  | o  2:48b9aae0607f Z
   |
   o  0:426bada5c675 A
   
diff --git a/tests/test-drawdag.t b/tests/test-drawdag.t
--- a/tests/test-drawdag.t
+++ b/tests/test-drawdag.t
@@ -39,10 +39,10 @@ 
   $ hg log -G -T '{desc}'
   o    foo
   |\
-  +---o  bar
-  | | |
-  | o |  baz
-  |  /
+  | o  baz
+  |
+  | o  bar
+  |/|
   +---o  d
   | |
   +---o  c
@@ -72,16 +72,16 @@ 
   $ hg log -G -T '{desc}'
   o    foo
   |\
-  | | o  d
-  | |/
-  | | o  c
-  | |/
-  | | o  bar
-  | |/|
-  | o |  b
-  | |/
-  o /  baz
-   /
+  +---o  d
+  | |
+  +---o  c
+  | |
+  | o  baz
+  |
+  | o  bar
+  |/|
+  o |  b
+  |/
   o  a
   
   $ reinit
@@ -105,16 +105,16 @@ 
   $ hg log -G -T '{desc}'
   o    foo
   |\
-  | | o  d
-  | |/
-  | | o  c
-  | |/
-  | | o  bar
-  | |/|
-  | o |  b
-  | |/
-  o /  baz
-   /
+  +---o  d
+  | |
+  +---o  c
+  | |
+  | o  baz
+  |
+  | o  bar
+  |/|
+  o |  b
+  |/
   o  a
   
   $ hg manifest -r a
@@ -209,22 +209,22 @@ 
   1 new orphan changesets
 
   $ hg log -r 'sort(all(), topo)' -G --hidden -T '{desc} {node}'
-  *  G 711f53bbef0bebd12eb6f0511d5e2e998b984846
+  x  I 58e6b987bf7045fcd9c54f496396ca1d1fc81047
+  |
+  o  H 575c4b5ec114d64b681d33f8792853568bfb2b2c
   |
-  x  F 64a8289d249234b9886244d379f15e6b650b28e3
-  |
-  o  E 7fb047a69f220c21711122dfd94305a9efb60cba
-  |
+  | *  G 711f53bbef0bebd12eb6f0511d5e2e998b984846
+  | |
+  | x  F 64a8289d249234b9886244d379f15e6b650b28e3
+  | |
+  | o  E 7fb047a69f220c21711122dfd94305a9efb60cba
+  |/
   | x  D be0ef73c17ade3fc89dc41701eb9fc3a91b58282
   | |
   | | x  C 26805aba1e600a82e93661149f2313866a221a7b
   | |/
   | x  B 112478962961147124edd43549aedd1a335e44bf
   |/
-  | x  I 58e6b987bf7045fcd9c54f496396ca1d1fc81047
-  | |
-  | o  H 575c4b5ec114d64b681d33f8792853568bfb2b2c
-  |/
   o  A 426bada5c67598ca65036d57d9e4b64b0c1ce7a0
   
   $ hg debugobsolete
diff --git a/tests/drawdag.py b/tests/drawdag.py
--- a/tests/drawdag.py
+++ b/tests/drawdag.py
@@ -327,13 +327,13 @@ 
         leafs = [k for k, v in remaining.items() if not v]
         if not leafs:
             raise error.Abort(_('the graph has cycles'))
-        for leaf in sorted(leafs):
-            if leaf in visible:
-                yield leaf, edges[leaf]
-            del remaining[leaf]
-            for k, v in remaining.items():
-                if leaf in v:
-                    v.remove(leaf)
+        leaf = min(leafs)
+        if leaf in visible:
+            yield leaf, edges[leaf]
+        del remaining[leaf]
+        for k, v in remaining.items():
+            if leaf in v:
+                v.remove(leaf)
 
 
 def _getcomments(text):