[PATCH 3 of 6 REPHASE-VIEW] phases: add basic pushkey support

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Wed Oct 26 12:56:27 UTC 2011


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1319632430 -7200
# Node ID 2e3bd3b14829703f74299257f466b6f16897bd3d
# Parent  528fa15037b1386f4cd09eedca80f43f0c41d1bf
phases: add basic pushkey support

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -65,5 +65,37 @@ def moveboundary(repo, phase, nodes):
                 moveboundary(repo, phase + 1, nodes) # cascading
                 # invalidate cache (we probably could be smarter here
                 if '_phaserev' in vars(repo):
                     del repo._phaserev
                 repo._dirtyphases = True
+
+def listphaseroots(repo):
+    """List phases root for serialisation over pushkey"""
+    if repo.ui.configbool('phases', 'publish', True):
+        return {}
+    else:
+        keys = {}
+        # reminder for rewriting when adding secret
+        assert len(trackedphases) ==1
+        assert len(allphases) == 2
+        for phase in trackedphases[::-1]:
+            for root in repo.set('roots(not ::%ln)', repo._phaseheads[phase]):
+                keys[root.hex()] = phase+1
+    return keys
+def pushphaseroot(repo, key, oldphase, newphase):
+    """List phases heads for serialisation over pushkey"""
+    raise NotImplementedError('No consumer for this yet')
+
+
+
+def listphaseheads(repo):
+    """List phases heads for serialisation over pushkey"""
+    raise NotImplementedError('No consumer for this yet')
+
+def pushphasehead(repo, key, oldphase, newphase):
+    """List phases root for serialisation over pushkey"""
+    lock = repo.lock()
+    try:
+        moveboundary(repo, newphase, [bin(key)])
+        return 1
+    finally:
+        lock.release()
diff --git a/mercurial/pushkey.py b/mercurial/pushkey.py
--- a/mercurial/pushkey.py
+++ b/mercurial/pushkey.py
@@ -3,20 +3,23 @@
 # Copyright 2010 Matt Mackall <mpm at selenic.com>
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import bookmarks
+import bookmarks, phases
 
 def _nslist(repo):
     n = {}
     for k in _namespaces:
         n[k] = ""
     return n
 
 _namespaces = {"namespaces": (lambda *x: False, _nslist),
-               "bookmarks": (bookmarks.pushbookmark, bookmarks.listbookmarks)}
+               "bookmarks": (bookmarks.pushbookmark, bookmarks.listbookmarks),
+               "phaseroots": (phases.pushphaseroot, phases.listphaseroots),
+               "phaseheads": (phases.pushphasehead, phases.listphaseheads),
+              }
 
 def register(namespace, pushkey, listkeys):
     _namespaces[namespace] = (pushkey, listkeys)
 
 def _get(namespace):



More information about the Mercurial-devel mailing list