sapling/eden/scm/tests/hgsql/waithook.py
Genevieve Helsel e0fac9b23c import print_function to use print as function in python2
Summary: in python3, print becomes a function, import print_fuction to use in python 2.(ran fix_print_with_import)

Reviewed By: lisroach, quark-zju, sfilipco

Differential Revision: D19588356

fbshipit-source-id: b7cf519058ae3909ba7813618719bbd09800e73a
2020-01-28 13:57:59 -08:00

30 lines
823 B
Python

# 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
import os
import random
import sys
import time
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")
repo.localvfs.write("hookrunning", "")
while not repo.localvfs.exists("flag"):
if time.time() - start > 20:
print("ERROR: Timeout waiting for .hg/flag", file=sys.stderr)
repo.localvfs.unlink("hookrunning")
return True
time.sleep(0.05)
repo.localvfs.unlink("hookrunning")
return False