[PATCH 25 of 25 RFC] shelve: no longer strip internal commit when using internal phase
Boris Feld
boris.feld at octobus.net
Thu Jun 7 10:11:24 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 be308025c42337fdd4a144ba7b09dee1d175b3fe
# Parent bdd0e592a83f124210517cd776f900a746946466
# EXP-Topic internal-phase
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r be308025c423
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 give much
better performance and is less traumatic for caches.
Test change 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 strip the internal changeset and be fine.
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -428,7 +428,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"""
@@ -641,8 +648,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)
@@ -735,8 +743,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
@@ -377,12 +377,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
@@ -425,10 +437,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
@@ -481,14 +494,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
@@ -548,7 +562,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
@@ -571,7 +585,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
@@ -608,16 +622,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
@@ -627,11 +641,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)
@@ -651,10 +665,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
@@ -780,13 +804,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
|/
@@ -802,6 +826,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
|
@@ -813,6 +853,8 @@ unshelve and conflicts with tracked and
|/
o 0 a test 1970-01-01 00:00 +0000
+#endif
+
$ hg st
M f
? f.orig
@@ -888,7 +930,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
@@ -897,7 +939,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)
@@ -911,13 +953,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
@@ -996,14 +1038,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
@@ -1170,24 +1212,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
@@ -1197,8 +1239,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
@@ -1214,25 +1256,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
@@ -1242,8 +1284,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 ..
@@ -1294,31 +1336,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