Commit Graph

29 Commits

Author SHA1 Message Date
Genevieve Helsel
aae83490c9 compare blob contents sha1 in Diff.cpp
Summary: Even if blobs have different hashes, they could have the same contents. For example, if between the two revisions being compared, if a file was changed and then later reverted. In that case, the contents would be the same but the blobs would have different hashes. Currently, `getScmStatusBetweenRevisions()` would report false positives in this case. This is also needed so we do not report false positives in `getScmStatus()` when hit this code path

Reviewed By: simpkins

Differential Revision: D18647086

fbshipit-source-id: 66e12648a24fd7e5612eee5e599a5b81c7c5f2d1
2019-11-22 08:09:37 -08:00
Andres Suarez
fbdb46f5cb Tidy up license headers
Reviewed By: chadaustin

Differential Revision: D17872966

fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
2019-10-11 05:28:23 -07:00
Adam Simpkins
9bfb48c921 update license headers in .py files
Summary:
Update the copyright & license headers in Python files to reflect the
relicensing to GPLv2

Reviewed By: wez

Differential Revision: D15487088

fbshipit-source-id: 9f2138dff41048d2c35f15e09a04ae5a9c9c80dd
2019-06-19 17:02:46 -07:00
Adam Simpkins
53a6513e14 clean up arguments to the EdenFS class in the integration tests
Summary:
Clean up the `EdenFS` class construction.

Previously it accepted the `eden_dir`, `etc_eden_dir`, and `home_dir`
arguments as separate parameters.  If `etc_eden_dir` or `home_dir` were not
specified it would not pass these arguments to `edenfs`, allowing the default
values to be used.  This is undesirable for most tests.

Now it accepts a `base_dir` argument.  Explicit values for the `eden_dir`,
`etc_eden_dir`, and `home_dir` parameters can still be specified (this is used
for the snapshot tests), but if they aren't specified, default locations
inside the `base_dir` will be used instead.

This also cleans up some of the code to use `pathlib.Path` values instead of
plain `str` objects in more places.

Reviewed By: strager

Differential Revision: D15756358

fbshipit-source-id: 3e87ddc98d15fcb7f60c6c3116d4fcc8e49432ea
2019-06-11 18:27:21 -07:00
Matt Glazar
9e6a39e951 Factor duplicate code into EdenTestCase.get_counters
Summary:
In another diff, Adam Simpkins noticed that HgImporterStatsTest.get_counters was clunky and that the logic belongs in the EdenTestCase base class.

