mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
75105421ce
Summary: Introduce separate wire types to allow protocol evolution and client API changes to happen independently. * Duplicate `*Request`, `*Entry`, `Key`, `Parents`, `RepoPathBuf`, `HgId`, and `revisionstore_types::Metadata` types into the `wire` module. The versions in the `wire` module are required to have proper `serde` annotations, `Serialize` / `Deserialize` implementations, etc. These have been removed from the original structs. * Introduce infallible conversions from "API types" to "wire types" with the `ToWire` trait and fallible conversions from "wire types" to "API types" with the `ToApi`. API -> wire conversions should never fail in a binary that builds succesfully, but wire -> API conversions can fail in the case that the server and client are using different versions of the library. This will cause, for instance, a newly-introduced enum variant used by the client to be deserialized into the catch-all `Unknown` variant on the server, which won't generally have a corresponding representation in the API type. * Cleanup: remove `*Response` types, which are no longer used anywhere. * Introduce a `map` method on `Fetch` struct which allows a fallible conversion function to be used to convert a `Fetch<T>` to a `Fetch<U>`. This function is used in the edenapi client implementation to convert from wire types to API types. * Modify `edenapi_server` to convert from API types to wire types. * Modify `edenapi_cli` to convert back to wire types before serializing responses to disk. * Modify `make_req` to use `ToWire` for converting API structs from the `json` module to wire structs. * Modify `read_res` to use `ToApi` to convert deserialized wire types to API types with the necessary methods for investigating the contents (`.data()`, primarily). It will print an error message to stderr if it encounters a wire type which cannot be converted into the corresponding API type. * Add some documentation about protocol conventions to the root of the `wire` module. Reviewed By: kulshrax Differential Revision: D23224705 fbshipit-source-id: 88f8addc403f3a8da3cde2aeee765899a826446d |
||
---|---|---|
.. | ||
async-runtime | ||
auth | ||
backingstore | ||
blackbox | ||
bookmarkstore | ||
cdatapack | ||
clib | ||
clidispatch | ||
cliparser | ||
commitcloudsubscriber | ||
commitstore/bench-serialize | ||
configparser | ||
cpython-async | ||
cpython-ext | ||
dag | ||
dev-logger | ||
drawdag | ||
edenapi | ||
edenfs-client | ||
encoding | ||
fsinfo | ||
fsyncglob | ||
hg-http | ||
hg-metrics | ||
hgcommands | ||
hgcommits | ||
hgtime | ||
http-client | ||
indexedlog | ||
linelog | ||
lz4-pyframe | ||
manifest | ||
manifest-tree | ||
metalog | ||
mincode | ||
minibench | ||
minibytes | ||
mpatch | ||
mpatch-sys | ||
mutationstore | ||
nodemap | ||
pathmatcher | ||
procinfo | ||
radixbuf | ||
renderdag | ||
revisionstore | ||
revlogindex | ||
spawn-ext | ||
taggederror | ||
taggederror-util | ||
third-party | ||
thrift-types | ||
tracing-collector | ||
treestate | ||
types | ||
util | ||
version | ||
vfs | ||
vlqencoding | ||
workingcopy | ||
xdiff | ||
xdiff-sys | ||
zstdelta | ||
zstore | ||
CMakeLists.txt | ||
README.md |
lib
Any native code (C/C++/Rust) that Mercurial (either core or extensions)
depends on should go here. Python code, or native code that depends on
Python code (e.g. #include <Python.h>
or use cpython
) is disallowed.
As we start to convert more of Mercurial into Rust, and write new paths entrirely in native code, we'll want to limit our dependency on Python, which is why this barrier exists.
See also hgext/extlib/README.md
, mercurial/cext/README.mb
.
How do I choose between lib
and extlib
(and cext
)?
If your code is native and doesn't depend on Python (awesome!), it goes here.
Otherwise, put it in hgext/extlib
(if it's only used by extensions) or
mercurial/cext
(if it's used by extensions or core).