comparison mercurial/exchange.py @ 33039:b82615afde65

bundle: add a applybundle1() method This is one step towards removing a bunch of "if isinstance(gen, unbundle20)" by treating bundle1 and bundle2 more similarly. The name may sounds ironic for a method in the bundle2 module, but I didn't think it was worth it yet to create a new 'bundle' module that depends on the 'bundle2' module. Besides, we'll inline the method again later.
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 16 Jun 2017 10:25:11 -0700
parents d765ad56081f
children 2baef42a2881
comparison
equal deleted inserted replaced
33038:f0efd2bffe1e 33039:b82615afde65
1446 raise error.Abort(_("partial pull cannot be done because " 1446 raise error.Abort(_("partial pull cannot be done because "
1447 "other repository doesn't support " 1447 "other repository doesn't support "
1448 "changegroupsubset.")) 1448 "changegroupsubset."))
1449 else: 1449 else:
1450 cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull') 1450 cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull')
1451 pullop.cgresult, addednodes = cg.apply(pullop.repo, tr, 'pull', 1451 pullop.cgresult = bundle2.applybundle1(pullop.repo, cg, tr, 'pull',
1452 pullop.remote.url()) 1452 pullop.remote.url())
1453 1453
1454 def _pullphase(pullop): 1454 def _pullphase(pullop):
1455 # Get remote phases data from remote 1455 # Get remote phases data from remote
1456 if 'phases' in pullop.stepsdone: 1456 if 'phases' in pullop.stepsdone:
1735 # push can proceed 1735 # push can proceed
1736 if not isinstance(cg, bundle2.unbundle20): 1736 if not isinstance(cg, bundle2.unbundle20):
1737 # legacy case: bundle1 (changegroup 01) 1737 # legacy case: bundle1 (changegroup 01)
1738 txnname = "\n".join([source, util.hidepassword(url)]) 1738 txnname = "\n".join([source, util.hidepassword(url)])
1739 with repo.lock(), repo.transaction(txnname) as tr: 1739 with repo.lock(), repo.transaction(txnname) as tr:
1740 r, addednodes = cg.apply(repo, tr, source, url) 1740 r = bundle2.applybundle1(repo, cg, tr, source, url)
1741 else: 1741 else:
1742 r = None 1742 r = None
1743 try: 1743 try:
1744 def gettransaction(): 1744 def gettransaction():
1745 if not lockandtr[2]: 1745 if not lockandtr[2]:
2000 if isinstance(cg, bundle2.unbundle20): 2000 if isinstance(cg, bundle2.unbundle20):
2001 bundle2.applybundle(repo, cg, tr, 'clonebundles', url) 2001 bundle2.applybundle(repo, cg, tr, 'clonebundles', url)
2002 elif isinstance(cg, streamclone.streamcloneapplier): 2002 elif isinstance(cg, streamclone.streamcloneapplier):
2003 cg.apply(repo) 2003 cg.apply(repo)
2004 else: 2004 else:
2005 cg.apply(repo, tr, 'clonebundles', url) 2005 bundle2.applybundle1(repo, cg, tr, 'clonebundles', url)
2006 return True 2006 return True
2007 except urlerr.httperror as e: 2007 except urlerr.httperror as e:
2008 ui.warn(_('HTTP error fetching bundle: %s\n') % str(e)) 2008 ui.warn(_('HTTP error fetching bundle: %s\n') % str(e))
2009 except urlerr.urlerror as e: 2009 except urlerr.urlerror as e:
2010 ui.warn(_('error fetching bundle: %s\n') % e.reason) 2010 ui.warn(_('error fetching bundle: %s\n') % e.reason)