# HG changeset patch
# User Boris Feld
# Date 1505929086 -7200
# Wed Sep 20 19:38:06 2017 +0200
# Node ID 0505e8dfaf0f62b3532699958ce0d6d62bf1bb0c
# Parent 44c4ed4ad0326c6a8ab09b7a27c40a45e67ec1f3
# EXP-Topic b2.phases.push
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
0505e8dfaf0f
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).
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -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')
diff --git a/tests/test-acl.t b/tests/test-acl.t
--- a/tests/test-acl.t
+++ b/tests/test-acl.t
@@ -97,7 +97,7 @@
bundle2-output-part: "check:phases" 24 bytes payload
bundle2-output-part: "check:heads" streamed payload
bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
- bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload
+ bundle2-output-part: "phase-heads" 24 bytes payload
bundle2-input-bundle: with-transaction
bundle2-input-part: "replycaps" supported
bundle2-input-part: total payload size 168
@@ -117,17 +117,15 @@
adding quux/file.py revisions
added 3 changesets with 3 changes to 3 files
bundle2-input-part: total payload size 1553
- bundle2-input-part: "pushkey" (params: 4 mandatory) supported
- pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955"
+ bundle2-input-part: "phase-heads" supported
+ bundle2-input-part: total payload size 24
bundle2-input-bundle: 4 parts total
updating the branch cache
- bundle2-output-bundle: "HG20", 2 parts total
+ bundle2-output-bundle: "HG20", 1 parts total
bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory)
empty payload
- bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload
bundle2-input-bundle: no-transaction
bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory)
supported
- bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported
- bundle2-input-bundle: 1 parts total
+ bundle2-input-bundle: 0 parts total
listing keys for "phases"
repository tip rolled back to revision 0 (undo push)
0:6675d58eff77
@@ -162,7 +160,7 @@
bundle2-output-part: "check:phases" 24 bytes payload
bundle2-output-part: "check:heads" streamed payload
bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
- bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload
+ bundle2-output-part: "phase-heads" 24 bytes payload
bundle2-input-bundle: with-transaction
bundle2-input-part: "replycaps" supported
bundle2-input-part: total payload size 168
@@ -184,17 +182,15 @@
calling hook pretxnchangegroup.acl: hgext.acl.hook
acl: changes have source "push" - skipping
bundle2-input-part: total payload size 1553
- bundle2-input-part: "pushkey" (params: 4 mandatory) supported
- pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955"
+ bundle2-input-part: "phase-heads" supported
+ bundle2-input-part: total payload size 24
bundle2-input-bundle: 4 parts total
updating the branch cache
- bundle2-output-bundle: "HG20", 2 parts total
+ bundle2-output-bundle: "HG20", 1 parts