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