Mercurial > hg
changeset 40417:49c7b701fdc2 stable
phase: add an archived phase
This phase allows for hidden changesets in the "user space". It differs from
the "internal" phase which is intended for internal by-product only. There
have been discussions at the 4.8 sprint to use such phase to speedup cleanup
after history rewriting operation.
Shipping it in the same release as the 'internal-phase' groups the associated
`requires` entry. The important bit is to have support for this phase in the
earliest version of mercurial possible. Adding the UI to manipulate this new
phase later seems fine.
The current plan for archived usage and user interface are as follow. On a
repository with internal-phase on and evolution off:
* history rewriting command set rewritten changeset in the archived phase.
(This mean updating the cleanupnodes method).
* keep `hg unbundle .hg/strip-backup/X.hg` as a way to restore changeset for
now
(backup bundle need to contains phase data)
* [maybe] add a `hg strip --soft` advance flag
(a light way to expose the feature without getting in the way of a better
UI)
Mercurial 4.8 freeze is too close to get the above in by then.
We don't introduce a new repository `requirement` as we reuse the one
introduced with the 'archived' phase during the 4.8 cycle.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 17 Oct 2018 14:47:01 +0200 |
parents | 36ba91e06948 |
children | 89703e6151e7 |
files | mercurial/phases.py tests/test-phases.t |
diffstat | 2 files changed, 53 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/phases.py Tue Oct 23 20:46:21 2018 +0900 +++ b/mercurial/phases.py Wed Oct 17 14:47:01 2018 +0200 @@ -129,11 +129,13 @@ # record phase index public, draft, secret = range(3) internal = INTERNAL_FLAG | HIDEABLE_FLAG +archived = HIDEABLE_FLAG allphases = range(internal + 1) trackedphases = allphases[1:] # record phase names phasenames = [None] * len(allphases) phasenames[:3] = ['public', 'draft', 'secret'] +phasenames[archived] = 'archived' phasenames[internal] = 'internal' # record phase property mutablephases = tuple(allphases[1:]) @@ -446,8 +448,9 @@ def _retractboundary(self, repo, tr, targetphase, nodes): # Be careful to preserve shallow-copied values: do not update # phaseroots values, replace them. - if targetphase == internal and not supportinternal(repo): - msg = 'this repository does not support the internal phase' + if targetphase in (archived, internal) and not supportinternal(repo): + name = phasenames[targetphase] + msg = 'this repository does not support the %s phase' % name raise error.ProgrammingError(msg) repo = repo.unfiltered()
--- a/tests/test-phases.t Tue Oct 23 20:46:21 2018 +0900 +++ b/tests/test-phases.t Wed Oct 17 14:47:01 2018 +0200 @@ -850,6 +850,10 @@ ** ProgrammingError: this repository does not support the internal phase raise error.ProgrammingError(msg) mercurial.error.ProgrammingError: this repository does not support the internal phase + $ hg --config "phases.new-commit=archived" commit -m "my test archived commit" 2>&1 | grep ProgrammingError + ** ProgrammingError: this repository does not support the archived phase + raise error.ProgrammingError(msg) + mercurial.error.ProgrammingError: this repository does not support the archived phase $ cd .. @@ -878,7 +882,8 @@ test-debug-phase: new rev 1: x -> 96 test-hook-close-phase: c01c42dffc7f81223397e99652a0703f83e1c5ea: -> internal -Usual visibility rules apply when working directory parents +The changeset is a working parent descendant. +Per the usual visibility rules, it is made visible. $ hg log -G -l 3 @ changeset: 1:c01c42dffc7f @@ -904,3 +909,45 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: A + +Test for archived phase +----------------------- + +Commit an archived changesets + + $ echo B > B + $ hg add B + $ hg status + A B + $ hg --config "phases.new-commit=archived" commit -m "my test archived commit" + test-debug-phase: new rev 2: x -> 32 + test-hook-close-phase: 8df5997c3361518f733d1ae67cd3adb9b0eaf125: -> archived + +The changeset is a working parent descendant. +Per the usual visibility rules, it is made visible. + + $ hg log -G -l 3 + @ changeset: 2:8df5997c3361 + | tag: tip + | parent: 0:4a2df7238c3b + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: my test archived commit + | + o changeset: 0:4a2df7238c3b + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: A + + +Commit is hidden as expected + + $ hg up 0 + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ hg log -G + @ changeset: 0:4a2df7238c3b + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: A +