mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
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.
This commit is contained in:
parent
322ec1b757
commit
4d38b093fd
@ -331,13 +331,16 @@ def listphases(repo):
|
|||||||
def pushphase(repo, nhex, oldphasestr, newphasestr):
|
def pushphase(repo, nhex, oldphasestr, newphasestr):
|
||||||
"""List phases root for serialization over pushkey"""
|
"""List phases root for serialization over pushkey"""
|
||||||
repo = repo.unfiltered()
|
repo = repo.unfiltered()
|
||||||
|
tr = None
|
||||||
lock = repo.lock()
|
lock = repo.lock()
|
||||||
try:
|
try:
|
||||||
currentphase = repo[nhex].phase()
|
currentphase = repo[nhex].phase()
|
||||||
newphase = abs(int(newphasestr)) # let's avoid negative index surprise
|
newphase = abs(int(newphasestr)) # let's avoid negative index surprise
|
||||||
oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise
|
oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise
|
||||||
if currentphase == oldphase and newphase < oldphase:
|
if currentphase == oldphase and newphase < oldphase:
|
||||||
|
tr = repo.transaction('pushkey-phase')
|
||||||
advanceboundary(repo, newphase, [bin(nhex)])
|
advanceboundary(repo, newphase, [bin(nhex)])
|
||||||
|
tr.close()
|
||||||
return 1
|
return 1
|
||||||
elif currentphase == newphase:
|
elif currentphase == newphase:
|
||||||
# raced, but got correct result
|
# raced, but got correct result
|
||||||
@ -345,6 +348,8 @@ def pushphase(repo, nhex, oldphasestr, newphasestr):
|
|||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
finally:
|
finally:
|
||||||
|
if tr:
|
||||||
|
tr.release()
|
||||||
lock.release()
|
lock.release()
|
||||||
|
|
||||||
def analyzeremotephases(repo, subset, roots):
|
def analyzeremotephases(repo, subset, roots):
|
||||||
|
Loading…
Reference in New Issue
Block a user