sapling/tests/hgsql/waithook.py
Mark Thomas 0fa782e83d localrepo: split vfs into localvfs and sharedvfs
Summary:
Split the `repo.vfs` object into two.  When a repo is not shared, these are
both the `.hg` directory of the repo.  When it is shared:

* `repo.localvfs` represents the `.hg` directory of the local repository.
* `repo.sharedvfs` represents the `.hg` directory of the shared primary
  repository.

The old `vfs` is an alias for `localvfs`.  In the future, access through
this name will be deprecated to force callers to think whether they want
the local or shared hg directory.

Reviewed By: quark-zju

Differential Revision: D9699160

fbshipit-source-id: 6600df855c59b6df13e919399192789a873231c6
2018-09-28 07:23:00 -07:00

20 lines
594 B
Python

import time, sys, os, random
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 >>sys.stderr, "ERROR: Timeout waiting for .hg/flag"
repo.localvfs.unlink("hookrunning")
return True
time.sleep(0.05)
repo.localvfs.unlink("hookrunning")
return False