From d579cdd7f6fd0712e012013664a8068dd0dd9703 Mon Sep 17 00:00:00 2001 From: David Greenberg Date: Fri, 11 Mar 2022 17:05:39 -0800 Subject: [PATCH] getdeps optionally can get hg info from env var (#911) Summary: X-link: https://github.com/rsocket/rsocket-cpp/pull/911 X-link: https://github.com/facebookexperimental/rust-shed/pull/32 X-link: https://github.com/facebookincubator/reindeer/pull/3 X-link: https://github.com/fairinternal/AIRStore/pull/36 X-link: https://github.com/facebookincubator/velox/pull/1197 X-link: https://github.com/facebookincubator/mvfst/pull/242 X-link: https://github.com/facebookexperimental/eden/pull/116 X-link: https://github.com/facebookincubator/fizz/pull/75 X-link: https://github.com/facebookincubator/katran/pull/157 X-link: https://github.com/facebook/watchman/pull/1011 X-link: https://github.com/facebook/wangle/pull/205 Pull Request resolved: https://github.com/facebook/proxygen/pull/401 X-link: https://github.com/facebook/openr/pull/129 X-link: https://github.com/facebook/fbzmq/pull/35 X-link: https://github.com/facebook/fb303/pull/26 X-link: https://github.com/facebook/bistro/pull/59 X-link: https://github.com/facebook/folly/pull/1734 X-link: https://github.com/facebook/fboss/pull/113 Adds an environment variable to getdeps to provide `hg` info to avoid calling `hg` directly. When using `getdeps` inside a containerized environment (which we need to build Research Super Cluster tooling with the correct linker attributes), `getdeps` fails because of unregistered mercurial extensions in the `hgrc`. This allows `getdeps` to be useable in an environment where the mercurial extensions used in a project aren't installed/available. Reviewed By: vivekspai Differential Revision: D34732506 fbshipit-source-id: 6475088fbf3323347095ca5af8a902382cf8f9d0 --- build/fbcode_builder/getdeps/fetcher.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/build/fbcode_builder/getdeps/fetcher.py b/build/fbcode_builder/getdeps/fetcher.py index a42ae58b9..3f45716d1 100644 --- a/build/fbcode_builder/getdeps/fetcher.py +++ b/build/fbcode_builder/getdeps/fetcher.py @@ -525,12 +525,15 @@ def get_fbsource_repo_data(build_options) -> FbsourceRepoData: if cached_data: return cached_data - cmd = ["hg", "log", "-r.", "-T{node}\n{date|hgdate}"] - env = Env() - env.set("HGPLAIN", "1") - log_data = subprocess.check_output( - cmd, cwd=build_options.fbsource_dir, env=dict(env.items()) - ).decode("ascii") + if "GETDEPS_HG_REPO_DATA" in os.environ: + log_data = os.environ["GETDEPS_HG_REPO_DATA"] + else: + cmd = ["hg", "log", "-r.", "-T{node}\n{date|hgdate}"] + env = Env() + env.set("HGPLAIN", "1") + log_data = subprocess.check_output( + cmd, cwd=build_options.fbsource_dir, env=dict(env.items()) + ).decode("ascii") (hash, datestr) = log_data.split("\n")