comparison 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
comparison
equal deleted inserted replaced
34820:a95067b1dca6 34821:aa5e7b4a3a01
733 affected |= remote - set(newheads) 733 affected |= remote - set(newheads)
734 if affected: 734 if affected:
735 data = iter(sorted(affected)) 735 data = iter(sorted(affected))
736 bundler.newpart('check:updated-heads', data=data) 736 bundler.newpart('check:updated-heads', data=data)
737 737
738 def _pushing(pushop):
739 """return True if we are pushing anything"""
740 return bool(pushop.outgoing.missing
741 or pushop.outdatedphases
742 or pushop.outobsmarkers
743 or pushop.outbookmarks)
744
745 @b2partsgenerator('check-phases')
746 def _pushb2checkphases(pushop, bundler):
747 """insert phase move checking"""
748 if not _pushing(pushop) or pushop.force:
749 return
750 b2caps = bundle2.bundle2caps(pushop.remote)
751 hasphaseheads = 'heads' in b2caps.get('phases', ())
752 if pushop.remotephases is not None and hasphaseheads:
753 # check that the remote phase has not changed
754 checks = [[] for p in phases.allphases]
755 checks[phases.public].extend(pushop.remotephases.publicheads)
756 checks[phases.draft].extend(pushop.remotephases.draftroots)
757 if any(checks):
758 for nodes in checks:
759 nodes.sort()
760 checkdata = phases.binaryencode(checks)
761 bundler.newpart('check:phases', data=checkdata)
762
738 @b2partsgenerator('changeset') 763 @b2partsgenerator('changeset')
739 def _pushb2ctx(pushop, bundler): 764 def _pushb2ctx(pushop, bundler):
740 """handle changegroup push through bundle2 765 """handle changegroup push through bundle2
741 766
742 addchangegroup result is stored in the ``pushop.cgresult`` attribute. 767 addchangegroup result is stored in the ``pushop.cgresult`` attribute.