Mercurial > public > mercurial-scm > hg-stable
diff mercurial/exchange.py @ 34821:aa5e7b4a3a01
phase: generate a push-race detection part on push
We are about to switch phase pushing from using pushkey to using a the new
dedicated binary part. We introduce the push race detection on its own to help
detect potential impact.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 11 Oct 2017 07:40:00 +0200 |
parents | eb6375651974 |
children | c1e7ce11db9b |
line wrap: on
line diff
--- a/mercurial/exchange.py Wed Oct 11 07:13:02 2017 +0200 +++ b/mercurial/exchange.py Wed Oct 11 07:40:00 2017 +0200 @@ -735,6 +735,31 @@ data = iter(sorted(affected)) bundler.newpart('check:updated-heads', data=data) +def _pushing(pushop): + """return True if we are pushing anything""" + return bool(pushop.outgoing.missing + or pushop.outdatedphases + or pushop.outobsmarkers + or pushop.outbookmarks) + +@b2partsgenerator('check-phases') +def _pushb2checkphases(pushop, bundler): + """insert phase move checking""" + if not _pushing(pushop) or pushop.force: + return + b2caps = bundle2.bundle2caps(pushop.remote) + hasphaseheads = 'heads' in b2caps.get('phases', ()) + if pushop.remotephases is not None and hasphaseheads: + # check that the remote phase has not changed + checks = [[] for p in phases.allphases] + checks[phases.public].extend(pushop.remotephases.publicheads) + checks[phases.draft].extend(pushop.remotephases.draftroots) + if any(checks): + for nodes in checks: + nodes.sort() + checkdata = phases.binaryencode(checks) + bundler.newpart('check:phases', data=checkdata) + @b2partsgenerator('changeset') def _pushb2ctx(pushop, bundler): """handle changegroup push through bundle2