diff tests/test-bundle2.t @ 20952:b24ee5076b94

bundle2: make it possible have a global transaction for the unbundling We use the `gettransaction` method approach already used for pull. We need this because we do not know beforehand if the bundle needs a transaction to be created. And (1) we do not want to create a transaction for nothing. (2) Some bundle2 bundles may be read-only and do not require any lock or transaction to be held.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 02 Apr 2014 23:56:49 -0700
parents f977c732bf34
children 12f161f08d74
line wrap: on
line diff
--- a/tests/test-bundle2.t	Fri Apr 04 17:47:19 2014 -0500
+++ b/tests/test-bundle2.t	Wed Apr 02 23:56:49 2014 -0700
@@ -96,13 +96,18 @@
   > def cmdunbundle2(ui, repo):
   >     """process a bundle2 stream from stdin on the current repo"""
   >     try:
+  >         tr = None
   >         lock = repo.lock()
+  >         tr = repo.transaction('processbundle')
   >         try:
   >             unbundler = bundle2.unbundle20(ui, sys.stdin)
-  >             op = bundle2.processbundle(repo, unbundler)
+  >             op = bundle2.processbundle(repo, unbundler, lambda: tr)
+  >             tr.close()
   >         except KeyError, exc:
   >             raise util.Abort('missing support for %s' % exc)
   >     finally:
+  >         if tr is not None:
+  >             tr.release()
   >         lock.release()
   >         remains = sys.stdin.read()
   >         ui.write('%i unread bytes\n' % len(remains))