##// END OF EJS Templates
with: use context manager for lock in pushphase
Bryan O'Sullivan -
r27861:3315a9c2 default
parent child Browse files
Show More
@@ -404,26 +404,23 b' def listphases(repo):'
404 def pushphase(repo, nhex, oldphasestr, newphasestr):
404 def pushphase(repo, nhex, oldphasestr, newphasestr):
405 """List phases root for serialization over pushkey"""
405 """List phases root for serialization over pushkey"""
406 repo = repo.unfiltered()
406 repo = repo.unfiltered()
407 tr = None
407 with repo.lock():
408 lock = repo.lock()
409 try:
410 currentphase = repo[nhex].phase()
408 currentphase = repo[nhex].phase()
411 newphase = abs(int(newphasestr)) # let's avoid negative index surprise
409 newphase = abs(int(newphasestr)) # let's avoid negative index surprise
412 oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise
410 oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise
413 if currentphase == oldphase and newphase < oldphase:
411 if currentphase == oldphase and newphase < oldphase:
414 tr = repo.transaction('pushkey-phase')
412 try:
415 advanceboundary(repo, tr, newphase, [bin(nhex)])
413 tr = repo.transaction('pushkey-phase')
416 tr.close()
414 advanceboundary(repo, tr, newphase, [bin(nhex)])
415 tr.close()
416 finally:
417 tr.release()
417 return 1
418 return 1
418 elif currentphase == newphase:
419 elif currentphase == newphase:
419 # raced, but got correct result
420 # raced, but got correct result
420 return 1
421 return 1
421 else:
422 else:
422 return 0
423 return 0
423 finally:
424 if tr:
425 tr.release()
426 lock.release()
427
424
428 def analyzeremotephases(repo, subset, roots):
425 def analyzeremotephases(repo, subset, roots):
429 """Compute phases heads and root in a subset of node from root dict
426 """Compute phases heads and root in a subset of node from root dict
General Comments 0
You need to be logged in to leave comments. Login now