rebase: preserve working directory parent (BC)
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Mon, 14 Oct 2013 16:12:29 +0200
changeset 19925 9c78ed396075
parent 19924 c23c62209cc4
child 19926 0f99747202f9
rebase: preserve working directory parent (BC) Prior to this changeset, rebase always left the working directory as a parent of the last rebased changeset. The is dubious when, before the rebase, the working directory was not a parent of the tip most rebased changeset. With this changeset, we move the working directory back to its original parent. If the original parent was rebased, we use it's successors. This is a step toward solving issue3813 (rebase loses active bookmark if it's not on a head)
hgext/rebase.py
tests/test-rebase-bookmarks.t
tests/test-rebase-cache.t
tests/test-rebase-check-restore.t
tests/test-rebase-collapse.t
tests/test-rebase-detach.t
tests/test-rebase-interruptions.t
tests/test-rebase-named-branches.t
tests/test-rebase-newancestor.t
tests/test-rebase-obsolete.t
tests/test-rebase-parameters.t
tests/test-rebase-scenario-global.t
--- a/hgext/rebase.py	Mon Oct 14 16:49:54 2013 +0200
+++ b/hgext/rebase.py	Mon Oct 14 16:12:29 2013 +0200
@@ -359,6 +359,13 @@
             # this should probably be cleaned up
             targetnode = repo[target].node()
 
+        # restore original working directory
+        # (we do this before stripping)
+        newwd = state.get(originalwd, originalwd)
+        if newwd not in [c.rev() for c in repo[None].parents()]:
+            ui.note(_("update back to initial working directory parent\n"))
+            hg.updaterepo(repo, newwd, False)
+
         if not keepf:
             collapsedas = None
             if collapsef:
--- a/tests/test-rebase-bookmarks.t	Mon Oct 14 16:49:54 2013 +0200
+++ b/tests/test-rebase-bookmarks.t	Mon Oct 14 16:12:29 2013 +0200
@@ -119,9 +119,9 @@
   saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  3: 'C' bookmarks: Y Z
+  o  3: 'C' bookmarks: Y Z
   |
-  o  2: 'B' bookmarks: X
+  @  2: 'B' bookmarks: X
   |
   o  1: 'D' bookmarks: W
   |
@@ -130,7 +130,7 @@
 rebase --continue with bookmarks present (issue3802)
 
   $ hg up 2
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo 'C' > c
   $ hg add c
   $ hg ci -m 'other C'
--- a/tests/test-rebase-cache.t	Mon Oct 14 16:49:54 2013 +0200
+++ b/tests/test-rebase-cache.t	Mon Oct 14 16:12:29 2013 +0200
@@ -121,11 +121,11 @@
   0: 'A' 
 
   $ hg tglog
-  @  8: 'E' branch3
+  o  8: 'E' branch3
   |
   o  7: 'D' branch3
   |
-  o  6: 'F' branch3
+  @  6: 'F' branch3
   |
   o  5: 'branch3' branch3
   |
--- a/tests/test-rebase-check-restore.t	Mon Oct 14 16:49:54 2013 +0200
+++ b/tests/test-rebase-check-restore.t	Mon Oct 14 16:12:29 2013 +0200
@@ -80,11 +80,11 @@
   $ hg rebase --continue
 
   $ hg tglog
-  @  7:secret 'C'
+  o  7:secret 'C'
   |
   o  6:draft 'B'
   |
-  | o  5:draft 'F' notdefault
+  | @  5:draft 'F' notdefault
   | |
   o |  4:draft 'E'
   | |
--- a/tests/test-rebase-collapse.t	Mon Oct 14 16:49:54 2013 +0200
+++ b/tests/test-rebase-collapse.t	Mon Oct 14 16:12:29 2013 +0200
@@ -57,11 +57,11 @@
   saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglogp
-  @  5:secret 'Collapsed revision
+  o  5:secret 'Collapsed revision
   |  * B
   |  * C
   |  * D'
-  o  4:draft 'H'
+  @  4:draft 'H'
   |
   | o  3:draft 'G'
   |/|
