Mercurial > hg
changeset 24650:b83a8f512a80
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 06 Apr 2015 18:31:59 -0700 |
parents | 2d15c59a001b |
children | 67241ee427cf |
files | mercurial/exchange.py |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/exchange.py Tue Apr 07 16:01:32 2015 -0700 +++ b/mercurial/exchange.py Mon Apr 06 18:31:59 2015 -0700 @@ -52,6 +52,14 @@ 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 @@ 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 @@ 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)