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

login
register
mail settings
Submitter Durham Goode
Date Oct. 6, 2015, 10:08 p.m.
Message ID <0e304cffebad9b34e941.1444169303@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/10835/
State Superseded
Commit ee1bcb9aa6e49bce43b8ea0723875dbd8d29f2d7
Headers show

Comments

Durham Goode - Oct. 6, 2015, 10:08 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1444167749 25200
#      Tue Oct 06 14:42:29 2015 -0700
# Node ID 0e304cffebad9b34e941951a7bd0211444c9911f
# Parent  efd57cd6fd1d5eb76102fabfc45676873bbba29d
bundle2: add op.gettransaction() to handlers that need the lock

A future patch will be making the bundle2 lock be taken on demand. We need to
introduce transaction-gets to each handler that needs the lock.

The tests caught these issues when I added lazy locking.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1324,6 +1324,8 @@  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.
+    op.gettransaction()
     if heads != op.repo.heads():
         raise error.PushRaced('repository changed while pushing - '
                               'please try again')
@@ -1392,6 +1394,9 @@  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.
+    op.gettransaction()
     ret = op.repo.pushkey(namespace, key, old, new)
     record = {'namespace': namespace,
               'key': key,
@@ -1447,6 +1452,8 @@  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.
+    op.gettransaction()
     cache = tags.hgtagsfnodescache(op.repo.unfiltered())
 
     count = 0