@@ -92,10 +92,10 @@
   saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  6: 'Collapsed revision
+  o  6: 'Collapsed revision
   |  * E
   |  * G'
-  o  5: 'H'
+  @  5: 'H'
   |
   o  4: 'F'
   |
@@ -128,9 +128,9 @@
   saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  6: 'custom message'
+  o  6: 'custom message'
   |
-  o  5: 'H'
+  @  5: 'H'
   |
   o  4: 'F'
   |
@@ -235,11 +235,11 @@
   saved backup bundle to $TESTTMP/b1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @    5: 'Collapsed revision
+  o    5: 'Collapsed revision
   |\   * E
   | |  * F
   | |  * G'
-  | o  4: 'H'
+  | @  4: 'H'
   | |
   o |    3: 'D'
   |\ \
@@ -384,12 +384,12 @@
   saved backup bundle to $TESTTMP/c1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @    5: 'Collapsed revision
+  o    5: 'Collapsed revision
   |\   * E
   | |  * F
   | |  * G
   | |  * H'
-  | o  4: 'I'
+  | @  4: 'I'
   | |
   o |    3: 'D'
   |\ \
@@ -473,12 +473,12 @@
   saved backup bundle to $TESTTMP/d1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  2: 'Collapsed revision
+  o  2: 'Collapsed revision
   |  * B
   |  * C
   |  * D
   |  * E'
-  o  1: 'F'
+  @  1: 'F'
   |
   o  0: 'A'
   
