Mercurial > public > mercurial-scm > hg-stable
diff mercurial/exchange.py @ 34836:537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
The part we are using for pull is now used for push too. As we no longer use
pushkey, pushkey hooks are no longer triggered. This is an obvious backward
incompatible change. We could artificially trigger the pushkey hook within the
bundle2 part, but this seemed too hacky to me.
An option would be to disable by default this new mechanism for a couple of
versions to help people migrate to `txnclose-phase`. I took the liberal and
optimistic path to just turn it on by default directly.
.. bc::
Push no longer triggers a pushkey hook when updating phases. Use the new
`txnclose-phase` and `txnclose-phase` hooks instead.
(Applies when both server and client use version 4.4 or above).
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 20 Sep 2017 19:38:06 +0200 |
parents | c1e7ce11db9b |
children | 498697fe41f2 |
line wrap: on
line diff
--- a/mercurial/exchange.py Tue Oct 17 12:41:24 2017 -0700 +++ b/mercurial/exchange.py Wed Sep 20 19:38:06 2017 +0200 @@ -806,9 +806,26 @@ if 'phases' in pushop.stepsdone: return b2caps = bundle2.bundle2caps(pushop.remote) - if 'pushkey' in b2caps: + ui = pushop.repo.ui + + legacyphase = 'phases' in ui.configlist('devel', 'legacy.exchange') + haspushkey = 'pushkey' in b2caps + hasphaseheads = 'heads' in b2caps.get('phases', ()) + + if hasphaseheads and not legacyphase: + _pushb2phaseheads(pushop, bundler) + elif haspushkey: _pushb2phasespushkey(pushop, bundler) +def _pushb2phaseheads(pushop, bundler): + """push phase information through a bundle2 - binary part""" + pushop.stepsdone.add('phases') + if pushop.outdatedphases: + updates = [[] for p in phases.allphases] + updates[0].extend(h.node() for h in pushop.outdatedphases) + phasedata = phases.binaryencode(updates) + bundler.newpart('phase-heads', data=phasedata) + def _pushb2phasespushkey(pushop, bundler): """push phase information through a bundle2 - pushkey part""" pushop.stepsdone.add('phases')