[PATCH 3 of 6] phases: add basic pushkey support
Matt Mackall
mpm at selenic.com
Tue Dec 13 22:51:35 UTC 2011
On Tue, 2011-12-13 at 00:52 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1323686995 -3600
> # Node ID 1bd92cc9496a217c06662431a2f3e3e8e0780a2a
> # Parent ac112bc18cc7ad1ac3ceed52e06c44b5fdf274d7
> phases: add basic pushkey support
>
> diff --git a/mercurial/phases.py b/mercurial/phases.py
> --- a/mercurial/phases.py
> +++ b/mercurial/phases.py
> @@ -100,3 +100,36 @@
> del repo._phaserev
> repo._dirtyphases = True
>
> +
> +def listphaseroots(repo):
> + """List phases root for serialisation over pushkey"""
> + keys = {}
> + for phase in trackedphases:
> + for root in repo._phaseroots[phase]:
> + keys[hex(root)] = '%i' % phase
> + if repo.ui.configbool('phases', 'publish', True):
> + # Add an extra data to let remote know we are a publishing repo.
> + # Publishing repo can't just pretend they are old repo. When pushing
> + # to a publishing repo, the client still need to push phase boundary
Why is that? If the client sends a changegroup, the server can advance
the phases on its own, right?
If the client /does not/ send a changegroup, does it have any business
moving phases on the server? That's not immediately obvious.
> + # We are using nullid for this as nullid is never be used as phase root.
> + # having a nullid entry in phase roots mean you are a publishing repo
> + keys[hex(nullid)] = '0'
The key can be any string, why use something from the node space? How
about:
keys['publishing'] = 'true'
> + 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')
I think we can drop these and do:
def listphases():
return hash of phase roots
def pushphases(node, old, new):
if phase(node) == old and new < old:
move phase of node (and ancestors) to new
Abstractly, this is "get all phase info" and "manipulate a node phase"
which is a complete and proper set. No need to make a fuss about roots
vs heads here.
> +def pushphasehead(repo, key, oldphase, newphase):
> + """List phases root for serialisation over pushkey"""
> + lock = repo.lock()
> + try:
> + advanceboundary(repo, int(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
> @@ -5,7 +5,7 @@
> # 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 = {}
> @@ -14,7 +14,10 @@
> 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)
> diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
> --- a/tests/test-bookmarks-pushpull.t
> +++ b/tests/test-bookmarks-pushpull.t
> @@ -34,6 +34,8 @@
> Y 0:4e3505fd9583
> $ hg debugpushkey ../a namespaces
> bookmarks
> + phaseheads
> + phaseroots
> namespaces
> $ hg debugpushkey ../a bookmarks
> Y 4e3505fd95835d721066b76e75dbb8cc554d7f77
> @@ -151,6 +153,8 @@
>
> $ hg debugpushkey http://localhost:$HGPORT/ namespaces
> bookmarks
> + phaseheads
> + phaseroots
> namespaces
> $ hg debugpushkey http://localhost:$HGPORT/ bookmarks
> Y 4e3505fd95835d721066b76e75dbb8cc554d7f77
> diff --git a/tests/test-ssh.t b/tests/test-ssh.t
> --- a/tests/test-ssh.t
> +++ b/tests/test-ssh.t
> @@ -165,6 +165,8 @@
> $ cd ../local
> $ hg debugpushkey --config ui.ssh="python $TESTDIR/dummyssh" ssh://user@dummy/remote namespaces
> bookmarks
> + phaseheads
> + phaseroots
> namespaces
> $ hg book foo -r 0
> $ hg out -B
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list