comparison mercurial/phases.py @ 22052:793f9276aeb9

pushkey: wrap pushkey phase movement in a transaction Phases are not yet inside the transaction, but we need to prepare for it. So we wrap the phase movement inside a transaction.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 06 Aug 2014 00:54:58 -0700
parents 1716a2671ec7
children 616a455b02ca
comparison
equal deleted inserted replaced
22051:e894de232f35 22052:793f9276aeb9
329 return keys 329 return keys
330 330
331 def pushphase(repo, nhex, oldphasestr, newphasestr): 331 def pushphase(repo, nhex, oldphasestr, newphasestr):
332 """List phases root for serialization over pushkey""" 332 """List phases root for serialization over pushkey"""
333 repo = repo.unfiltered() 333 repo = repo.unfiltered()
334 tr = None
334 lock = repo.lock() 335 lock = repo.lock()
335 try: 336 try:
336 currentphase = repo[nhex].phase() 337 currentphase = repo[nhex].phase()
337 newphase = abs(int(newphasestr)) # let's avoid negative index surprise 338 newphase = abs(int(newphasestr)) # let's avoid negative index surprise
338 oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise 339 oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise
339 if currentphase == oldphase and newphase < oldphase: 340 if currentphase == oldphase and newphase < oldphase:
341 tr = repo.transaction('pushkey-phase')
340 advanceboundary(repo, newphase, [bin(nhex)]) 342 advanceboundary(repo, newphase, [bin(nhex)])
343 tr.close()
341 return 1 344 return 1
342 elif currentphase == newphase: 345 elif currentphase == newphase:
343 # raced, but got correct result 346 # raced, but got correct result
344 return 1 347 return 1
345 else: 348 else:
346 return 0 349 return 0
347 finally: 350 finally:
351 if tr:
352 tr.release()
348 lock.release() 353 lock.release()
349 354
350 def analyzeremotephases(repo, subset, roots): 355 def analyzeremotephases(repo, subset, roots):
351 """Compute phases heads and root in a subset of node from root dict 356 """Compute phases heads and root in a subset of node from root dict
352 357