[PATCH 10 of 10] shelve: no longer strip internal commit when using internal phase
Boris Feld
boris.feld at octobus.net
Wed Aug 29 12:30:58 EDT 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 18e2c4986d32aed2f10948277ba5dc1133f19f00
# Parent ccb9572516145a1b6f11a8d199c4a7da4774898b
# EXP-Topic internal-phase.shelve
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 18e2c4986d32
shelve: no longer strip internal commit when using internal phase
If the internal phase is available, the internal commit we create will be
automatically hidden and we don't need to strip them. Avoiding strip gives
much better performances and is less traumatic for caches.
Test changes are all related to revision number increasing more quickly since
we avoid stripping.
note: The hidden internal commit 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.
As we still use a backup bundle, we could probably just let rebase strip the
internal changeset and be fine. The case will be improved in a later series.
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -432,7 +432,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"""
@@ -650,8 +657,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)
@@ -744,8 +752,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 ..
More information about the Mercurial-devel
mailing list