Patchwork [1,of,5] exchange: create transaction for bundle1 unbundling earlier

login
register
mail settings
Submitter via Mercurial-devel
Date June 18, 2017, 7:02 a.m.
Message ID <c0f6614c4c95281e7188.1497769344@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/21474/
State Accepted
Headers show

Comments

via Mercurial-devel - June 18, 2017, 7:02 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1497568253 25200
#      Thu Jun 15 16:10:53 2017 -0700
# Node ID c0f6614c4c95281e7188879cd430ce0208680f2c
# Parent  8e02829bec6135f4ec96bb68b54de2c3f56dbc09
exchange: create transaction for bundle1 unbundling earlier

changegroup.apply() currently creates a transation if there isn't
already one. Having the callers of that method pass in an existing
transaction seems a little cleaner. To do that, we need to make sure
all callers have a transaction. Since the transaction name is used as
a hook argument (HG_TXNNAME), we need to match the name from
changegroup.apply().

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1733,7 +1733,8 @@ 
         # push can proceed
         if not util.safehasattr(cg, 'params'):
             # legacy case: bundle1 (changegroup 01)
-            with repo.lock():
+            txnname = "\n".join([source, util.hidepassword(url)])
+            with repo.lock(), repo.transaction(txnname):
                 r = cg.apply(repo, source, url)
         else:
             r = None