@@ -740,9 +740,9 @@
   $ hg rebase -d 0 -r "1::2" --collapse -m collapsed
   saved backup bundle to $TESTTMP/collapseaddremove/.hg/strip-backup/*-backup.hg (glob)
   $ hg tglog
-  @  1: 'collapsed'
+  o  1: 'collapsed'
   |
-  o  0: 'base'
+  @  0: 'base'
   
   $ hg manifest --rev tip
   b
--- a/tests/test-rebase-detach.t	Mon Oct 14 16:49:54 2013 +0200
+++ b/tests/test-rebase-detach.t	Mon Oct 14 16:12:29 2013 +0200
@@ -52,9 +52,9 @@
   saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg log -G --template "{rev}:{phase} '{desc}' {branches}\n"
-  @  7:secret 'D'
+  o  7:secret 'D'
   |
-  o  6:draft 'H'
+  @  6:draft 'H'
   |
   | o  5:draft 'G'
   |/|
@@ -103,11 +103,11 @@
   saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  7: 'D'
+  o  7: 'D'
   |
   o  6: 'C'
   |
-  o  5: 'H'
+  @  5: 'H'
   |
   | o  4: 'G'
   |/|
@@ -155,13 +155,13 @@
   saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  7: 'D'
+  o  7: 'D'
   |
   o  6: 'C'
   |
   o  5: 'B'
   |
-  o  4: 'H'
+  @  4: 'H'
   |
   | o  3: 'G'
   |/|
@@ -209,10 +209,10 @@
   saved backup bundle to $TESTTMP/a4/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg  log -G --template "{rev}:{phase} '{desc}' {branches}\n"
-  @  6:secret 'Collapsed revision
+  o  6:secret 'Collapsed revision
   |  * C
   |  * D'
-  o  5:draft 'H'
+  @  5:draft 'H'
   |
   | o  4:draft 'G'
   |/|
@@ -268,13 +268,13 @@
   saved backup bundle to $TESTTMP/a5/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  8: 'D'
+  o  8: 'D'
   |
   o  7: 'C'
   |
   o  6: 'B'
   |
-  o  5: 'extra branch'
+  @  5: 'extra branch'
   
   o  4: 'H'
   |
@@ -290,13 +290,13 @@
   $ hg rebase -d 5 -s 7
   saved backup bundle to $TESTTMP/a5/.hg/strip-backup/13547172c9c0-backup.hg (glob)
   $ hg tglog
-  @  8: 'D'
+  o  8: 'D'
   |
   o  7: 'C'
   |
   | o  6: 'B'
   |/
-  o  5: 'extra branch'
+  @  5: 'extra branch'
   
   o  4: 'H'
   |
@@ -329,11 +329,11 @@
   saved backup bundle to $TESTTMP/a6/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  8: 'Collapsed revision
+  o  8: 'Collapsed revision
   |  * I
   |  * Merge
   |  * J'
-  o  7: 'H'
+  @  7: 'H'
   |
   | o  6: 'G'
   |/|
--- a/tests/test-rebase-interruptions.t	Mon Oct 14 16:49:54 2013 +0200
+++ b/tests/test-rebase-interruptions.t	Mon Oct 14 16:12:29 2013 +0200
@@ -110,13 +110,13 @@
   warning: new changesets detected on source branch, not stripping
 
   $ hg tglogp
-  @  7:draft 'C'
+  o  7:draft 'C'
   |
   | o  6:secret 'Extra'
   | |
   o |  5:draft 'B'
   | |
-  o |  4:draft 'E'
+  @ |  4:draft 'E'
   | |
   o |  3:draft 'D'
   | |
--- a/tests/test-rebase-named-branches.t	Mon Oct 14 16:49:54 2013 +0200
+++ b/tests/test-rebase-named-branches.t	Mon Oct 14 16:12:29 2013 +0200
@@ -147,7 +147,7 @@
   saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  9: 'dev-two named branch' dev-two
+  o  9: 'dev-two named branch' dev-two
   |
   o  8: 'H'
   |
@@ -155,7 +155,7 @@
   |/|
   o |  6: 'F'
   | |
-  o |  5: 'dev-one named branch' dev-one
+  @ |  5: 'dev-one named branch' dev-one
   | |
   | o  4: 'E'
   | |
@@ -171,7 +171,7 @@
   saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  8: 'dev-two named branch' dev-two
+  o  8: 'dev-two named branch' dev-two
   |
   o  7: 'H'
   |
@@ -187,7 +187,7 @@
   | |
   | o  1: 'B'
   |/
-  o  0: 'A'
+  @  0: 'A'
   
 
 Rebasing descendant onto ancestor across different named branches
@@ -196,7 +196,7 @@
   saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  8: 'D'
+  o  8: 'D'
   |
   o  7: 'C'
   |
@@ -212,7 +212,7 @@
   | |
   | o  1: 'E'
   |/
-  o  0: 'A'
+  @  0: 'A'
   
   $ hg rebase -s 4 -d 5
   abort: source is ancestor of destination
@@ -222,7 +222,7 @@
   saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  8: 'D'
+  o  8: 'D'
   |
   o  7: 'C'
   |
@@ -238,6 +238,6 @@
   | |
   | o  1: 'E'
   |/
-  o  0: 'A'
+  @  0: 'A'
   
   $ cd ..
--- a/tests/test-rebase-newancestor.t	Mon Oct 14 16:49:54 2013 +0200
+++ b/tests/test-rebase-newancestor.t	Mon Oct 14 16:12:29 2013 +0200
@@ -44,11 +44,11 @@
   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  3: 'C'
+  o  3: 'C'
   |
   o  2: 'B'
   |
-  o  1: 'AD'
+  @  1: 'AD'
   |
   o  0: 'A'
   
--- a/tests/test-rebase-obsolete.t	Mon Oct 14 16:49:54 2013 +0200
+++ b/tests/test-rebase-obsolete.t	Mon Oct 14 16:12:29 2013 +0200
@@ -126,9 +126,9 @@
   grafting revision 3
   $ hg rebase  -s 42ccdea3bb16 -d .
   $ hg log -G
-  @  10:5ae4c968c6ac C
+  o  10:5ae4c968c6ac C
   |
-  o  9:08483444fef9 D
+  @  9:08483444fef9 D
   |
   o  8:8877864f1edb B
   |
@@ -143,9 +143,9 @@
   o  0:cd010b8cd998 A
   
   $ hg log --hidden -G
-  @  10:5ae4c968c6ac C
+  o  10:5ae4c968c6ac C
   |
-  o  9:08483444fef9 D
+  @  9:08483444fef9 D
   |
   o  8:8877864f1edb B
   |
@@ -209,11 +209,11 @@
   5ae4c968c6aca831df823664e706c9d4aa34473d 98f6af4ee9539e14da4465128f894c274900b6e5 0 {'date': '* *', 'user': 'test'} (glob)
   $ hg log --rev 'divergent()'
   $ hg log -G
-  @  13:98f6af4ee953 C
+  o  13:98f6af4ee953 C
   |
   o  12:462a34d07e59 B
   |
-  o  11:4596109a6a43 D
+  @  11:4596109a6a43 D
   |
   o  7:02de42196ebe H
   |
@@ -252,9 +252,9 @@
   $ cd collapse
   $ hg rebase  -s 42ccdea3bb16 -d eea13746799a --collapse
   $ hg log -G
-  @  8:4dc2197e807b Collapsed revision
+  o  8:4dc2197e807b Collapsed revision
   |
-  | o  7:02de42196ebe H
+  | @  7:02de42196ebe H
   | |
   o |  6:eea13746799a G
   |\|
@@ -265,9 +265,9 @@
   o  0:cd010b8cd998 A
   
   $ hg log --hidden -G
-  @  8:4dc2197e807b Collapsed revision
+  o  8:4dc2197e807b Collapsed revision
   |
-  | o  7:02de42196ebe H
+  | @  7:02de42196ebe H
   | |
   o |  6:eea13746799a G
   |\|
@@ -305,13 +305,13 @@
   $ hg rebase -s 5fddd98957c8 -d eea13746799a
   $ hg rebase -s 42ccdea3bb16 -d 02de42196ebe
   $ hg log -G
-  @  10:7c6027df6a99 B
+  o  10:7c6027df6a99 B
   |
   | o  9:cf44d2f5a9f4 D
   | |
   | o  8:e273c5e7d2d2 C
   | |
-  o |  7:02de42196ebe H
+  @ |  7:02de42196ebe H
   | |
   | o  6:eea13746799a G
   |/|
@@ -322,13 +322,13 @@
   o  0:cd010b8cd998 A
   
   $ hg log --hidden -G
-  @  10:7c6027df6a99 B
+  o  10:7c6027df6a99 B
   |
   | o  9:cf44d2f5a9f4 D
   | |
   | o  8:e273c5e7d2d2 C
   | |
-  o |  7:02de42196ebe H
+  @ |  7:02de42196ebe H
   | |
   | o  6:eea13746799a G
   |/|
@@ -356,7 +356,7 @@
   9:cf44d2f5a9f4 D (no-eol)
   $ hg rebase -r 8
   $ hg log -G
-  @  11:0d8f238b634c C
+  o  11:0d8f238b634c C
   |
   o  10:7c6027df6a99 B
   |
@@ -364,7 +364,7 @@
   | |
   | x  8:e273c5e7d2d2 C
   | |
-  o |  7:02de42196ebe H
+  @ |  7:02de42196ebe H
   | |
   | o  6:eea13746799a G
   |/|
@@ -381,11 +381,11 @@
 
   $ hg rebase --dest 4 --rev '7+11+9'
   $ hg log -G
-  @  14:1e8370e38cca C
+  o  14:1e8370e38cca C
   |
   | o  13:102b4c1d889b D
   | |
-  o |  12:bfe264faf697 H
+  @ |  12:bfe264faf697 H
   |/
   | o  10:7c6027df6a99 B
   | |
--- a/tests/test-rebase-parameters.t	Mon Oct 14 16:49:54 2013 +0200
+++ b/tests/test-rebase-parameters.t	Mon Oct 14 16:12:29 2013 +0200
@@ -197,11 +197,11 @@
   saved backup bundle to $TESTTMP/a4/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  8: 'D'
+  o  8: 'D'
   |
   o  7: 'C'
   |
-  o  6: 'I'
+  @  6: 'I'
   |
   o  5: 'H'
   |
@@ -257,13 +257,13 @@
   saved backup bundle to $TESTTMP/a6/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  8: 'D'
+  o  8: 'D'
   |
   o  7: 'C'
   |
   o  6: 'B'
   |
-  o  5: 'I'
+  @  5: 'I'
   |
   o  4: 'H'
   |
@@ -287,11 +287,11 @@
   saved backup bundle to $TESTTMP/a7/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  8: 'D'
+  o  8: 'D'
   |
   o  7: 'C'
   |
-  | o  6: 'I'
+  | @  6: 'I'
   |/
   o  5: 'H'
   |
@@ -317,13 +317,13 @@
   saved backup bundle to $TESTTMP/a8/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  8: 'D'
+  o  8: 'D'
   |
   o  7: 'C'
   |
   o  6: 'B'
   |
-  | o  5: 'I'
+  | @  5: 'I'
   |/
   o  4: 'H'
   |
@@ -347,11 +347,11 @@
   saved backup bundle to $TESTTMP/a9/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  8: 'D'
+  o  8: 'D'
   |
   o  7: 'C'
   |
-  o  6: 'I'
+  @  6: 'I'
   |
   o  5: 'H'
   |
--- a/tests/test-rebase-scenario-global.t	Mon Oct 14 16:49:54 2013 +0200
+++ b/tests/test-rebase-scenario-global.t	Mon Oct 14 16:12:29 2013 +0200
@@ -52,9 +52,9 @@
   saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  7: 'D'
+  o  7: 'D'
   |
-  o  6: 'H'
+  @  6: 'H'
   |
   | o  5: 'G'
   |/|
@@ -80,9 +80,9 @@
   saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  7: 'D'
+  o  7: 'D'
   |
-  | o  6: 'H'
+  | @  6: 'H'
   |/
   | o  5: 'G'
   |/|
@@ -108,9 +108,9 @@
   saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @  6: 'E'
+  o  6: 'E'
   |
-  o  5: 'H'
+  @  5: 'H'
   |
   o  4: 'F'
   |
@@ -160,9 +160,9 @@
   saved backup bundle to $TESTTMP/a5/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  @    7: 'G'
+  o    7: 'G'
   |\
-  | o  6: 'H'
+  | @  6: 'H'
   | |
   | o  5: 'F'
   | |
@@ -256,11 +256,11 @@
   $ hg rebase -d 0 -s 2
   saved backup bundle to $TESTTMP/a7/.hg/strip-backup/5fddd98957c8-backup.hg (glob)
   $ hg tglog
-  @  7: 'D'
+  o  7: 'D'
   |
   o  6: 'C'
   |
-  | o  5: 'H'
+  | @  5: 'H'
   | |
   | | o  4: 'G'
   | |/|
@@ -360,7 +360,7 @@
   [255]
   $ hg rebase -r '2::8' -d 1 --keep
   $ hg tglog
-  @  13: 'I'
+  o  13: 'I'
   |
   o  12: 'H'
   |
@@ -401,7 +401,7 @@
   [255]
   $ hg rebase -r '3::8' -d 1 --keep
   $ hg tglog
-  @  12: 'I'
+  o  12: 'I'
   |
   o  11: 'H'
   |
@@ -440,7 +440,7 @@
   [255]
   $ hg rebase -r '3::7' -d 1 --keep
   $ hg tglog
-  @  11: 'H'
+  o  11: 'H'
   |
   o  10: 'G'
   |
@@ -477,7 +477,7 @@
   [255]
   $ hg rebase -r '3::(7+5)' -d 1 --keep
   $ hg tglog
-  @  13: 'H'
+  o  13: 'H'
   |
   o  12: 'G'
   |
@@ -517,7 +517,7 @@
   $ hg rebase -r '6::' -d 2
   saved backup bundle to $TESTTMP/ah5/.hg/strip-backup/3d8a618087a7-backup.hg (glob)
   $ hg tglog
-  @  8: 'I'
+  o  8: 'I'
   |
   o  7: 'H'
   |
@@ -547,7 +547,7 @@
   $ hg rebase -r '(4+6)::' -d 1
   saved backup bundle to $TESTTMP/ah6/.hg/strip-backup/3d8a618087a7-backup.hg (glob)
   $ hg tglog
-  @  8: 'I'
+  o  8: 'I'
   |
   o  7: 'H'
   |