[PATCH 1 of 2 V2] bundle2: add op.gettransaction() to handlers that need the lock

Durham Goode durham at fb.com
Wed Oct 7 01:42:19 UTC 2015


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1444167749 25200
#      Tue Oct 06 14:42:29 2015 -0700
# Node ID 1c8b56dd34406c2dfb2942d70ce427ef0d359f0c
# Parent  efd57cd6fd1d5eb76102fabfc45676873bbba29d
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.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1324,6 +1324,9 @@ def handlecheckheads(op, inpart):
         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')
@@ -1392,6 +1395,10 @@ def handlepushkey(op, inpart):
     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,
@@ -1447,6 +1454,9 @@ def handlehgtagsfnodes(op, inpart):
 
     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


More information about the Mercurial-devel mailing list