[PATCH STABLE STABLE V2] phase: add an archived phase
Augie Fackler
raf at durin42.com
Tue Oct 23 12:59:26 EDT 2018
queued, thanks
> On Oct 23, 2018, at 11:56, Boris Feld <boris.feld at octobus.net> wrote:
>
> # HG changeset patch
> # User Boris Feld <boris.feld at octobus.net>
> # Date 1539780421 -7200
> # Wed Oct 17 14:47:01 2018 +0200
> # Branch stable
> # Node ID 14ea5d230fdd42269ac04658e357684531c00736
> # Parent 36ba91e069486f8283199f92d6d3d19b8580e85c
> # EXP-Topic archived-phase
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 14ea5d230fdd
> 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.
>
> diff --git a/mercurial/phases.py b/mercurial/phases.py
> --- a/mercurial/phases.py
> +++ b/mercurial/phases.py
> @@ -129,11 +129,13 @@ HIDEABLE_FLAG = 32 # Phases that are hid
> # 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 @@ class phasecache(object):
> 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()
> diff --git a/tests/test-phases.t b/tests/test-phases.t
> --- a/tests/test-phases.t
> +++ b/tests/test-phases.t
> @@ -850,6 +850,10 @@ Check we deny its usage on older reposit
> ** 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 @@ Commit an internal changesets
> 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 @@ Commit is hidden as expected
> 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
> +
More information about the Mercurial-devel
mailing list