2019-07-30 18:16:14 +03:00
|
|
|
import os
|
|
|
|
import random
|
|
|
|
import sys
|
|
|
|
import time
|
2018-09-25 23:09:39 +03:00
|
|
|
|
|
|
|
|
|
|
|
def waithook(ui, repo, **kwargs):
|
|
|
|
"""This hook is used to block pushes in some pushrebase tests
|
|
|
|
|
|
|
|
It spins until `.hg/flag` exists
|
|
|
|
"""
|
|
|
|
start = time.time()
|
|
|
|
repo._wlockfreeprefix.add("hookrunning")
|
2018-09-28 17:08:40 +03:00
|
|
|
repo.localvfs.write("hookrunning", "")
|
|
|
|
while not repo.localvfs.exists("flag"):
|
2018-09-25 23:09:39 +03:00
|
|
|
if time.time() - start > 20:
|
|
|
|
print >>sys.stderr, "ERROR: Timeout waiting for .hg/flag"
|
2018-09-28 17:08:40 +03:00
|
|
|
repo.localvfs.unlink("hookrunning")
|
2018-09-25 23:09:39 +03:00
|
|
|
return True
|
|
|
|
time.sleep(0.05)
|
2018-09-28 17:08:40 +03:00
|
|
|
repo.localvfs.unlink("hookrunning")
|
2018-09-25 23:09:39 +03:00
|
|
|
return False
|