comparison mercurial/bundle2.py @ 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 b87e4638dabf
children 56b2bcea2529
comparison
equal deleted inserted replaced
26564:bed9e6c706f6 26565:ee1bcb9aa6e4
1372 heads = [] 1372 heads = []
1373 while len(h) == 20: 1373 while len(h) == 20:
1374 heads.append(h) 1374 heads.append(h)
1375 h = inpart.read(20) 1375 h = inpart.read(20)
1376 assert not h 1376 assert not h
1377 # Trigger a transaction so that we are guaranteed to have the lock now.
1378 if op.ui.configbool('experimental', 'bundle2lazylocking'):
1379 op.gettransaction()
1377 if heads != op.repo.heads(): 1380 if heads != op.repo.heads():
1378 raise error.PushRaced('repository changed while pushing - ' 1381 raise error.PushRaced('repository changed while pushing - '
1379 'please try again') 1382 'please try again')
1380 1383
1381 @parthandler('output') 1384 @parthandler('output')
1440 dec = pushkey.decode 1443 dec = pushkey.decode
1441 namespace = dec(inpart.params['namespace']) 1444 namespace = dec(inpart.params['namespace'])
1442 key = dec(inpart.params['key']) 1445 key = dec(inpart.params['key'])
1443 old = dec(inpart.params['old']) 1446 old = dec(inpart.params['old'])
1444 new = dec(inpart.params['new']) 1447 new = dec(inpart.params['new'])
1448 # Grab the transaction to ensure that we have the lock before performing the
1449 # pushkey.
1450 if op.ui.configbool('experimental', 'bundle2lazylocking'):
1451 op.gettransaction()
1445 ret = op.repo.pushkey(namespace, key, old, new) 1452 ret = op.repo.pushkey(namespace, key, old, new)
1446 record = {'namespace': namespace, 1453 record = {'namespace': namespace,
1447 'key': key, 1454 'key': key,
1448 'old': old, 1455 'old': old,
1449 'new': new} 1456 'new': new}
1495 def handlehgtagsfnodes(op, inpart): 1502 def handlehgtagsfnodes(op, inpart):
1496 """Applies .hgtags fnodes cache entries to the local repo. 1503 """Applies .hgtags fnodes cache entries to the local repo.
1497 1504
1498 Payload is pairs of 20 byte changeset nodes and filenodes. 1505 Payload is pairs of 20 byte changeset nodes and filenodes.
1499 """ 1506 """
1507 # Grab the transaction so we ensure that we have the lock at this point.
1508 if op.ui.configbool('experimental', 'bundle2lazylocking'):
1509 op.gettransaction()
1500 cache = tags.hgtagsfnodescache(op.repo.unfiltered()) 1510 cache = tags.hgtagsfnodescache(op.repo.unfiltered())
1501 1511
1502 count = 0 1512 count = 0
1503 while True: 1513 while True:
1504 node = inpart.read(20) 1514 node = inpart.read(20)