[PATCH 1 of 2] shelve: no longer strip internal commit when using internal phase
Boris Feld
boris.feld at octobus.net
Fri Sep 21 11:49:50 UTC 2018
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1528245106 -7200
# Wed Jun 06 02:31:46 2018 +0200
# Node ID e47e45bd5fd68bec6e3bb9aa159d1ca9883117f3
# Parent 65b39c556c6dcf06e19d59db33c0ce65fb9b3618
# EXP-Topic internal-phase.shelve
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e47e45bd5fd6
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 --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -434,7 +434,14 @@ def _includeunknownfiles(repo, pats, opt
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 @@ def unshelveabort(ui, repo, state, opts)
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 @@ def unshelvecontinue(ui, repo, state, op
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 --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -380,12 +380,24 @@ force a conflicted merge to occur
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 @@ abort the unshelve and be happy
$ 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 @@ attempt to continue
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 @@ if we resolve a conflict while unshelvin
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 @@ if we resolve a conflict while unshelvin
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 @@ test bookmarks
$ 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 @@ shelve should still work even if mq is d
$ 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 @@ shelve should leave dirstate clean (issu
$ 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 @@ unshelve and conflicts with tracked and
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 at 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 at 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 @@ unshelve and conflicts with tracked and
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 at localhost 2004-01-10 13:37 +0000
+ |
+ | @ 8 changes to: commit stuff shelve at 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 at localhost 1970-01-01 00:00 +0000
|
@@ -816,6 +856,8 @@ unshelve and conflicts with tracked and
|/
o 0 a test 1970-01-01 00:00 +0000
+#endif
+
$ hg st
M f
? f.orig
@@ -891,7 +933,7 @@ Recreate some conflict again
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 @@ Recreate some conflict again
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 @@ is a no-op), works (issue4398)
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 @@ Test interactive shelve
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 @@ Test visibility of in-memory changes ins
$ 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 <<EOF
@@ -1225,8 +1267,8 @@ Test visibility of in-memory changes ins
$ sh $TESTTMP/checkvisibility.sh after-unshelving
==== after-unshelving:
- VISIBLE 5:703117a2acfb
- ACTUAL 5:703117a2acfb
+ VISIBLE (5|19):703117a2acfb (re)
+ ACTUAL (5|19):703117a2acfb (re)
====
== test visibility to external update hook
@@ -1242,25 +1284,25 @@ Test visibility of in-memory changes ins
$ 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
==== update:
- VISIBLE 6:54c00d20fb3f
- VISIBLE 7:492ed9d705e5
- ACTUAL 5:703117a2acfb
+ VISIBLE (6|20):54c00d20fb3f (re)
+ VISIBLE 1?7:492ed9d705e5 (re)
+ ACTUAL (5|19):703117a2acfb (re)
====
==== update:
- VISIBLE 6:54c00d20fb3f
- ACTUAL 5:703117a2acfb
+ VISIBLE (6|20):54c00d20fb3f (re)
+ ACTUAL (5|19):703117a2acfb (re)
====
==== update:
- VISIBLE 5:703117a2acfb
- ACTUAL 5:703117a2acfb
+ VISIBLE (5|19):703117a2acfb (re)
+ ACTUAL (5|19):703117a2acfb (re)
====
$ cat >> .hg/hgrc <<EOF
@@ -1270,8 +1312,8 @@ Test visibility of in-memory changes ins
$ sh $TESTTMP/checkvisibility.sh after-unshelving
==== after-unshelving:
- VISIBLE 5:703117a2acfb
- ACTUAL 5:703117a2acfb
+ VISIBLE (5|19):703117a2acfb (re)
+ ACTUAL (5|19):703117a2acfb (re)
====
$ cd ..
@@ -1322,31 +1364,31 @@ Keep active bookmark while (un)shelving
> 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 @@ mercurial does not crash
$ 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
@@ -1824,3 +1871,5 @@ Unshelve without .shelve metadata:
node=82e0cb9893247d12667017593ce1e5655860f1ac
$ cd ..
+
+#endif
More information about the Mercurial-devel
mailing list