Hoist HgImporterStatsTest.get_counters into EdenTestCase. Also avoid reusing the Thrift client between calls to get_counters because edenfs might restart between calls (in which case the old Thrift client won't work).

Reviewed By: wez

Differential Revision: D15514537

fbshipit-source-id: 0ae25106baa0e5b2d857b0bb2552d884b9b270ef
2019-05-28 15:43:18 -07:00
Matt Glazar
f33c394da5 Fix crash for getSHA1(./hello)
Summary:
getSHA1 is only handling std::system_error. If another kind of exception is thrown, it's never caught and edenfs crashes.

Calling EdenMount::getInode with a path such as "./hello" will cause a std::domain_error to be thrown. Since std::domain_error is not derived from std::system_error, `getSHA1ForPathDefensively(["./hello"])` crashes edenfs.

Fix the crash by forwarding all exceptions over Thrift, not just std::system_error-s.

Reviewed By: simpkins

Differential Revision: D13386450

fbshipit-source-id: 06262dad30a5508ed482c9e8979b61aa9643280a
2018-12-07 16:34:42 -08:00
Adam Simpkins
a0411b8a51 add member type annotations to make pyre happy
Summary:
Add type annotations for class member variables.  The pyre type checker has
some limited automatic type detection for member variables set in
`__init__()`, but in general it expects member variables to be explicitly
declared at the top-level of the class.

Reviewed By: strager

Differential Revision: D13051092

fbshipit-source-id: 080259ab3f422ffae2b908ed610062237105ccbe
2018-11-14 13:03:09 -08:00
Adam Simpkins
7c7aa119cd fix str/bytes conversion for thrift API calls
Summary:
The thrift APIs accept path names and commit IDs as binary data (python bytes)
rather than unicode strings.  Our python code got this wrong in several
locations.  It looks like mypy didn't previously flag this since mypy doesn't
actually figure out the correct type for the thrift `client` object, and
seemed to just be largely ignoring it.  I plan to update the code so that mypy
can figure out out the client type correctly.  Fixing these type errors is
required to make sure we won't get type errors once that is changed.

This just simply uses `encode("utf-8")` for now.  In the future the path
arguments should be converted to `pathlib.Path`, which will do a slightly
smarter conversion, and avoid errors on non-UTF-8 binary data.  In the
meantime, I believe that just using `encode("utf-8")` preserves what the
thrift code was doing implicitly before, and does not make handling of
non-UTF-8 data any worse than it was before.

Reviewed By: strager

Differential Revision: D13051094

fbshipit-source-id: 94cb62f3dd78b8e854a72a392fe8fdfad5ffd4cb
2018-11-14 13:03:09 -08:00
Chad Austin
b861392284 Fix eden debug unload . from the root of the checkout
Summary:
The C++ code disallows use of "." in RelativePaths, but it's
reasonable for users of the Thrift API to pass "." to indicate the
root of the mount. Handle that in the EdenServiceHandler.

Reviewed By: strager

Differential Revision: D9647776

fbshipit-source-id: b61c2d1c0dcd69ccfa38bf27379281d10cdf1ceb
2018-09-13 14:55:03 -07:00
Wez Furlong
cfde0c0717 define paths as binary rather than strings in the thrift interface
Summary:
This prevents `hg status` from blowing up with a UTF-8 decode
error inside the generated thrift code.

Push safety concerns:
* This doesn't change the wire representation of the data
* Existing clients that believe it to be a string will continue to have
  the same behavior
* Buck has its own copy of an older version of the thrift spec, so it will
  continue to work "OK".
* When buck resyncs with our thrift file, some changes will likely be needed
  to convert the byte arrays to strings or paths or whatever is appropriate
  for bucks internal API

Work "OK" above means that clients that currently believe that `string` is
utf-8 encoded will have a runtime error if we ever send them a path that
is not utf-8.  This is the behavior prior to this diff and will continue
to be the behavior for clients (like buck) that have an older version
of the thrift file.

Reviewed By: simpkins

Differential Revision: D9270843

fbshipit-source-id: b01135aec9152aaf5199e1c654ddd7f61c03717e
2018-08-11 01:35:49 -07:00
Chad Austin
d5575b3374 enable typechecking on Eden Python libraries
Summary: Fix a bunch of mypy errors in our Python.

Reviewed By: wez

Differential Revision: D9144139

fbshipit-source-id: d91a019f8580bc57fd510d307325089a7e8a6155
2018-08-03 15:07:00 -07:00
Lukasz Langa
deee232d74 Upgrade to 18.5b1
Summary: Mostly empty lines removed and added.  A few bugfixes on excessive line splitting.

Reviewed By: cooperlees

Differential Revision: D8198776

fbshipit-source-id: 4361faf4a2b9347d57fb6e1342c494575f2beb67
2018-05-30 01:11:47 -07:00
Wez Furlong
c83849e5af enable Black python formatting and apply to eden
Summary: No functional changes

Reviewed By: simpkins

Differential Revision: D7945989

fbshipit-source-id: e267e6134d87570427b3fdf5974006dce5774113
2018-05-09 21:37:07 -07:00
Michael Bolin
a24cffb99b Move test_glob out of ThriftTest and into its own test.
Summary:
I would like to to test more inputs for `glob()` with different characteristics.
I think this would be more logically organized when divided across a number of
test methods in a single `GlobTest` class.

This revision does a straight move of the eixsting `test_glob()` method without
introducing any new test cases.

Reviewed By: chadaustin

Differential Revision: D7741506

fbshipit-source-id: 141341d74265f3949ed7523f40a56f98d95ee13e
2018-04-26 14:17:04 -07:00
Michael Bolin
b07ddbc2b3 Fix flake8 warnings in eden/integration folder.
Summary:
These were making some noise in the Nuclide diagnostics pane.

In the course of making these changes, I ended up reformatting
some files, as well. Perhaps we should flag flake8 and autoformat
violations more aggressively in CI now?

Reviewed By: chadaustin

Differential Revision: D7658030

fbshipit-source-id: b52a29b1cc242967f868dcc8ee46ec1bb9bdfbee
2018-04-18 12:42:33 -07:00
Adam Simpkins
398a824aac add type annotations to more of the integration tests
Summary:
We already had type annotations on most of the `hg` integration tests.  This
adds them for the top-level (non-source-control-specific) tests.

typeseverywhere

Reviewed By: wez

Differential Revision: D7459281

fbshipit-source-id: 41266b232ded510d6b63dd3e62c272a0cd6a0e1a
2018-04-04 17:55:11 -07:00
Adam Simpkins
a21f0763ba restructure @eden_repo_test decorator to make mypy happy
Summary:
Update the eden_repo_test decorator so that it no longer automatically adds
`EdenRepoTestBase` as a parent class.  Individual test classes still specify
`EdenRepoTest` as their parent now.

This enables `mypy` to correctly figure out that the individual test classes
derive from `unittest.TestCase`.

This basically does the same thing as D6268258 for the top-level integration
tests.

Reviewed By: wez

Differential Revision: D7459280

fbshipit-source-id: 5d18bd241dad77d55541ac3fa1d169496ffe7003
2018-04-04 17:55:11 -07:00
Adam Simpkins
567c744991 improve how some of the integration tests clean up thrift clients
Summary:
Perform cleanup with an `addCleanup()` function rather than in `tearDown()`.
This is slightly simpler, but also avoids throwing an exception in `tearDown()`
if `setUp()` failed before it created the thrift client.

Reviewed By: wez

Differential Revision: D7436636

fbshipit-source-id: fe525c1fac86bb866c560cca0ad940ea87d96f07
2018-03-28 22:22:32 -07:00
Adam Simpkins
685077677e update getScmStatusBetweenRevisions() to avoid creating inode objects
Summary:
Update the getScmStatusBetweenRevisions() thrift call to use the new
diffCommits() function that diffs source control Tree objects without creating
TreeInode objects to perform the diff.

This addresses two bugs:
- Each call to EdenMount::diffRevisions() constructed a new root inode
  associated with the mount, and this would never get destroyed.  It was not
  destroyed at the end of the diffRevisions() call since inodes are normally
  not destroyed immediately when they are unreferenced.  It was not destroyed
  during EdenMount::shutdown() since EdenMount didn't have any references to
  these additional root inode structures and their children.
- EdenMount::diffRevisions() incorrectly swapped ADDED and REMOVED statuses in
  the result.

Reviewed By: wez

Differential Revision: D7341609

fbshipit-source-id: 16e755a0ff685f51c977c3b27d6af96908f33494
2018-03-20 16:47:12 -07:00
Adam Simpkins
f6685834de update eden to be more liberal when parsing BinaryHash arguments
Summary:
Update Eden's thrift service handler code to accept BinaryHash arguments either
as 20-byte binary values or as 40-byte hexadecimal values.

This will make it easier to transition APIs like getScmStatusBetweenRevisions()
to use 20-byte binary hash arguments without breaking existing clients.

Reviewed By: wez

Differential Revision: D7341607

fbshipit-source-id: 3e952211900d3ec4b9c2073cf3afd55ae7e253ea
2018-03-20 16:47:12 -07:00
Adam Simpkins
dfe7cac4c2 add an integration test for getScmStatusBetweenRevisions()
Summary:
Add an integration test for the getScmStatusBetweenRevisions() thrift call.

This call apparently gets the ADDED and REMOVED states backwards.  For now the
test checks for the current (incorrect) behavior.

This also fixes the thrift definition for this function to stop using the
BinaryHash typedef.  Unlike most of our other thrift functions this method
appears to require the arguments as 40-byte hexadecimal strings.

Reviewed By: wez

Differential Revision: D7341606

fbshipit-source-id: 73cbd0ecf4445da6b1f0ef9cf6d9dce47e6fb593
2018-03-20 15:07:39 -07:00
Adam Simpkins
e8fd893bb2 set the client path in the listMounts() response
Summary: Fix a simple TODO in EdenServiceHandler.cpp

Reviewed By: chadaustin

Differential Revision: D7329635

fbshipit-source-id: b42b2cc13be3ad5b18a629ed15f6c51cea52fbda
2018-03-19 17:01:52 -07:00
Wez Furlong
8a77f57ea3 delete flakey test_unload_free_inodes_age
Summary:
chadaustin is going to think about how to test this
in unit tests intestead :-p

Reviewed By: chadaustin

Differential Revision: D6951788

fbshipit-source-id: 137f285f3a1f080ce43392a621c73640ce3a9bf7
2018-02-09 12:13:56 -08:00
Wez Furlong
b5c47a9ed7 adjust expectations for inode unload integration test
Summary: This should make it less flaky

Reviewed By: simpkins

Differential Revision: D6908454

fbshipit-source-id: 07622b469ec635972290c3a4e5d1ed4b05ddd51a
2018-02-05 22:08:54 -08:00
Jyothsna Konisa
72b61a5ddc Changes to return unloaded inode count for TreeInode::unloadChildrenNow
Summary:
1.Modified `TreeInode::unloadChildrenNow()` to return number of inodes that have been unloaded.
2.Modified `EdenServiceHandler::unloadInodeForPath()` to return number of inodes that are unloaded.

Reviewed By: simpkins

Differential Revision: D5627539

fbshipit-source-id: 4cdb0433dced6bf101158b9e6f8c35de67d9abbe
2017-08-22 19:50:00 -07:00
Jyothsna Konisa
371cfa097d TestCase to verify unloadChildrenNow with age
Summary:
Added a test case `test_unload_free_inodes_age` to verify the behaviour of unloadChildrenNow with age parameter.
Added new parameter age to `unloadInodeForPath` in eden.thrift, and `EdenServiceHandler`.
Modified `do_unload_inodes` function in `debug.py` to support the new behaviour.

Reviewed By: simpkins

Differential Revision: D5565859

fbshipit-source-id: a35053725be26bc906cf158969cbe21db1cbadde
2017-08-22 19:50:00 -07:00
Simon Jensen
3a0e66677b Cache invalidation thrift api
Summary: Provide a thrift interface to invalidate the cache for an inode denoted by path.

Reviewed By: simpkins

Differential Revision: D5655387

fbshipit-source-id: 887aa4963d216a0d8eed93b6fb8721632cc31d19
2017-08-21 16:05:44 -07:00
Jyothsna Konisa
299f7d1373 Integration Test for UnnloadFreeInodes
Summary:
1. Moved read, write, mkdir, rm methods in hg/lib/hg_extension_test_base.py to lib/test_case.py.
2. Added integration test case to test unload free inodes.

Reviewed By: simpkins

Differential Revision: D5277870

fbshipit-source-id: b93b6049a10357cf8c92366e6dca3968f7f30c30
2017-06-22 22:38:47 -07:00
Adam Simpkins
8884b46b3f move integration tests to eden/integration
Summary:
Move the integration tests from eden/fs/integration up one directory, to
eden/integration.

The main benefit is that this makes it easy to run just the edenfs unit tests
by running "buck test eden/fs/...".  These unit tests complete much more
quickly than the full set of integration tests, providing a faster test suite
to re-run repeatedly during development.  The integration tests can be run with
"buck test eden/integration/...", and the full set of tests can still be run
with "buck test eden/..."

Reviewed By: wez

Differential Revision: D4490247

fbshipit-source-id: 5ceb5a19526f56e1cb926f352fa30ad2f1212c05
2017-01-31 14:41:14 -08:00