Commit d8e90515 authored by Wez Furlong's avatar Wez Furlong Committed by Facebook GitHub Bot

getdeps: partially educate getdeps about EdenFS on Windows

Summary:
I noticed that copytree was taking forever and realized
that it wasn't issuing a prefetch call so I started looking in here;
this commit teaches getdeps how to recognize and EdenFS repo on
Windows but skips calling prefetch on Windows.

Currently the prefetch implementation triggers some very slow
processing in mercurial that is slower to start than just
enumerating the files in the opensource build.

It turned out that my original problem was just that my credentials
had expired and we weren't surfacing that error on Windows yet.

Reviewed By: simpkins

Differential Revision: D20755905

fbshipit-source-id: 8d3695cdd1f04199d1d409895482b8c706285d5f
parent ae4d15fd
......@@ -13,6 +13,7 @@ import subprocess
import sys
import tempfile
from .copytree import containing_repo_type
from .envfuncs import Env, add_path_entry
from .fetcher import get_fbsource_repo_data
from .manifest import ContextGenerator
......@@ -25,19 +26,6 @@ except ImportError:
pass
def containing_repo_type(path):
while True:
if os.path.exists(os.path.join(path, ".git")):
return ("git", path)
if os.path.exists(os.path.join(path, ".hg")):
return ("hg", path)
parent = os.path.dirname(path)
if parent == path:
return None, None
path = parent
def detect_project(path):
repo_type, repo_root = containing_repo_type(path)
if repo_type is None:
......
......@@ -9,21 +9,42 @@ import os
import shutil
import subprocess
from .platform import is_windows
PREFETCHED_DIRS = set()
def is_eden(dirpath):
"""Returns True if the specified directory is the root directory of,
or is a sub-directory of an Eden mount."""
return os.path.islink(os.path.join(dirpath, ".eden", "root"))
def containing_repo_type(path):
while True:
if os.path.exists(os.path.join(path, ".git")):
return ("git", path)
if os.path.exists(os.path.join(path, ".hg")):
return ("hg", path)
parent = os.path.dirname(path)
if parent == path:
return None, None
path = parent
def find_eden_root(dirpath):
"""If the specified directory is the root directory of, or is a
sub-directory of an Eden mount, returns the canonical absolute path
to the root of that Eden mount."""
return os.readlink(os.path.join(dirpath, ".eden", "root"))
"""If the specified directory is inside an EdenFS checkout, returns
the canonical absolute path to the root of that checkout.
Returns None if the specified directory is not in an EdenFS checkout.
"""
if is_windows():
repo_type, repo_root = containing_repo_type(dirpath)
if repo_root is not None:
if os.path.exists(os.path.join(repo_root, ".eden", "config")):
return os.path.realpath(repo_root)
return None
try:
return os.readlink(os.path.join(dirpath, ".eden", "root"))
except OSError:
return None
def prefetch_dir_if_eden(dirpath):
......@@ -33,14 +54,20 @@ def prefetch_dir_if_eden(dirpath):
so we help accelerate things by performing a prefetch on the
source directory """
global PREFETCHED_DIRS
if not is_eden(dirpath) or dirpath in PREFETCHED_DIRS:
if is_windows():
# prefetch takes longer than not prefetching our opensource
# projects until we cut over to the new globfiles implementation
return
if dirpath in PREFETCHED_DIRS:
return
root = find_eden_root(dirpath)
if root is None:
return
rel = os.path.relpath(dirpath, root)
print("Prefetching %s..." % rel)
# TODO: this should be edenfsctl but until I swing through a new
# package deploy, I only have `eden` on my mac to test this
subprocess.call(["eden", "prefetch", "--repo", root, "--silent", "%s/**" % rel])
subprocess.call(
["edenfsctl", "prefetch", "--repo", root, "--silent", "%s/**" % rel]
)
PREFETCHED_DIRS.add(dirpath)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment