##// 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,13 +1198,7 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,
1203 source='histedit',
1204 url='bundle:' + backupfile)
1205 else:
1206 bundle2.applybundle(repo, gen, tr,
1207 source='histedit',
1208 url='bundle:' + backupfile)
1202 url='bundle:' + backupfile)
1209
1203
1210 os.remove(backupfile)
1204 os.remove(backupfile)
@@ -126,17 +126,10 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,
131 self.repo.currenttransaction(),
132 source='unshelve',
130 source='unshelve',
133 url='bundle:' + self.vfs.join(self.fname),
131 url='bundle:' + self.vfs.join(self.fname),
134 targetphase=phases.secret)
132 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 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 if isinstance(unbundler, unbundle20):
321 tr.hookargs['bundle2'] = '1'
322 tr.hookargs['bundle2'] = '1'
322 if source is not None and 'source' not in tr.hookargs:
323 if source is not None and 'source' not in tr.hookargs:
323 tr.hookargs['source'] = source
324 tr.hookargs['source'] = source
324 if url is not None and 'url' not in tr.hookargs:
325 if url is not None and 'url' not in tr.hookargs:
325 tr.hookargs['url'] = url
326 tr.hookargs['url'] = url
326 return processbundle(repo, unbundler, lambda: tr)
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 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,
5212 source='unbundle',
5213 url=url)
5211 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,7 +1448,7 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
@@ -1738,7 +1738,7 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 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 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):
215 bundle2.applybundle(repo, gen, tr, source='strip',
214 bundle2.applybundle(repo, gen, tr, source='strip',
216 url=tmpbundleurl)
215 url=tmpbundleurl, emptyok=True)
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