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

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Fri Feb 3 04:36:09 CST 2012


# 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:

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