Updated Rust wrapper so that hg status works again in Eden.

Summary:
The storage format for dirstate data in Eden changed substantially in D6179950.
Although `status.rs` was modified as part of that change, it was only updated to
make it so the rust wrapper still compiled, but it did not maintain the
correctness of the overall function.

This revision is a port of the logic in `eden/py/dirstate.py` and
`eden/hg/eden/EdenThriftClient.py` so that the Python code in the Eden/Hg
extension behaves the same as that of the Rust wrapper.

The current implementation of `hg status` in Rust does not relativize paths to `$PWD`, so
it always behaves as if `--root-relative` was specified. This should be fixed in a
follow-up revision.

Reviewed By: jsgf

Differential Revision: D6717211

fbshipit-source-id: ca900e251d392a77c07cb7305c4d4a62def1c7ab
This commit is contained in:
Michael Bolin 2018-01-19 12:05:35 -08:00 committed by Facebook Github Bot
parent b6b2a08998
commit b6639e37a5
2 changed files with 35 additions and 2 deletions

View File

@ -5,6 +5,8 @@ python_library(
"//eden/cli:lib",
"//eden/fs/service:py-client",
"//eden/fs/service:thrift-py",
"//libfb/py:pathutils",
"//scm/telemetry/hg:hg",
],
external_deps = [
"py-hypothesis",

View File

@ -63,8 +63,7 @@ class HgRepository(repobase.Repository):
# Set HGRCPATH to make sure we aren't affected by the local system's
# mercurial settings from /etc/mercurial/
self.hg_environment['HGRCPATH'] = ''
self.hg_bin = distutils.spawn.find_executable(
'hg.real') or distutils.spawn.find_executable('hg')
self.hg_bin = find_hg_bin()
def hg(
self,
@ -215,3 +214,35 @@ class HgRepository(repobase.Repository):
else:
args = ['reset', rev]
self.hg(*args, stdout=None, stderr=None)
_hg_bin = None
def find_hg_bin() -> str:
global _hg_bin
if _hg_bin:
return _hg_bin
try:
from libfb.py import pathutils
_hg_bin = pathutils.get_build_rule_output_path(
'@/scm/telemetry/hg:hg',
pathutils.BuildRuleTypes.RUST_BINARY,
start_path=__file__
)
if _hg_bin:
return _hg_bin
except ImportError:
# Code to load the custom Hg wrapper was not available.
pass
_hg_bin = distutils.spawn.find_executable('hg.real')
if _hg_bin:
return _hg_bin
_hg_bin = distutils.spawn.find_executable('hg')
if _hg_bin:
return _hg_bin
raise Exception('No hg binary found!')