##// END OF EJS Templates
bundleoperation: optionnaly record the `remote` that produced the bundle...
marmoute -
r50659:4188e75a default
parent child Browse files
Show More
@@ -416,7 +416,7 b' def _widen('
416 repo, trmanager.transaction, source=b'widen'
416 repo, trmanager.transaction, source=b'widen'
417 )
417 )
418 # TODO: we should catch error.Abort here
418 # TODO: we should catch error.Abort here
419 bundle2.processbundle(repo, bundle, op=op)
419 bundle2.processbundle(repo, bundle, op=op, remote=remote)
420
420
421 if ellipsesremote:
421 if ellipsesremote:
422 with ds.parentchange():
422 with ds.parentchange():
@@ -315,8 +315,17 b' class bundleoperation:'
315 * a way to construct a bundle response when applicable.
315 * a way to construct a bundle response when applicable.
316 """
316 """
317
317
318 def __init__(self, repo, transactiongetter, captureoutput=True, source=b''):
318 def __init__(
319 self,
320 repo,
321 transactiongetter,
322 captureoutput=True,
323 source=b'',
324 remote=None,
325 ):
319 self.repo = repo
326 self.repo = repo
327 # the peer object who produced this bundle if available
328 self.remote = remote
320 self.ui = repo.ui
329 self.ui = repo.ui
321 self.records = unbundlerecords()
330 self.records = unbundlerecords()
322 self.reply = None
331 self.reply = None
@@ -363,7 +372,7 b' def _notransaction():'
363 raise TransactionUnavailable()
372 raise TransactionUnavailable()
364
373
365
374
366 def applybundle(repo, unbundler, tr, source, url=None, **kwargs):
375 def applybundle(repo, unbundler, tr, source, url=None, remote=None, **kwargs):
367 # transform me into unbundler.apply() as soon as the freeze is lifted
376 # transform me into unbundler.apply() as soon as the freeze is lifted
368 if isinstance(unbundler, unbundle20):
377 if isinstance(unbundler, unbundle20):
369 tr.hookargs[b'bundle2'] = b'1'
378 tr.hookargs[b'bundle2'] = b'1'
@@ -371,10 +380,12 b' def applybundle(repo, unbundler, tr, sou'
371 tr.hookargs[b'source'] = source
380 tr.hookargs[b'source'] = source
372 if url is not None and b'url' not in tr.hookargs:
381 if url is not None and b'url' not in tr.hookargs:
373 tr.hookargs[b'url'] = url
382 tr.hookargs[b'url'] = url
374 return processbundle(repo, unbundler, lambda: tr, source=source)
383 return processbundle(
384 repo, unbundler, lambda: tr, source=source, remote=remote
385 )
375 else:
386 else:
376 # the transactiongetter won't be used, but we might as well set it
387 # the transactiongetter won't be used, but we might as well set it
377 op = bundleoperation(repo, lambda: tr, source=source)
388 op = bundleoperation(repo, lambda: tr, source=source, remote=remote)
378 _processchangegroup(op, unbundler, tr, source, url, **kwargs)
389 _processchangegroup(op, unbundler, tr, source, url, **kwargs)
379 return op
390 return op
380
391
@@ -450,7 +461,14 b' class partiterator:'
450 )
461 )
451
462
452
463
453 def processbundle(repo, unbundler, transactiongetter=None, op=None, source=b''):
464 def processbundle(
465 repo,
466 unbundler,
467 transactiongetter=None,
468 op=None,
469 source=b'',
470 remote=None,
471 ):
454 """This function process a bundle, apply effect to/from a repo
472 """This function process a bundle, apply effect to/from a repo
455
473
456 It iterates over each part then searches for and uses the proper handling
474 It iterates over each part then searches for and uses the proper handling
@@ -466,7 +484,12 b' def processbundle(repo, unbundler, trans'
466 if op is None:
484 if op is None:
467 if transactiongetter is None:
485 if transactiongetter is None:
468 transactiongetter = _notransaction
486 transactiongetter = _notransaction
469 op = bundleoperation(repo, transactiongetter, source=source)
487 op = bundleoperation(
488 repo,
489 transactiongetter,
490 source=source,
491 remote=remote,
492 )
470 # todo:
493 # todo:
471 # - replace this is a init function soon.
494 # - replace this is a init function soon.
472 # - exception catching
495 # - exception catching
@@ -1183,7 +1183,12 b' def _pushbundle2(pushop):'
1183 trgetter = None
1183 trgetter = None
1184 if pushback:
1184 if pushback:
1185 trgetter = pushop.trmanager.transaction
1185 trgetter = pushop.trmanager.transaction
1186 op = bundle2.processbundle(pushop.repo, reply, trgetter)
1186 op = bundle2.processbundle(
1187 pushop.repo,
1188 reply,
1189 trgetter,
1190 remote=pushop.remote,
1191 )
1187 except error.BundleValueError as exc:
1192 except error.BundleValueError as exc:
1188 raise error.RemoteError(_(b'missing support for %s') % exc)
1193 raise error.RemoteError(_(b'missing support for %s') % exc)
1189 except bundle2.AbortFromPart as exc:
1194 except bundle2.AbortFromPart as exc:
@@ -1903,10 +1908,18 b' def _pullbundle2(pullop):'
1903
1908
1904 try:
1909 try:
1905 op = bundle2.bundleoperation(
1910 op = bundle2.bundleoperation(
1906 pullop.repo, pullop.gettransaction, source=b'pull'
1911 pullop.repo,
1912 pullop.gettransaction,
1913 source=b'pull',
1914 remote=pullop.remote,
1907 )
1915 )
1908 op.modes[b'bookmarks'] = b'records'
1916 op.modes[b'bookmarks'] = b'records'
1909 bundle2.processbundle(pullop.repo, bundle, op=op)
1917 bundle2.processbundle(
1918 pullop.repo,
1919 bundle,
1920 op=op,
1921 remote=pullop.remote,
1922 )
1910 except bundle2.AbortFromPart as exc:
1923 except bundle2.AbortFromPart as exc:
1911 pullop.repo.ui.error(_(b'remote: abort: %s\n') % exc)
1924 pullop.repo.ui.error(_(b'remote: abort: %s\n') % exc)
1912 raise error.RemoteError(_(b'pull failed on remote'), hint=exc.hint)
1925 raise error.RemoteError(_(b'pull failed on remote'), hint=exc.hint)
@@ -1995,7 +2008,12 b' def _pullchangeset(pullop):'
1995 ).result()
2008 ).result()
1996
2009
1997 bundleop = bundle2.applybundle(
2010 bundleop = bundle2.applybundle(
1998 pullop.repo, cg, tr, b'pull', pullop.remote.url()
2011 pullop.repo,
2012 cg,
2013 tr,
2014 b'pull',
2015 pullop.remote.url(),
2016 remote=pullop.remote,
1999 )
2017 )
2000 pullop.cgresult = bundle2.combinechangegroupresults(bundleop)
2018 pullop.cgresult = bundle2.combinechangegroupresults(bundleop)
2001
2019
General Comments 0
You need to be logged in to leave comments. Login now