[PATCH 02 of 10] context: introduce a "shared" property (similar to "immutable")
pierre-yves.david at logilab.fr
pierre-yves.david at logilab.fr
Mon Jan 30 10:49:36 CST 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1327941097 -3600
# Branch stable
# Node ID 087a920ef41a7dc3870af4a458cebd2f219f72f5
# Parent 1fa9f6a24edb78d24d8f7aaa4a214e6e67f8ce4f
context: introduce a "shared" property (similar to "immutable")
This property is True if the changeset should be exchanged:
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)
More information about the Mercurial-devel
mailing list