changeset 26565:ee1bcb9aa6e4

bundle2: add op.gettransaction() to handlers that need the lock A future patch will allow the bundle2 lock be taken lazily. We need to introduce transaction-gets to each handler that needs the lock. The tests caught these issues when I added lazy locking.
author Durham Goode <durham@fb.com>
date Tue, 06 Oct 2015 14:42:29 -0700
parents bed9e6c706f6
children 58880acd2369
files mercurial/bundle2.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Thu Oct 08 17:44:22 2015 -0500
+++ b/mercurial/bundle2.py	Tue Oct 06 14:42:29 2015 -0700
@@ -1374,6 +1374,9 @@
         heads.append(h)
         h = inpart.read(20)
     assert not h
+    # Trigger a transaction so that we are guaranteed to have the lock now.
+    if op.ui.configbool('experimental', 'bundle2lazylocking'):
+        op.gettransaction()
     if heads != op.repo.heads():
         raise error.PushRaced('repository changed while pushing - '
                               'please try again')
@@ -1442,6 +1445,10 @@
     key = dec(inpart.params['key'])
     old = dec(inpart.params['old'])
     new = dec(inpart.params['new'])
+    # Grab the transaction to ensure that we have the lock before performing the
+    # pushkey.
+    if op.ui.configbool('experimental', 'bundle2lazylocking'):
+        op.gettransaction()
     ret = op.repo.pushkey(namespace, key, old, new)
     record = {'namespace': namespace,
               'key': key,
@@ -1497,6 +1504,9 @@
 
     Payload is pairs of 20 byte changeset nodes and filenodes.
     """
+    # Grab the transaction so we ensure that we have the lock at this point.
+    if op.ui.configbool('experimental', 'bundle2lazylocking'):
+        op.gettransaction()
     cache = tags.hgtagsfnodescache(op.repo.unfiltered())
 
     count = 0