2020-01-29 00:56:02 +03:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
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:
|
2020-01-29 00:56:02 +03:00
|
|
|
print("ERROR: Timeout waiting for .hg/flag", file=sys.stderr)
|
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
|