mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
06fa75f637
Summary: This is the right method to write plain strings data to files. Reviewed By: quark-zju Differential Revision: D19675386 fbshipit-source-id: 1f939f79294cbc45f56944058649c384b674b880
30 lines
827 B
Python
30 lines
827 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.writeutf8("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
|