Commit Graph

9 Commits

Author SHA1 Message Date
Matt Glazar
afde763cdb Improve typing of dirstate read and write functions
Summary:
* Add type annotations to struct.unpack results to prevent leaking Any.
* Make the type signature for read and write as similar as possible (without changing behavior). This will help a future diff (D10224078) which makes the signatures match exactly.

This diff should not change behavior.

Reviewed By: chadaustin

Differential Revision: D10224079

fbshipit-source-id: 5d43d6fbbc989f71dae006dc3d378600d49272d3
2018-10-08 15:14:44 -07:00
Matt Glazar
1314cc6be4 Add regression tests for dirstate serializer and deserializer
Summary: I want to make minor changes to eden.dirstate. Add some basic tests to increase code coverage from 0%.

Reviewed By: chadaustin

Differential Revision: D10223605

fbshipit-source-id: 09835d8052b1460915b4091488f525d4268b3e51
2018-10-08 13:49:53 -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
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
Adam Simpkins
954d8945b2 refactor CLI subcommand definitions
Summary:
Refactor the Eden CLI command so that all subcommands are implemented as
subclasses.  This helps keep the command line argument definitions together
with the logic for the command.

This is primarily just a code refactoring change, but I did include a few minor
behavioral changes to the help output:
- The command list is now always sorted alphabetically in the help output.
- The "help" subcommand can now show help for more than just one subcommand
  deep.  (e.g., `eden help stats io` now works correctly)
- I made some minor improvements to a few of the help strings.

Reviewed By: chadaustin

Differential Revision: D7673021

fbshipit-source-id: dc4c6db20a0fe7452d38bdafc6273e234dba8e4e
2018-04-19 17:59:51 -07:00
Adam Simpkins
21d2b6c46d Remove TARGETS files
Summary:
This removes the TARGETS files from the eden github repository.  The
open source buck build has been failing for several months, since buck
removed support for the thrift_library() rule.

I will potentially take a stab at adding CMake build support for Eden
at some point in the future.

Reviewed By: chadaustin

Differential Revision: D6893233

fbshipit-source-id: e6023094a807cf481ac49998c6f21b213be6c288
2018-02-20 19:57:45 -08:00
Michael Bolin
b77b390c9f Remove support for old dirstate format.
Summary:
We've been using the new format for long enough that I don't think we need to
keep the old migration code around anymore. I didn't add support for it in
D6717211, so I think we're better off just killing it at this point.

Reviewed By: wez

Differential Revision: D6762271

fbshipit-source-id: d7590f3402f2ac23446aa1858ea58eeae676c153
2018-01-19 13:06:10 -08:00
Adam Simpkins
53ac2a3ebe support reading the old .hg/dirstate format
Summary:
Update the eden.dirstate code to return parent information correctly even if
the .hg/dirstate file is still using the old format.

This does not return non-normal tuples correctly.  If we really wanted to we
could add the hgdirstate.thrift file back so we could parse the old dirstate
file correctly, but it doesn't really seem worthwhile for now.  Simply
returning the parents information will probably be good enough to help most of
our current users upgrade.

Reviewed By: bolinfest

Differential Revision: D6263602

fbshipit-source-id: 9b65335b0e98ba3fd79d2f220c82df18753ccfdc
2017-11-07 14:17:37 -08:00
Michael Bolin
5d738193e5 Store Hg dirstate data in Hg instead of Eden.
Summary:
This is a major change to how we manage the dirstate in Eden's Hg extension.

Previously, the dirstate information was stored under `$EDEN_CONFIG_DIR`,
which is Eden's private storage. Any time the Mercurial extension wanted to
read or write the dirstate, it had to make a Thrift request to Eden to do so on
its behalf. The upside is that Eden could answer dirstate-related questions
independently of the Python code.

This was sufficiently different than how Mercurial's default dirstate worked
that our subclass, `eden_dirstate`, had to override quite a bit of behavior.
Failing to manage the `.hg/dirstate` file in a way similar to the way Mercurial
does has exposed some "unofficial contracts" that Mercurial has. For example,
tools like Nuclide rely on changes to the `.hg/dirstate` file as a heuristic to
determine when to invalidate its internal caches for Mercurial data.

Today, Mercurial has a well-factored `dirstatemap` abstraction that is primarily
responsible for the transactions with the dirstate's data. With this split, we can
focus on putting most of our customizations in our `eden_dirstate_map` subclass
while our `eden_dirstate` class has to override fewer methods. Because the
data is managed through the `.hg/dirstate` file, transaction logic in Mercurial that
relies on renaming/copying that file will work out-of-the-box. This change
also reduces the number of Thrift calls the Mercurial extension has to make
for operations like `hg status` or `hg add`.

In this revision, we introduce our own binary format for the `.hg/dirstate` file.
The logic to read and write this file is in `eden/py/dirstate.py`. After the first
40 bytes, which are used for the parent hashes, the next four bytes are
reserved for a version number for the file format so we can manage file format
changes going forward.

Admittedly one downside of this change is that it is a breaking change.
Ideally, users should commit all of their local changes in their existing mounts,
shutdown Eden, delete the old mounts, restart Eden, and re-clone.

In the end, this change deletes a number of Mercurial-specific code and Thrift
APIs from Eden. This is a better separation of concerns that makes Eden more
SCM-agnostic. For example, this change removes `Dirstate.cpp` and
`DirstatePersistance.cpp`, replacing them with the much simpler and more
general `Differ.cpp`. The Mercurial-specific logic from `Dirstate.cpp` that turned
a diff into an `hg status` now lives in the Mercurial extension in
`EdenThriftClient.getStatus()`, which is much more appropriate.

Note that this reverts the changes that were recently introduced in D6116105:
we now need to intercept `localrepo.localrepository.dirstate` once again.

Reviewed By: simpkins

Differential Revision: D6179950

fbshipit-source-id: 5b78904909b669c9cc606e2fe1fd118ef6eaab95
2017-11-06 19:56:49 -08:00