##// END OF EJS Templates
bundle: make applybundle() delegate v1 bundles to applybundle1()
Martin von Zweigbergk -
r33043:18c2489a default
parent child Browse files
Show More
@@ -1198,14 +1198,8 b' def _aborthistedit(ui, repo, state):'
1198 f = hg.openpath(ui, backupfile)
1198 f = hg.openpath(ui, backupfile)
1199 gen = exchange.readbundle(ui, f, backupfile)
1199 gen = exchange.readbundle(ui, f, backupfile)
1200 with repo.transaction('histedit.abort') as tr:
1200 with repo.transaction('histedit.abort') as tr:
1201 if not isinstance(gen, bundle2.unbundle20):
1201 bundle2.applybundle(repo, gen, tr, source='histedit',
1202 bundle2.applybundle1(repo, gen, tr,
1202 url='bundle:' + backupfile)
1203 source='histedit',
1204 url='bundle:' + backupfile)
1205 else:
1206 bundle2.applybundle(repo, gen, tr,
1207 source='histedit',
1208 url='bundle:' + backupfile)
1209
1203
1210 os.remove(backupfile)
1204 os.remove(backupfile)
1211
1205
@@ -126,17 +126,10 b' class shelvedfile(object):'
126 fp = self.opener()
126 fp = self.opener()
127 try:
127 try:
128 gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs)
128 gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs)
129 if not isinstance(gen, bundle2.unbundle20):
129 bundle2.applybundle(self.repo, gen, self.repo.currenttransaction(),
130 bundle2.applybundle1(self.repo, gen,
130 source='unshelve',
131 self.repo.currenttransaction(),
131 url='bundle:' + self.vfs.join(self.fname),
132 source='unshelve',
132 targetphase=phases.secret)
133 url='bundle:' + self.vfs.join(self.fname),
134 targetphase=phases.secret)
135 else:
136 bundle2.applybundle(self.repo, gen,
137 self.repo.currenttransaction(),
138 source='unshelve',
139 url='bundle:' + self.vfs.join(self.fname))
140 finally:
133 finally:
141 fp.close()
134 fp.close()
142
135
@@ -316,14 +316,17 b' def applybundle1(repo, cg, tr, source, u'
316 _processchangegroup(op, cg, tr, source, url, **kwargs)
316 _processchangegroup(op, cg, tr, source, url, **kwargs)
317 return op
317 return op
318
318
319 def applybundle(repo, unbundler, tr, source=None, url=None):
319 def applybundle(repo, unbundler, tr, source=None, url=None, **kwargs):
320 # transform me into unbundler.apply() as soon as the freeze is lifted
320 # transform me into unbundler.apply() as soon as the freeze is lifted
321 tr.hookargs['bundle2'] = '1'
321 if isinstance(unbundler, unbundle20):
322 if source is not None and 'source' not in tr.hookargs:
322 tr.hookargs['bundle2'] = '1'
323 tr.hookargs['source'] = source
323 if source is not None and 'source' not in tr.hookargs:
324 if url is not None and 'url' not in tr.hookargs:
324 tr.hookargs['source'] = source
325 tr.hookargs['url'] = url
325 if url is not None and 'url' not in tr.hookargs:
326 return processbundle(repo, unbundler, lambda: tr)
326 tr.hookargs['url'] = url
327 return processbundle(repo, unbundler, lambda: tr)
328 else:
329 return applybundle1(repo, unbundler, tr, source, url, **kwargs)
327
330
328 def processbundle(repo, unbundler, transactiongetter=None, op=None):
331 def processbundle(repo, unbundler, transactiongetter=None, op=None):
329 """This function process a bundle, apply effect to/from a repo
332 """This function process a bundle, apply effect to/from a repo
@@ -5207,13 +5207,8 b' def unbundle(ui, repo, fname1, *fnames, '
5207 if not isinstance(gen, bundle2.unbundle20):
5207 if not isinstance(gen, bundle2.unbundle20):
5208 txnname = 'unbundle\n%s' % util.hidepassword(url)
5208 txnname = 'unbundle\n%s' % util.hidepassword(url)
5209 with repo.transaction(txnname) as tr:
5209 with repo.transaction(txnname) as tr:
5210 if isinstance(gen, bundle2.unbundle20):
5210 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
5211 op = bundle2.applybundle(repo, gen, tr,
5211 url=url)
5212 source='unbundle',
5213 url=url)
5214 else:
5215 op = bundle2.applybundle1(repo, gen, tr,
5216 source='unbundle', url=url)
5217 except error.BundleUnknownFeatureError as exc:
5212 except error.BundleUnknownFeatureError as exc:
5218 raise error.Abort(
5213 raise error.Abort(
5219 _('%s: unknown bundle feature, %s') % (fname, exc),
5214 _('%s: unknown bundle feature, %s') % (fname, exc),
@@ -1448,8 +1448,8 b' def _pullchangeset(pullop):'
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 bundleop = bundle2.applybundle1(pullop.repo, cg, tr, 'pull',
1451 bundleop = bundle2.applybundle(pullop.repo, cg, tr, 'pull',
1452 pullop.remote.url())
1452 pullop.remote.url())
1453 pullop.cgresult = bundle2.combinechangegroupresults(bundleop)
1453 pullop.cgresult = bundle2.combinechangegroupresults(bundleop)
1454
1454
1455 def _pullphase(pullop):
1455 def _pullphase(pullop):
@@ -1738,7 +1738,7 b' def unbundle(repo, cg, heads, source, ur'
1738 # legacy case: bundle1 (changegroup 01)
1738 # legacy case: bundle1 (changegroup 01)
1739 txnname = "\n".join([source, util.hidepassword(url)])
1739 txnname = "\n".join([source, util.hidepassword(url)])
1740 with repo.lock(), repo.transaction(txnname) as tr:
1740 with repo.lock(), repo.transaction(txnname) as tr:
1741 op = bundle2.applybundle1(repo, cg, tr, source, url)
1741 op = bundle2.applybundle(repo, cg, tr, source, url)
1742 r = bundle2.combinechangegroupresults(op)
1742 r = bundle2.combinechangegroupresults(op)
1743 else:
1743 else:
1744 r = None
1744 r = None
@@ -1999,12 +1999,10 b' def trypullbundlefromurl(ui, repo, url):'
1999 fh = urlmod.open(ui, url)
1999 fh = urlmod.open(ui, url)
2000 cg = readbundle(ui, fh, 'stream')
2000 cg = readbundle(ui, fh, 'stream')
2001
2001
2002 if isinstance(cg, bundle2.unbundle20):
2002 if isinstance(cg, streamclone.streamcloneapplier):
2003 bundle2.applybundle(repo, cg, tr, 'clonebundles', url)
2004 elif isinstance(cg, streamclone.streamcloneapplier):
2005 cg.apply(repo)
2003 cg.apply(repo)
2006 else:
2004 else:
2007 bundle2.applybundle1(repo, cg, tr, 'clonebundles', url)
2005 bundle2.applybundle(repo, cg, tr, 'clonebundles', url)
2008 return True
2006 return True
2009 except urlerr.httperror as e:
2007 except urlerr.httperror as e:
2010 ui.warn(_('HTTP error fetching bundle: %s\n') % str(e))
2008 ui.warn(_('HTTP error fetching bundle: %s\n') % str(e))
@@ -211,12 +211,8 b' def strip(ui, repo, nodelist, backup=Tru'
211 if not isinstance(gen, bundle2.unbundle20):
211 if not isinstance(gen, bundle2.unbundle20):
212 txnname = "strip\n%s" % util.hidepassword(tmpbundleurl)
212 txnname = "strip\n%s" % util.hidepassword(tmpbundleurl)
213 with repo.transaction(txnname) as tr:
213 with repo.transaction(txnname) as tr:
214 if isinstance(gen, bundle2.unbundle20):
214 bundle2.applybundle(repo, gen, tr, source='strip',
215 bundle2.applybundle(repo, gen, tr, source='strip',
215 url=tmpbundleurl, emptyok=True)
216 url=tmpbundleurl)
217 else:
218 bundle2.applybundle1(repo, gen, tr, 'strip', tmpbundleurl,
219 emptyok=True)
220 if not repo.ui.verbose:
216 if not repo.ui.verbose:
221 repo.ui.popbuffer()
217 repo.ui.popbuffer()
222 f.close()
218 f.close()
General Comments 0
You need to be logged in to leave comments. Login now