mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
a152fa4585
Summary: Migrate away from streaming Thrift Python, and instead implement `eden trace hg` in C++, which will eventually let us support Windows. This also fixes an unexplained crash in `eden trace hg` on macOS. Reviewed By: xavierd Differential Revision: D25515377 fbshipit-source-id: 1916aa7f09df37e9dee3479a858932c724f8aed4
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
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 absolute_import, division, print_function, unicode_literals
|
|
|
|
import argparse
|
|
import os
|
|
import pathlib
|
|
import sys
|
|
|
|
from . import subcmd as subcmd_mod
|
|
from .cmd_util import require_checkout
|
|
from .subcmd import Subcmd
|
|
|
|
|
|
trace_cmd = subcmd_mod.Decorator()
|
|
|
|
|
|
def get_trace_stream_command() -> pathlib.Path:
|
|
try:
|
|
return pathlib.Path(os.environ["EDENFS_TRACE_STREAM"])
|
|
except KeyError:
|
|
return pathlib.Path("/usr/local/libexec/eden/eden_trace_stream")
|
|
|
|
|
|
@trace_cmd("hg", "Trace hg object fetches")
|
|
class TraceHgCommand(Subcmd):
|
|
def setup_parser(self, parser: argparse.ArgumentParser) -> None:
|
|
parser.add_argument(
|
|
"checkout", default=None, nargs="?", help="Path to the checkout"
|
|
)
|
|
|
|
async def run(self, args: argparse.Namespace) -> int:
|
|
if sys.platform == "win32":
|
|
print("Not yet supported on Windows", file=sys.stderr)
|
|
return 1
|
|
instance, checkout, _rel_path = require_checkout(args, args.checkout)
|
|
|
|
trace_stream_command = get_trace_stream_command()
|
|
# TODO: Use subprocess.call on Windows.
|
|
os.execl(
|
|
trace_stream_command,
|
|
os.fsencode(trace_stream_command),
|
|
b"--mountRoot",
|
|
os.fsencode(checkout.path),
|
|
b"--trace=hg",
|
|
)
|