comparison mercurial/exchange.py @ 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 e0e28e910fa3
comparison
equal deleted inserted replaced
24649:2d15c59a001b 24650:b83a8f512a80
49 if version is None: 49 if version is None:
50 raise ValueError('bundler do not support common obsmarker format') 50 raise ValueError('bundler do not support common obsmarker format')
51 stream = obsolete.encodemarkers(markers, True, version=version) 51 stream = obsolete.encodemarkers(markers, True, version=version)
52 return bundler.newpart('b2x:obsmarkers', data=stream) 52 return bundler.newpart('b2x:obsmarkers', data=stream)
53 return None 53 return None
54
55 def _canusebundle2(op):
56 """return true if a pull/push can use bundle2
57
58 Feel free to nuke this function when we drop the experimental option"""
59 return (op.repo.ui.configbool('experimental', 'bundle2-exp', False)
60 and op.remote.capable('bundle2-exp'))
61
54 62
55 class pushoperation(object): 63 class pushoperation(object):
56 """A object that represent a single push operation 64 """A object that represent a single push operation
57 65
58 It purpose is to carry push related state and very common operation. 66 It purpose is to carry push related state and very common operation.
215 unbundle = pushop.remote.capable('unbundle') 223 unbundle = pushop.remote.capable('unbundle')
216 if not unbundle: 224 if not unbundle:
217 lock = pushop.remote.lock() 225 lock = pushop.remote.lock()
218 try: 226 try:
219 _pushdiscovery(pushop) 227 _pushdiscovery(pushop)
220 if (pushop.repo.ui.configbool('experimental', 'bundle2-exp', 228 if _canusebundle2(pushop):
221 False)
222 and pushop.remote.capable('bundle2-exp')):
223 _pushbundle2(pushop) 229 _pushbundle2(pushop)
224 _pushchangeset(pushop) 230 _pushchangeset(pushop)
225 _pushsyncphase(pushop) 231 _pushsyncphase(pushop)
226 _pushobsolete(pushop) 232 _pushobsolete(pushop)
227 _pushbookmark(pushop) 233 _pushbookmark(pushop)
874 pullop.remotebookmarks = remote.listkeys('bookmarks') 880 pullop.remotebookmarks = remote.listkeys('bookmarks')
875 lock = pullop.repo.lock() 881 lock = pullop.repo.lock()
876 try: 882 try:
877 pullop.trmanager = transactionmanager(repo, 'pull', remote.url()) 883 pullop.trmanager = transactionmanager(repo, 'pull', remote.url())
878 _pulldiscovery(pullop) 884 _pulldiscovery(pullop)
879 if (pullop.repo.ui.configbool('experimental', 'bundle2-exp', False) 885 if _canusebundle2(pullop):
880 and pullop.remote.capable('bundle2-exp')):
881 _pullbundle2(pullop) 886 _pullbundle2(pullop)
882 _pullchangeset(pullop) 887 _pullchangeset(pullop)
883 _pullphase(pullop) 888 _pullphase(pullop)
884 _pullbookmarks(pullop) 889 _pullbookmarks(pullop)
885 _pullobsolete(pullop) 890 _pullobsolete(pullop)