rebase: rebase changesets in topo order (issue5370) (BC)
authorXidorn Quan <me@upsuper.org>
Sat, 17 Sep 2016 17:02:56 +1000
changeset 30007 aca0954d3739
parent 30006 b19c2679289c
child 30008 e83f89d3b1f7
rebase: rebase changesets in topo order (issue5370) (BC) There are two reasons that rebase should be done this way: 1. This would make rebasing faster because it would minimize the total number of files to be checked out in the process, as it don't need to switch back and forth between branches. 2. It makes resolving conflicts easier as user has a better context. This commit changes the behavior in "Test multiple root handling" of test-rebase-obsolete.t. It is an expected change which reflects the new behavior that commits in a branch are grouped together when rebased.
hgext/rebase.py
tests/test-rebase-obsolete.t
tests/test-rebase-scenario-global.t
--- a/hgext/rebase.py	Thu Sep 22 12:36:30 2016 -0700
+++ b/hgext/rebase.py	Sat Sep 17 17:02:56 2016 +1000
@@ -335,7 +335,7 @@
         if self.activebookmark:
             bookmarks.deactivate(repo)
 
-        sortedrevs = sorted(self.state)
+        sortedrevs = repo.revs('sort(%ld, -topo)', self.state)
         cands = [k for k, v in self.state.iteritems() if v == revtodo]
         total = len(cands)
         pos = 0
--- a/tests/test-rebase-obsolete.t	Thu Sep 22 12:36:30 2016 -0700
+++ b/tests/test-rebase-obsolete.t	Sat Sep 17 17:02:56 2016 +1000
@@ -418,16 +418,16 @@
 ------------------------------------
 
   $ hg rebase --dest 4 --rev '7+11+9'
+  rebasing 9:cf44d2f5a9f4 "D"
   rebasing 7:02de42196ebe "H"
-  rebasing 9:cf44d2f5a9f4 "D"
   not rebasing ignored 10:7c6027df6a99 "B"
   rebasing 11:0d8f238b634c "C" (tip)
   $ hg log -G
   o  14:1e8370e38cca C
   |
-  | o  13:102b4c1d889b D
-  | |
-  @ |  12:bfe264faf697 H
+  @  13:bfe264faf697 H
+  |
+  | o  12:102b4c1d889b D
   |/
   | o  10:7c6027df6a99 B
   | |
--- a/tests/test-rebase-scenario-global.t	Thu Sep 22 12:36:30 2016 -0700
+++ b/tests/test-rebase-scenario-global.t	Sat Sep 17 17:02:56 2016 +1000
@@ -761,6 +761,69 @@
   rebasing 3:a7d6f3a00bf3 "second source with subdir" (tip)
   saved backup bundle to $TESTTMP/cwd-vanish/.hg/strip-backup/779a07b1b7a0-853e0073-backup.hg (glob)
 
+Test that rebase is done in topo order (issue5370)
+
+  $ cd ..
+  $ hg init order
+  $ cd order
+  $ touch a && hg add a && hg ci -m A
+  $ touch b && hg add b && hg ci -m B
+  $ touch c && hg add c && hg ci -m C
+  $ hg up 1
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ touch d && hg add d && hg ci -m D
+  created new head
+  $ hg up 2
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ touch e && hg add e && hg ci -m E
+  $ hg up 3
+  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ touch f && hg add f && hg ci -m F
+  $ hg up 0
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  $ touch g && hg add g && hg ci -m G
+  created new head
+
+  $ hg tglog
+  @  6: 'G'
+  |
+  | o  5: 'F'
+  | |
+  | | o  4: 'E'
+  | | |
+  | o |  3: 'D'
+  | | |
+  | | o  2: 'C'
+  | |/
+  | o  1: 'B'
+  |/
+  o  0: 'A'
+  
+
+  $ hg rebase -s 1 -d 6
+  rebasing 1:76035bbd54bd "B"
+  rebasing 2:d84f5cfaaf14 "C"
+  rebasing 4:82ae8dc7a9b7 "E"
+  rebasing 3:ab709c9f7171 "D"
+  rebasing 5:412b391de760 "F"
+  saved backup bundle to $TESTTMP/cwd-vanish/order/.hg/strip-backup/76035bbd54bd-e341bc99-backup.hg (glob)
+
+  $ hg tglog
+  o  6: 'F'
+  |
+  o  5: 'D'
+  |
+  | o  4: 'E'
+  | |
+  | o  3: 'C'
+  |/
+  o  2: 'B'
+  |
+  @  1: 'G'
+  |
+  o  0: 'A'
+  
+
 Test experimental revset
 ========================