mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
exchange: introduce a '_canusebundle2' function
This function refactors the logic that decides to use 'bundle2' during an exchange (pull/push). This will help being consistent while transitioning from the experimental protocol to the final frozen version. I do not expect this function to survive on the long run when using 'bundle2' will become a simple capability check. This is also necessary to allow HG2Y support in an extension to ease transition of companies using the experimental protocol in production (yeah...). Such extension will be able to wrap this function to use the experimental protocol in some case.
This commit is contained in:
parent
151c000fca
commit
540445ae21
@ -52,6 +52,14 @@ def buildobsmarkerspart(bundler, markers):
|
||||
return bundler.newpart('b2x:obsmarkers', data=stream)
|
||||
return None
|
||||
|
||||
def _canusebundle2(op):
|
||||
"""return true if a pull/push can use bundle2
|
||||
|
||||
Feel free to nuke this function when we drop the experimental option"""
|
||||
return (op.repo.ui.configbool('experimental', 'bundle2-exp', False)
|
||||
and op.remote.capable('bundle2-exp'))
|
||||
|
||||
|
||||
class pushoperation(object):
|
||||
"""A object that represent a single push operation
|
||||
|
||||
@ -217,9 +225,7 @@ def push(repo, remote, force=False, revs=None, newbranch=False, bookmarks=()):
|
||||
lock = pushop.remote.lock()
|
||||
try:
|
||||
_pushdiscovery(pushop)
|
||||
if (pushop.repo.ui.configbool('experimental', 'bundle2-exp',
|
||||
False)
|
||||
and pushop.remote.capable('bundle2-exp')):
|
||||
if _canusebundle2(pushop):
|
||||
_pushbundle2(pushop)
|
||||
_pushchangeset(pushop)
|
||||
_pushsyncphase(pushop)
|
||||
@ -876,8 +882,7 @@ def pull(repo, remote, heads=None, force=False, bookmarks=()):
|
||||
try:
|
||||
pullop.trmanager = transactionmanager(repo, 'pull', remote.url())
|
||||
_pulldiscovery(pullop)
|
||||
if (pullop.repo.ui.configbool('experimental', 'bundle2-exp', False)
|
||||
and pullop.remote.capable('bundle2-exp')):
|
||||
if _canusebundle2(pullop):
|
||||
_pullbundle2(pullop)
|
||||
_pullchangeset(pullop)
|
||||
_pullphase(pullop)
|
||||
|
Loading…
Reference in New Issue
Block a user