[PATCH 2 of 2] context: introduce a "shared" property (similar to "immutable")

Idan Kamara idankk86 at gmail.com
Fri Feb 3 06:08:06 CST 2012


On Fri, Feb 3, 2012 at 12:36 PM, <pierre-yves.david at logilab.fr> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1327941097 -3600
> # Node ID 35a9121f3246e05b7a4b83564435d0e3fa346160
> # Parent  77bd9605c6da0d58b8f48fe8e5b56c24e34d3146
> context: introduce a "shared" property (similar to "immutable")
>
> This property is True if the changeset should be exchanged:
>

Shouldn't this be called "shareable" instead? "shared" only
tells if it's currently shared or not rather than "this cset
should not be shared".


>
> draft and public: ctx.shared() == True
> secret: ctx.shared() == False
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -126,10 +126,12 @@ class changectx(object):
>         return self._repo._phaserev[self._rev]
>     def phasestr(self):
>         return phases.phasenames[self.phase()]
>     def immutable(self):
>         return self._repo._phaserev[self._rev] <= phases.public
> +    def shared(self):
> +        return self._repo._phaserev[self._rev] <= phases.draft
>     def hidden(self):
>         return self._rev in self._repo.changelog.hiddenrevs
>
>     def parents(self):
>         """return contexts for each parent changeset"""
> diff --git a/mercurial/discovery.py b/mercurial/discovery.py
> --- a/mercurial/discovery.py
> +++ b/mercurial/discovery.py
> @@ -116,11 +116,11 @@ def findcommonoutgoing(repo, other, only
>         sets = repo.changelog.findcommonmissing(og.commonheads, onlyheads)
>         og._common, allmissing = sets
>         og._missing = missing = []
>         og.excluded = excluded = []
>         for node in allmissing:
> -            if repo[node].phase() >= phases.secret:
> +            if not repo[node].shared():
>                 excluded.append(node)
>             else:
>                 missing.append(node)
>         if excluded:
>             # update missing heads
> diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
> --- a/mercurial/wireproto.py
> +++ b/mercurial/wireproto.py
> @@ -471,11 +471,11 @@ def listkeys(repo, proto, namespace):
>
>  def lookup(repo, proto, key):
>     try:
>         k = encoding.tolocal(key)
>         c = repo[k]
> -        if c.phase() == phases.secret:
> +        if not c.shared():
>             raise error.RepoLookupError(_("unknown revision '%s'") % k)
>         r = c.hex()
>         success = 1
>     except Exception, inst:
>         r = str(inst)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120203/7cb4fc84/attachment.html>


More information about the Mercurial-devel mailing list