[PATCH 3 of 9 RFC] phases: add a binary version of listphases

Yuya Nishihara yuya at tcha.org
Tue Aug 16 09:59:15 EDT 2016


On Sun, 14 Aug 2016 14:10:02 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1471204404 25200
> #      Sun Aug 14 12:53:24 2016 -0700
> # Node ID cab15fd54ee60cc067920454544586cc4aa03d8e
> # Parent  d06d34dd880f58ecef32d96baec16508497d5639
> phases: add a binary version of listphases

> --- a/mercurial/phases.py
> +++ b/mercurial/phases.py
> @@ -369,22 +369,28 @@ def retractboundary(repo, tr, targetphas
>      This function move boundary *backward* this means that all nodes
>      are set in the target phase or kept in a *higher* phase.
>  
>      Simplify boundary to contains phase roots only."""
>      phcache = repo._phasecache.copy()
>      phcache.retractboundary(repo, tr, targetphase, nodes)
>      repo._phasecache.replace(phcache)
>  
> -def listphases(repo):
> -    """List phases root for serialization over pushkey"""
> +def listphasesraw(repo):
> +    """Obtain phases pushkey keys.
> +
> +    Keys are raw binary nodes. Values are '1' to indicate a draft root.
> +
> +    The special key ``publishing`` with value of ``True`` indicates that the
> +    repo is publishing.
> +    """
>      keys = {}
>      value = '%i' % draft
>      for root in repo._phasecache.phaseroots[draft]:
> -        keys[hex(root)] = value
> +        keys[root] = value
>  
>      if repo.publishing():
>          # Add an extra data to let remote know we are a publishing

I slightly prefer a specially-crafted key over "publishing" string in binary
format, that will never ever conflicts with any possible hash values. (even
I know sha1(x) != "publishing" is guaranteed.)


More information about the Mercurial-devel mailing list