comparison mercurial/exchange.py @ 35783:c97639ad6874

bundle2: specify what capabilities will be used for We currently assume there is a symmetric relationship of bundle2 capabilities between client and server. However, this may not always be the case. We need a bundle2 capability to advertise bundle2 streaming clone support on servers to differentiate it from the existing, legacy streaming clone support. However, servers may wish to disable streaming clone support. If bundle2 capabilities were the same between client and server, a client (which may also be a server) that has disabled streaming clone support would not be able to perform a streaming clone itself! This commit introduces a "role" argument to bundle2.getrepocaps() that explicitly defines the role being performed. This will allow us (and extensions) to alter bundle2 capabilities depending on the operation being performed. Differential Revision: https://phab.mercurial-scm.org/D1923
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 20 Jan 2018 13:54:36 -0800
parents 56c30b31afbe
children 08cc94dd3d3c
comparison
equal deleted inserted replaced
35782:9d249f3de730 35783:c97639ad6874
1013 pushback = (pushop.trmanager 1013 pushback = (pushop.trmanager
1014 and pushop.ui.configbool('experimental', 'bundle2.pushback')) 1014 and pushop.ui.configbool('experimental', 'bundle2.pushback'))
1015 1015
1016 # create reply capability 1016 # create reply capability
1017 capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo, 1017 capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo,
1018 allowpushback=pushback)) 1018 allowpushback=pushback,
1019 role='client'))
1019 bundler.newpart('replycaps', data=capsblob) 1020 bundler.newpart('replycaps', data=capsblob)
1020 replyhandlers = [] 1021 replyhandlers = []
1021 for partgenname in b2partsgenorder: 1022 for partgenname in b2partsgenorder:
1022 partgen = b2partsgenmapping[partgenname] 1023 partgen = b2partsgenmapping[partgenname]
1023 ret = partgen(pushop, bundler) 1024 ret = partgen(pushop, bundler)
1446 1447
1447 def _pullbundle2(pullop): 1448 def _pullbundle2(pullop):
1448 """pull data using bundle2 1449 """pull data using bundle2
1449 1450
1450 For now, the only supported data are changegroup.""" 1451 For now, the only supported data are changegroup."""
1451 kwargs = {'bundlecaps': caps20to10(pullop.repo)} 1452 kwargs = {'bundlecaps': caps20to10(pullop.repo, role='client')}
1452 1453
1453 # make ui easier to access 1454 # make ui easier to access
1454 ui = pullop.repo.ui 1455 ui = pullop.repo.ui
1455 1456
1456 # At the moment we don't do stream clones over bundle2. If that is 1457 # At the moment we don't do stream clones over bundle2. If that is
1678 if markers: 1679 if markers:
1679 pullop.repo.obsstore.add(tr, markers) 1680 pullop.repo.obsstore.add(tr, markers)
1680 pullop.repo.invalidatevolatilesets() 1681 pullop.repo.invalidatevolatilesets()
1681 return tr 1682 return tr
1682 1683
1683 def caps20to10(repo): 1684 def caps20to10(repo, role):
1684 """return a set with appropriate options to use bundle20 during getbundle""" 1685 """return a set with appropriate options to use bundle20 during getbundle"""
1685 caps = {'HG20'} 1686 caps = {'HG20'}
1686 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) 1687 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo, role=role))
1687 caps.add('bundle2=' + urlreq.quote(capsblob)) 1688 caps.add('bundle2=' + urlreq.quote(capsblob))
1688 return caps 1689 return caps
1689 1690
1690 # List of names of steps to perform for a bundle2 for getbundle, order matters. 1691 # List of names of steps to perform for a bundle2 for getbundle, order matters.
1691 getbundle2partsorder = [] 1692 getbundle2partsorder = []