# HG changeset patch # User Boris Feld # Date 1528245106 -7200 # Node ID 52dfa1eb0ad4f6141849a88b8389f5e08c44cf0b # Parent f803bcb902ad8d4c14cc8e9a7e437c22ea5dc413 shelve: no longer strip internal commit when using internal phase When the internal phase is used, the internal commits we create during shelve will be automatically hidden, and we don't need to strip them. Avoiding strips gives much better performances and is less traumatic for caches. Test changes are all related to revision numbers increasing more quickly since we avoid stripping. At the end of `test-shelve.t` we now need manually strip the shelve-commit in addition to the x.shelve file deletion. This emulates a preexisting shelve after a repository upgrade. Note: The hidden internal commits confuses rebase a bit as shown by a new test added. This will happen when the user have shelve commits on top of a changeset to be rebased. We'll fix this in the next commit. As we still use a backup bundle, rebase can just strip the internal changesets and be fine. diff -r f803bcb902ad -r 52dfa1eb0ad4 hgext/shelve.py --- a/hgext/shelve.py Wed Sep 19 12:07:52 2018 -0700 +++ b/hgext/shelve.py Wed Jun 06 02:31:46 2018 +0200 @@ -434,7 +434,14 @@ repo[None].add(s.unknown) def _finishshelve(repo): - _aborttransaction(repo) + if phases.supportinternal(repo): + backupname = 'dirstate.shelve' + tr = repo.currenttransaction() + repo.dirstate.savebackup(tr, backupname) + tr.close() + repo.dirstate.restorebackup(None, backupname) + else: + _aborttransaction(repo) def createcmd(ui, repo, pats, opts): """subcommand that creates a new shelve""" @@ -652,8 +659,9 @@ rebase.clearstatus(repo) mergefiles(ui, repo, state.wctx, state.pendingctx) - repair.strip(ui, repo, state.nodestoremove, backup=False, - topic='shelve') + if not phases.supportinternal(repo): + repair.strip(ui, repo, state.nodestoremove, backup=False, + topic='shelve') finally: shelvedstate.clear(repo) ui.warn(_("unshelve of '%s' aborted\n") % state.name) @@ -746,8 +754,9 @@ mergefiles(ui, repo, state.wctx, shelvectx) restorebranch(ui, repo, state.branchtorestore) - repair.strip(ui, repo, state.nodestoremove, backup=False, - topic='shelve') + if not phases.supportinternal(repo): + repair.strip(ui, repo, state.nodestoremove, backup=False, + topic='shelve') _restoreactivebookmark(repo, state.activebookmark) shelvedstate.clear(repo) unshelvecleanup(ui, repo, state.name, opts) diff -r f803bcb902ad -r 52dfa1eb0ad4 tests/test-shelve.t --- a/tests/test-shelve.t Wed Sep 19 12:07:52 2018 -0700 +++ b/tests/test-shelve.t Wed Jun 06 02:31:46 2018 +0200 @@ -380,12 +380,24 @@ ensure that we have a merge with unresolved conflicts +#if phasebased + $ hg heads -q --template '{rev}\n' + 8 + 5 + $ hg parents -q --template '{rev}\n' + 8 + 5 +#endif + +#if stripbased $ hg heads -q --template '{rev}\n' 5 4 $ hg parents -q --template '{rev}\n' 4 5 +#endif + $ hg status M a/a M b.rename/b @@ -428,10 +440,11 @@ $ hg unshelve -a unshelve of 'default' aborted $ hg heads -q - 3:2e69b451d1ea + [37]:2e69b451d1ea (re) $ hg parents - changeset: 3:2e69b451d1ea + changeset: [37]:2e69b451d1ea (re) tag: tip + parent: 3:509104101065 (?) user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: second @@ -484,14 +497,15 @@ ensure the repo is as we hope $ hg parents - changeset: 3:2e69b451d1ea + changeset: [37]:2e69b451d1ea (re) tag: tip + parent: 3:509104101065 (?) user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: second $ hg heads -q - 3:2e69b451d1ea + [37]:2e69b451d1ea (re) $ hg status -C A b.rename/b @@ -551,7 +565,7 @@ rebasing shelved changes merging a/a $ hg parents -q - 4:33f7f61e6c5e + (4|13):33f7f61e6c5e (re) $ hg shelve -l default (*)* changes to: second (glob) $ hg status @@ -574,7 +588,7 @@ merging a/a note: unshelved changes already existed in the working copy $ hg parents -q - 4:33f7f61e6c5e + (4|13):33f7f61e6c5e (re) $ hg shelve -l $ hg status A foo/foo @@ -611,16 +625,16 @@ $ hg bookmark test $ hg bookmark - * test 4:33f7f61e6c5e + \* test (4|13):33f7f61e6c5e (re) $ hg shelve shelved as test 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg bookmark - * test 4:33f7f61e6c5e + \* test (4|13):33f7f61e6c5e (re) $ hg unshelve unshelving change 'test' $ hg bookmark - * test 4:33f7f61e6c5e + \* test (4|13):33f7f61e6c5e (re) shelve should still work even if mq is disabled @@ -630,11 +644,11 @@ $ hg --config extensions.mq=! shelve --list test (*)* changes to: create conflict (glob) $ hg bookmark - * test 4:33f7f61e6c5e + \* test (4|13):33f7f61e6c5e (re) $ hg --config extensions.mq=! unshelve unshelving change 'test' $ hg bookmark - * test 4:33f7f61e6c5e + \* test (4|13):33f7f61e6c5e (re) shelve should leave dirstate clean (issue4055) @@ -654,10 +668,20 @@ $ hg shelve shelved as default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + +#if phasebased + $ hg rebase -d 6c103be8f4e4 --config extensions.rebase= + rebasing 2:323bfa07f744 "xyz" + merging x + warning: orphaned descendants detected, not stripping 323bfa07f744 (?) +#endif + +#if stripbased $ hg rebase -d 6c103be8f4e4 --config extensions.rebase= rebasing 2:323bfa07f744 "xyz" (tip) merging x saved backup bundle to $TESTTMP/shelverebase/.hg/strip-backup/323bfa07f744-78114325-rebase.hg +#endif $ hg unshelve unshelving change 'default' rebasing shelved changes @@ -783,13 +807,13 @@ shelved as default 0 files updated, 0 files merged, 1 files removed, 0 files unresolved #if repobundlerepo - $ hg log -G --template '{rev} {desc|firstline} {author}' -R bundle://.hg/shelved/default.hg -r 'bundle()' - o 4 changes to: commit stuff shelve@localhost + $ hg log -G --template '{rev} {desc|firstline} {author}' -R bundle://.hg/shelved/default.hg -r 'bundle()' --hidden + o [48] changes to: commit stuff shelve@localhost (re) | ~ #endif $ hg log -G --template '{rev} {desc|firstline} {author}' - @ 3 commit stuff test + @ [37] commit stuff test (re) | | o 2 c test |/ @@ -805,6 +829,22 @@ warning: conflicts while merging f! (edit, then use 'hg resolve --mark') unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') [1] + +#if phasebased + $ hg log -G --template '{rev} {desc|firstline} {author} {date|isodate}' + @ 9 pending changes temporary commit shelve@localhost 2004-01-10 13:37 +0000 + | + | @ 8 changes to: commit stuff shelve@localhost 1970-01-01 00:00 +0000 + |/ + o 7 commit stuff test 1970-01-01 00:00 +0000 + | + | o 2 c test 1970-01-01 00:00 +0000 + |/ + o 0 a test 1970-01-01 00:00 +0000 + +#endif + +#if stripbased $ hg log -G --template '{rev} {desc|firstline} {author} {date|isodate}' @ 5 changes to: commit stuff shelve@localhost 1970-01-01 00:00 +0000 | @@ -816,6 +856,8 @@ |/ o 0 a test 1970-01-01 00:00 +0000 +#endif + $ hg st M f ? f.orig @@ -891,7 +933,7 @@ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (activating bookmark test) $ hg bookmark - * test 4:33f7f61e6c5e + \* test (4|13):33f7f61e6c5e (re) $ hg unshelve unshelving change 'default' rebasing shelved changes @@ -900,7 +942,7 @@ unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') [1] $ hg bookmark - test 4:33f7f61e6c5e + test (4|13):33f7f61e6c5e (re) Test that resolving all conflicts in one direction (so that the rebase is a no-op), works (issue4398) @@ -914,13 +956,13 @@ note: unshelved changes already existed in the working copy unshelve of 'default' complete $ hg bookmark - * test 4:33f7f61e6c5e + \* test (4|13):33f7f61e6c5e (re) $ hg diff $ hg status ? a/a.orig ? foo/foo $ hg summary - parent: 4:33f7f61e6c5e tip + parent: (4|13):33f7f61e6c5e tip (re) create conflict branch: default bookmarks: *test @@ -999,14 +1041,14 @@ M a/a ? foo/foo $ hg bookmark - * test 4:33f7f61e6c5e + \* test (4|13):33f7f61e6c5e (re) $ hg unshelve unshelving change 'test' temporarily committing pending changes (restore with 'hg unshelve --abort') rebasing shelved changes merging a/a $ hg bookmark - * test 4:33f7f61e6c5e + \* test (4|13):33f7f61e6c5e (re) $ cat a/a a a @@ -1198,24 +1240,24 @@ $ sh $TESTTMP/checkvisibility.sh before-unshelving ==== before-unshelving: - VISIBLE 5:703117a2acfb - ACTUAL 5:703117a2acfb + VISIBLE (5|19):703117a2acfb (re) + ACTUAL (5|19):703117a2acfb (re) ==== $ hg unshelve --keep default temporarily committing pending changes (restore with 'hg unshelve --abort') rebasing shelved changes ==== preupdate: - VISIBLE 6:54c00d20fb3f - ACTUAL 5:703117a2acfb + VISIBLE (6|20):54c00d20fb3f (re) + ACTUAL (5|19):703117a2acfb (re) ==== ==== preupdate: - VISIBLE 8:8efe6f7537dc - ACTUAL 5:703117a2acfb + VISIBLE (8|21):8efe6f7537dc (re) + ACTUAL (5|19):703117a2acfb (re) ==== ==== preupdate: - VISIBLE 6:54c00d20fb3f - ACTUAL 5:703117a2acfb + VISIBLE (6|20):54c00d20fb3f (re) + ACTUAL (5|19):703117a2acfb (re) ==== $ cat >> .hg/hgrc <> .hg/hgrc < EOF $ hg bookmarks -R repo - test 4:33f7f61e6c5e + test (4|13):33f7f61e6c5e (re) $ hg share -B repo share updating working directory 6 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd share $ hg bookmarks - test 4:33f7f61e6c5e + test (4|13):33f7f61e6c5e (re) $ hg bookmarks foo $ hg bookmarks - * foo 5:703117a2acfb - test 4:33f7f61e6c5e + \* foo (5|19):703117a2acfb (re) + test (4|13):33f7f61e6c5e (re) $ echo x >> x $ hg shelve shelved as foo 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg bookmarks - * foo 5:703117a2acfb - test 4:33f7f61e6c5e + \* foo (5|19):703117a2acfb (re) + test (4|13):33f7f61e6c5e (re) $ hg unshelve unshelving change 'foo' $ hg bookmarks - * foo 5:703117a2acfb - test 4:33f7f61e6c5e + \* foo (5|19):703117a2acfb (re) + test (4|13):33f7f61e6c5e (re) $ cd .. @@ -1805,11 +1847,16 @@ $ hg unshelve --continue unshelve of 'ashelve' complete +#if phasebased + Unshelve without .shelve metadata: $ hg shelve shelved as default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ cat .hg/shelved/default.shelve + node=82e0cb9893247d12667017593ce1e5655860f1ac + $ hg strip --hidden --rev 82e0cb989324 --no-backup $ rm .hg/shelved/default.shelve $ echo 3 > a $ hg unshelve @@ -1823,4 +1870,6 @@ $ cat .hg/shelved/default.shelve node=82e0cb9893247d12667017593ce1e5655860f1ac +#endif + $ cd ..