diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -359,6 +359,13 @@ def rebase(ui, repo, **opts): # 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: diff --git a/tests/test-rebase-bookmarks.t b/tests/test-rebase-bookmarks.t --- a/tests/test-rebase-bookmarks.t +++ b/tests/test-rebase-bookmarks.t @@ -119,9 +119,9 @@ Keep active bookmark on the correct chan 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 @@ Keep active bookmark on the correct chan 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' diff --git a/tests/test-rebase-cache.t b/tests/test-rebase-cache.t --- a/tests/test-rebase-cache.t +++ b/tests/test-rebase-cache.t @@ -121,11 +121,11 @@ Rebase part of branch2 (5-6) onto branch 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 | diff --git a/tests/test-rebase-check-restore.t b/tests/test-rebase-check-restore.t --- a/tests/test-rebase-check-restore.t +++ b/tests/test-rebase-check-restore.t @@ -80,11 +80,11 @@ Solve the conflict and go on: $ 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' | | 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 @@ -57,11 +57,11 @@ Rebasing B onto H and collapsing changes 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 @@ Rebasing E onto H: 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 @@ Rebasing G onto H with custom message: 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 @@ Rebase and collapse - E onto H: 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 @@ Rebase and collapse - E onto I: 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 @@ Rebase and collapse - B onto F: 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 @@ Test collapsing changes that add then re $ 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 diff --git a/tests/test-rebase-detach.t b/tests/test-rebase-detach.t --- a/tests/test-rebase-detach.t +++ b/tests/test-rebase-detach.t @@ -52,9 +52,9 @@ Rebasing D onto H detaching from C: 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 @@ Rebasing C onto H detaching from B: 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 @@ Rebasing B onto H using detach (same as 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 @@ Rebasing C onto H detaching from B and c 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 @@ Rebasing across null as ancestor 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 @@ Rebasing across null as ancestor $ 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 @@ Verify that target is not selected as ex 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' |/| diff --git a/tests/test-rebase-interruptions.t b/tests/test-rebase-interruptions.t --- a/tests/test-rebase-interruptions.t +++ b/tests/test-rebase-interruptions.t @@ -110,13 +110,13 @@ Solve the conflict and go on: 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' | | diff --git a/tests/test-rebase-named-branches.t b/tests/test-rebase-named-branches.t --- a/tests/test-rebase-named-branches.t +++ b/tests/test-rebase-named-branches.t @@ -147,7 +147,7 @@ Branch name containing a dash (issue3181 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 @@ Branch name containing a dash (issue3181 |/| 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 @@ Branch name containing a dash (issue3181 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 @@ Branch name containing a dash (issue3181 | | | o 1: 'B' |/ - o 0: 'A' + @ 0: 'A' Rebasing descendant onto ancestor across different named branches @@ -196,7 +196,7 @@ Rebasing descendant onto ancestor across 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 @@ Rebasing descendant onto ancestor across | | | o 1: 'E' |/ - o 0: 'A' + @ 0: 'A' $ hg rebase -s 4 -d 5 abort: source is ancestor of destination @@ -222,7 +222,7 @@ Rebasing descendant onto ancestor across 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 @@ Rebasing descendant onto ancestor across | | | o 1: 'E' |/ - o 0: 'A' + @ 0: 'A' $ cd .. 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 @@ -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' 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 @@ -126,9 +126,9 @@ set. 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 @@ set. 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 @@ More complex case were part of the rebas 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 @@ collapse rebase $ 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 @@ collapse rebase 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 @@ not be rebased. $ 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 @@ not be rebased. 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 @@ Test that rewriting leaving instability 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 @@ Test that rewriting leaving instability | | | x 8:e273c5e7d2d2 C | | - o | 7:02de42196ebe H + @ | 7:02de42196ebe H | | | o 6:eea13746799a G |/| @@ -381,11 +381,11 @@ Test multiple root handling $ 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 | | diff --git a/tests/test-rebase-parameters.t b/tests/test-rebase-parameters.t --- a/tests/test-rebase-parameters.t +++ b/tests/test-rebase-parameters.t @@ -197,11 +197,11 @@ Specify only source (from 2 onto 8): 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 @@ Specify only base (from 1 onto 8): 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 @@ Specify source and dest (from 2 onto 7): 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 @@ Specify base and dest (from 1 onto 7): 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 @@ Specify only revs (from 2 onto 8) 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' | diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t --- a/tests/test-rebase-scenario-global.t +++ b/tests/test-rebase-scenario-global.t @@ -52,9 +52,9 @@ D onto H - simple rebase: 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 @@ D onto F - intermediate point: 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 @@ E onto H - skip of G: 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 @@ G onto H - merged revision having a pare 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 @@ C onto A - rebase onto an ancestor: $ 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 @@ Source on have two descendant heads but [255] $ hg rebase -r '2::8' -d 1 --keep $ hg tglog - @ 13: 'I' + o 13: 'I' | o 12: 'H' | @@ -401,7 +401,7 @@ Base on have one descendant heads we ask [255] $ hg rebase -r '3::8' -d 1 --keep $ hg tglog - @ 12: 'I' + o 12: 'I' | o 11: 'H' | @@ -440,7 +440,7 @@ rebase subset [255] $ hg rebase -r '3::7' -d 1 --keep $ hg tglog - @ 11: 'H' + o 11: 'H' | o 10: 'G' | @@ -477,7 +477,7 @@ rebase subset with multiple head [255] $ hg rebase -r '3::(7+5)' -d 1 --keep $ hg tglog - @ 13: 'H' + o 13: 'H' | o 12: 'G' | @@ -517,7 +517,7 @@ rebase on ancestor with revset $ 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 @@ We would expect heads are I, F if it was $ 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' |