# HG changeset patch # User Martin von Zweigbergk # Date 1498192077 25200 # Node ID dbc2ee17053e1206186c7f71c0cc64330daf4b2e # Parent e425f5aabe70c385e43a8875ff457a68f45143ad bundle: transpose transaction scope with bundle type switch This moves the transaction with-statements outside of the per-bundle-version switches, so the next patch will be a little simpler. diff -r e425f5aabe70 -r dbc2ee17053e mercurial/commands.py --- a/mercurial/commands.py Thu Jun 22 15:03:13 2017 -0700 +++ b/mercurial/commands.py Thu Jun 22 21:27:57 2017 -0700 @@ -5203,14 +5203,15 @@ hint=_('use "hg debugapplystreamclonebundle"')) url = 'bundle:' + fname try: - if isinstance(gen, bundle2.unbundle20): - with repo.transaction('unbundle') as tr: + txnname = 'unbundle' + if not isinstance(gen, bundle2.unbundle20): + txnname = 'unbundle\n%s' % util.hidepassword(url) + with repo.transaction(txnname) as tr: + if isinstance(gen, bundle2.unbundle20): op = bundle2.applybundle(repo, gen, tr, source='unbundle', url=url) - else: - txnname = 'unbundle\n%s' % util.hidepassword(url) - with repo.transaction(txnname) as tr: + else: op = bundle2.applybundle1(repo, gen, tr, source='unbundle', url=url) except error.BundleUnknownFeatureError as exc: diff -r e425f5aabe70 -r dbc2ee17053e mercurial/repair.py --- a/mercurial/repair.py Thu Jun 22 15:03:13 2017 -0700 +++ b/mercurial/repair.py Thu Jun 22 21:27:57 2017 -0700 @@ -207,13 +207,14 @@ # silence internal shuffling chatter repo.ui.pushbuffer() tmpbundleurl = 'bundle:' + vfs.join(tmpbundlefile) - if isinstance(gen, bundle2.unbundle20): - with repo.transaction('strip') as tr: + txnname = 'strip' + if not isinstance(gen, bundle2.unbundle20): + txnname = "strip\n%s" % util.hidepassword(tmpbundleurl) + with repo.transaction(txnname) as tr: + if isinstance(gen, bundle2.unbundle20): bundle2.applybundle(repo, gen, tr, source='strip', url=tmpbundleurl) - else: - txnname = "strip\n%s" % util.hidepassword(tmpbundleurl) - with repo.transaction(txnname) as tr: + else: bundle2.applybundle1(repo, gen, tr, 'strip', tmpbundleurl, emptyok=True) if not repo.ui.verbose: