From patchwork Sat Jun 24 15:38:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [08, of, 10] bundle: transpose transaction scope with bundle type switch From: via Mercurial-devel X-Patchwork-Id: 21672 Message-Id: <15326b3ffdaf861d6c7d.1498318716@martinvonz.svl.corp.google.com> To: mercurial-devel@mercurial-scm.org Date: Sat, 24 Jun 2017 08:38:36 -0700 # HG changeset patch # User Martin von Zweigbergk # Date 1498192077 25200 # Thu Jun 22 21:27:57 2017 -0700 # Node ID 15326b3ffdaf861d6c7dd9dad850f8790a869427 # Parent 0e791a5d805adf64d9056f7ee7be1f084c7ca10b 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 --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -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 --git a/mercurial/repair.py b/mercurial/repair.py --- a/mercurial/repair.py +++ b/mercurial/repair.py @@ -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: