Commit Graph

593 Commits

Author SHA1 Message Date
Jun Wu
9361d54b04 indexedlog: make sure meta file is created
Summary:
Previously, `load_or_create_meta` could return without actually creating the
meta file. That leads to problems when `load_or_create_meta` is called a
second time via `flush()`, it rewrites the primary file incorrectly. On Windows,
it will fail to rewrite the primary file.

Fix it by actually writing a meta file before returning.

Reviewed By: sfilipco

Differential Revision: D14568118

fbshipit-source-id: da3ad42bf48a923d732b1719839ca1953bd2b06c
2019-03-22 11:37:35 -07:00
Jun Wu
7e77bf81f0 indexedlog: rustfmt files
Summary: As the title.

Reviewed By: sfilipco

Differential Revision: D14568120

fbshipit-source-id: 7f2d8fb31e8f6c57976996e41f7a61503f5873a5
2019-03-22 11:37:35 -07:00
Arun Kulshreshtha
54e5f56277 types: add types for batched eden api requests
Summary: This diff adds serializable types representing batch requests for the Eden API. Just like the response types, these types must live the Mercurial's `types` crate so that they can be shared between the client and server.

Reviewed By: quark-zju

Differential Revision: D14573332

fbshipit-source-id: c31d718e6a97829ce1acfc25b8853dc3761323a7
2019-03-21 23:11:53 -07:00
Arun Kulshreshtha
4c1f11a751 types: fix mock node values
Summary: The mock values for the `Node` type are intended to have hashes that consist of a repeated digit (e.g., `1111111111111111111111111111111111111111`). However, since the bytes were specified using a single hex digit instead of two, the hashes were actually like `0101010101010101010101010101010101010101`. This diff fixes the values so they look as expected.

Reviewed By: quark-zju

Differential Revision: D14557546

fbshipit-source-id: 23651d70b9715d2fb77db162f689b87d9d43e5a2
2019-03-21 14:29:20 -07:00
Stefan Filip
e3b9873beb types: correctly import lazy_static in cargo
Summary: Fixes cargo test.

Reviewed By: quark-zju

Differential Revision: D14546435

fbshipit-source-id: daae0035871202fa3d221e11b0ea66199ded39d2
2019-03-20 19:56:14 -07:00
Stefan Filip
06704f2db2 radixbuf: add ignore marker to documentation blocks
Summary:
https://doc.rust-lang.org/rustdoc/documentation-tests.html#syntax-reference

Rust will treat an indentation of 4 or more spaces as a fenced code block and
attempt to run it as a docblock test

Reviewed By: singhsrb

Differential Revision: D14543987

fbshipit-source-id: 92f78e9e052befba0bd3eea80ac171f651f2fced
2019-03-20 19:56:14 -07:00
Stefan Filip
9c90eb2e9c radixbuf: cargo fmt
Summary: Formatting

Reviewed By: singhsrb

Differential Revision: D14543986

fbshipit-source-id: 5aae3a6166c315872102ab90d87d46d782682bc8
2019-03-20 19:56:14 -07:00
Stefan Filip
5e147ca3b7 commitcloudsubscriber: updates tests.rs
Summary:
The main issue is that cargo test fails preventing adding sandcastle
configuration that would run these tests on CI.

Reviewed By: singhsrb

Differential Revision: D14543988

fbshipit-source-id: c299148cce01316fad872b9cf8e15dea6633da48
2019-03-20 19:56:14 -07:00
Stefan Filip
ca6052e70c revisionstore: update rand package
Summary: This fixes the build in test mode.

Differential Revision: D14533840

fbshipit-source-id: baa40261f17cdc8881d99a52a7f5cbd1ff66307a
2019-03-20 19:56:14 -07:00
Xavier Deguillard
bee64d1535 asyncpacks: make the Metadata mandatory when adding to a asyncdatapack
Summary:
Similarly to the previous change let's make the asyncmutabledatapack force the
Metadata to be present.

Reviewed By: sfilipco

Differential Revision: D14443510

fbshipit-source-id: 26f851e8d38297dcc37410f0df6a69083531d516
2019-03-19 16:24:50 -07:00
Xavier Deguillard
1c1b1fadc7 revisionstore: make the Metadata mandatory when adding data to a datapack
Summary:
Now that mutablepacks can only create v1 packfile, we can force the Metadata to
not be optional. The main reason for doing this is to avoid issues where LFS
data is stored without its corresponding LFS flag. This can cause issue down
the line as LFS data will be intepreted as is, instead of being interpreted as
a pointer to the LFS blob.

Reviewed By: sfilipco

Differential Revision: D14443509

fbshipit-source-id: 9e7812017fc1356072278496406648f935024f92
2019-03-19 16:24:50 -07:00
Xavier Deguillard
10373e38e2 revisionstore: Force mutabledatapack to be created with v1
Summary:
The v0 doesn't support flags like whether the data is actually an LFS pointer. Let's simply
forbid creating them.

Reviewed By: quark-zju

Differential Revision: D14443512

fbshipit-source-id: 6ffa2e8fda2b2baba0aae53e749bc9248594a134
2019-03-19 16:24:50 -07:00
Xavier Deguillard
a3cee67af5 revisionstore: ignore more errors in repack_packs
Summary:
These last 2 errors are still considered fatal, but shouldn't be and are most
likely transient. Failing to open a packfile that was successfully opened
before can for instance happen when the file is removed by another process, or
if it somehow become corrupted. Failing the removal of the pack-file should no
longer be an issue, but if it fails, we can also ignore it with the reasoning
that the next repack will take care of it.

Reviewed By: sfilipco

Differential Revision: D14441288

fbshipit-source-id: 6c2758c2a88fd5d2d83b55defe3d263ee9f974a1
2019-03-19 16:19:14 -07:00
Arun Kulshreshtha
e697e7d994 types: add types for batch responses
Summary: In order to send batch responses from the API server for data fetching operations, we need to define the types sent over the wire from within `/scm/hg/lib` so that we can deserialize them from within Mercurial. For ease of use, these types implement `IntoIterator` to allow easily iterating over the content (performing type conversions where needed).

Reviewed By: quark-zju

Differential Revision: D14517259

fbshipit-source-id: 5ee867d8386e6b99cb5b4ed96338aeb7eb6a3e44
2019-03-19 14:28:48 -07:00
Arun Kulshreshtha
2418ee548c types: add mock values for Node and Key
Summary: When writing tests, it is often desirable to be able to quickly get a dummy value for a `Node` hash or `Key`. Trying to construct one on the spot can be overly verbose, so let's define some mock values that can be used by tests. This is similar to what Mononoke does (e.g., https://fburl.com/p9u55uye).

Reviewed By: quark-zju

Differential Revision: D14517258

fbshipit-source-id: e3d4cdd60010f44ca681d7a87e6124fe79f8a4c6
2019-03-19 14:28:48 -07:00
Arun Kulshreshtha
ef3f3dea44 types: rename LooseHistoryEntry and PackHistoryEntry
Summary: `LooseHistoryEntry` and `PackHistoryEntry` aren't the best names for these types, since the latter is what most users should use, whereas the former should only typically used for data transmission. As such, we should rename these to clarify the intent.

Differential Revision: D14512749

fbshipit-source-id: 5293df89766825077b2ba07224297b958bf46002
2019-03-18 19:50:19 -07:00
Xavier Deguillard
41d275ad36 revisionstore: ignore transient errors during repack
Summary:
Corrupted packfiles, or background removal of them could cause repack to fail,
let's simply ignore these transient errors and continue repacking.

Reviewed By: DurhamG

Differential Revision: D14373901

fbshipit-source-id: afe88e89a3bd0d010459975abecb2fef7f8dff6f
2019-03-11 18:15:45 -07:00
Stefan Filip
2eb3c24956 configparser: upgrade crate to rust edition 2018
Summary: As requested in D14380687.

Differential Revision: D14393014

fbshipit-source-id: 365c713b6f5a106cef0b945e63f224b7651d0e8f
2019-03-11 15:32:55 -07:00
Stefan Filip
3f33e9f3e9 configparser: fix XDG config loading
Summary:
The spec for both XDG and Mercurial say that when the XDG_CONFIG_HOME variable
is not set, we should default to $HOME/.config.

Windows and macOS also have a designated config folder outside of the home directory.
The `dirs` crate provides consistent access to this folder. I see no harm in looking at config
 folders across all operating systems.

Reviewed By: quark-zju

Differential Revision: D14380686

fbshipit-source-id: 5e5a9cd4694aaa49fbc526f4917dc4afdaeb9842
2019-03-11 15:32:55 -07:00
Stefan Filip
403e1c7ad2 configparser: rustfmt on hg.rs
Summary: Automatic formatting using rustfmt

Differential Revision: D14380687

fbshipit-source-id: 5f7832419b0941c00e2399c902454862580988a4
2019-03-11 15:32:55 -07:00
Stefan Filip
41e75fce3f manifest: fix infinite loop when cursor encounters error
Summary:
quark-zju noticed in code review that `Cursor` could get into an infinite loop when
it's results would be collected into a Vec<_>. That was the motive that I
needed to update `Cursor` to transition to `State::Done` when the cursor
encounters an error. Previously I felt that users of `Cursor` would only be
empowered by having the ability to retry the failure.

Reviewed By: quark-zju

Differential Revision: D14393590

fbshipit-source-id: b3e0974ac15d62f3f17790229121c0dec3a6149e
2019-03-11 15:27:52 -07:00
Jun Wu
6de9bec782 config: stop %include from scaning directories
Summary:
`listdir` makes it more expensive to detect config changes. We no longer need
it. Therefore drop the feature.

Reviewed By: markbt

Differential Revision: D13875655

fbshipit-source-id: 147adce45021c7b028aada5c40f498c2fd58c7f5
2019-03-08 16:57:06 -08:00
Stefan Filip
b7dee64bd2 manifest: fix tree entry serialization
Summary:
Follow up from D14178264.

Two changes:
 * tree manifest entries must end with a line feed
 * `t` is the byte that flags a directory

Reviewed By: DurhamG

Differential Revision: D14368316

fbshipit-source-id: b0b46c876649b8f25bf0ecdb1266527dbeb33796
2019-03-07 17:51:39 -08:00
Stefan Filip
660992a50a manifest: add tree::diff(Tree, Tree)
Summary:
`manifest::tree::diff()` returns an iterator over the differences between two
tree manifests.

I chose a function that takes two parameters over a method on Tree because it
felt more clear to write `left` and `right`. Also because I am not sure how
iterators would be abstracted on a trait.

Differential Revision: D14347656

fbshipit-source-id: 537574070cd18b08c77b3cd1cf4cff38d77fbf81
2019-03-07 17:46:44 -08:00
Stefan Filip
2deb0e6e42 manifest: add tree::Cursor and Tree::files()
Summary:
Cursor is a utility for iterating over a manifest tree. In this diff it is used
to implement Files. In the future it will be used to do a diff between two tree
manifests.

I am not sure how to describe an iterator return value in the Manifest trait so
I kept the function on the tree only for now. Looking forward to hearing your
suggestions.

Differential Revision: D14347655

fbshipit-source-id: ffd856443d8abe3ebd0557a096bf7a5ec46312d3
2019-03-07 17:46:44 -08:00
Xavier Deguillard
f868d77cd1 revisionstore: use remove_file from vfs.rs
Summary: The historypack wasn't using remove_file from vfs which was causing repack to fail.

Reviewed By: sfilipco

Differential Revision: D14373649

fbshipit-source-id: 2d87f24bda541bc011ed38533db1ac7bdddc81e3
2019-03-07 15:24:10 -08:00
Stefan Filip
c305e13566 manfiest: mark FileMetadata as Copy
Summary:
`Node` is marked as `Copy`. `FileMetadata` is not much more than `Node` so it
seems pretty clear that it should be marked `Copy`.

Reviewed By: DurhamG

Differential Revision: D14347657

fbshipit-source-id: 939abf88087bc8c6f942047a08d6a4a0d61e053f
2019-03-07 11:20:07 -08:00
Stefan Filip
5b370ffb72 manifest: move tree link to a separate file
Summary:
Cleaning up the `mod.rs` file so that it provides more signal.
`Link` is an internal implementation detail that other internal components may depend on so it is a great candidate to be moved to a dedicated file.

Differential Revision: D14347654

fbshipit-source-id: e5b5a42faf1e9f9c4a0591e5bd94182391ed511f
2019-03-07 11:20:07 -08:00
Stefan Filip
6d9dc154ca manifest: add flush function to manifests
Summary:
Save, finalize, flush, they mean about the same thing.

The first thing to note is that this implementation is not complete because
the parents are not correctly passed into the hashing function.

The second thing is that store failures make the code a little more complex
than it would have been otherwise.

(Note: this ignores all push blocking failures!)

Reviewed By: quark-zju

Differential Revision: D14292713

fbshipit-source-id: 807d7a385a62cb5f4948f1781d3146eaa6502ca9
2019-03-05 16:12:48 -08:00
Stefan Filip
25edcc014b manifest: inline store_entry_to_links
Summary:
This function is a bit on it's own with the removal of the pair conversion.
Since it is used in only one place it makes sense to inline it.

(Note: this ignores all push blocking failures!)

Reviewed By: quark-zju

Differential Revision: D14292712

fbshipit-source-id: abbf1dc70d61c0ad039f5bc5ed5277d0770e3899
2019-03-05 16:12:48 -08:00
Stefan Filip
c5cc253234 manifest: refactor tests to use store::Entry::from_elements
Summary:
Working on the save mechanism I realized that links_to_store_entry is not that
useful because we can avoid the failure states where we would try to serialize
an ephemeral node. I am removing that function and converting the code that was
using that function to using the Entry constructor directly.

(Note: this ignores all push blocking failures!)

Reviewed By: quark-zju

Differential Revision: D14292714

fbshipit-source-id: 54ef46670319c27d90fc78511a1eb6abf47d3acf
2019-03-05 16:12:48 -08:00
Stefan Filip
43fb573c23 types: add explicit conversions from owned paths types to unsized ref
Summary:
There are scenarios where an &PathComponentBuf or a &RepoPath will show up.
An example when using get from a HashMap. These are not the references that we
are looking for. We want &PathComponent and &RepoPath respectively. Adding
explicit conversions.

(Note: this ignores all push blocking failures!)

Reviewed By: quark-zju

Differential Revision: D14292711

fbshipit-source-id: 29f4de25c2ffebf7f009e4f2515e0ba8f0371ae0
2019-03-05 16:12:47 -08:00
Stefan Filip
765659d505 manifest: update tree manifest to take owneship of Store
Summary:
This is what Rust is telling us to do. The situation that triggers this update is
writing to the store. Particularly when the store is an in memory hashmap we
need to have a mutable borrow to the hashmap to insert into it. From a general
point of view this means that any sharing of the store between different
instances of a manifest will have to be handled by the struct that implements
the `Store` trait.

(Note: this ignores all push blocking failures!)

Reviewed By: quark-zju

Differential Revision: D14292716

fbshipit-source-id: 6e789527dbdf3cd3ffe967f4900251bf31f7d6b2
2019-03-05 16:12:47 -08:00
Stefan Filip
fcc560357a types: add RepoPathBuf::pop()
Summary:
The practical aspect of this method comes when iterating over a tree and having
to maintain the current path. When going deep we will be pushing path
components and when coming back we will be poping path components.

I am not sure if it makes sense to return the path component or not. However I
believe that we should return some sort of error when RepoPath is empty.

(Note: this ignores all push blocking failures!)

Reviewed By: quark-zju

Differential Revision: D14292715

fbshipit-source-id: 4ef1e10de7a60775340063b5baa317d3d626bc64
2019-03-05 16:12:47 -08:00
Stefan Filip
14f26aa355 manifest: add remove implementation for tree
Summary:
Removes a file from the manifest. Nothing special for it.

(Note: this ignores all push blocking failures!)

Reviewed By: quark-zju

Differential Revision: D14276645

fbshipit-source-id: 85e8ffd6cffee426c73eb627484dfa5a866a364b
2019-03-05 16:12:47 -08:00
Stefan Filip
1e9b7fafe9 manifest: refactor get_link out of manifest::get to allow code reuse
Summary:
It is going to be useful in tests to check how certain internal nodes change
so adding an api that allows fetching an internal node.

(Note: this ignores all push blocking failures!)

Differential Revision: D14276642

fbshipit-source-id: 9a3e488be6031f7b4727a8643f64970dcec8c400
2019-03-05 16:12:47 -08:00
Stefan Filip
e2b06628cd manifest: update Tree::get() to use RepoPath::parents()
Summary:
This removes the need for the local buffer for the parent.

(Note: this ignores all push blocking failures!)

Differential Revision: D14276648

fbshipit-source-id: a9378ea592d502ddf2dcdc35fe6ffa9ba213bc14
2019-03-05 16:12:47 -08:00
Stefan Filip
3c2c09f431 manifest: update tree::Manifest::insert
Summary:
Using the recently added path utilities so that we don't keep a secondary
parent buffer around.
Updating the file insert logic so that it is readable and intuitive.

(Note: this ignores all push blocking failures!)

Reviewed By: quark-zju

Differential Revision: D14276649

fbshipit-source-id: 8e7e835814f0039645601abbf1b701e8c1ed3697
2019-03-05 16:12:47 -08:00
Stefan Filip
dd2bfc6c04 types: add test for to_owned() on Path types
Summary:
I had an issue where I incorrectly ended up with a &&RepoPath. While debugging
I added this tests to validate my sanity. I think that keeping these tests is
useful for the future.

(Note: this ignores all push blocking failures!)

Differential Revision: D14276640

fbshipit-source-id: d7e1cedc80b3a0ecb97e5a0c80fc4eea110e943f
2019-03-05 16:12:47 -08:00
Stefan Filip
f71814f8e2 types: add dedicated iterator type for RepoPath::components()
Summary:
The current implementation has some gotchas that are related to how the `split`
method is implemented for `&str`. The new implementation is more clear for how
we construct path components

(Note: this ignores all push blocking failures!)

Differential Revision: D14276639

fbshipit-source-id: 1a22c177ba570915b7952eee78ed9191f7b72976
2019-03-05 16:12:47 -08:00
Stefan Filip
27c0d1c991 types: add RepoPath::last_component()
Summary:
Return the last component of the path. The empty path, `RepoPath::empty()`
does not have any components so `None` is returned in that case.

(Note: this ignores all push blocking failures!)

Differential Revision: D14276643

fbshipit-source-id: 9c4caf455891e77d03f22d81b39e3a34ae61ffcc
2019-03-05 16:12:47 -08:00
Stefan Filip
ed6e6245ad types: add RepoPath::parent()
Summary:
`RepoPath::parent` returns the parent of the path. The empty path,
`RepoPath::empty()` does not have a parent so `None` is returned in that case.

(Note: this ignores all push blocking failures!)

Differential Revision: D14276641

fbshipit-source-id: fc60da9750dc76e4f598dd483a63adc180135cb4
2019-03-05 16:12:47 -08:00
Stefan Filip
736cfe89bd types: add RepoPath::split_last_component()
Summary:
Tries to split the current `RepoPath` in a parent path and a component. If the
current path is empty then None is returned. If the current path contains only
one component then the pair that is returned is the empty repo path and a path
component that will match the contents `self`.

(Note: this ignores all push blocking failures!)

Differential Revision: D14276644

fbshipit-source-id: e85a22f65cc267e48f12af6bf6b40c7673b7eaaa
2019-03-05 16:12:47 -08:00
Stefan Filip
68b6897a78 types: Add RepoPath::parents()
Summary:
An iterator for the parent directories of a path.

(Note: this ignores all push blocking failures!)

Differential Revision: D14276646

fbshipit-source-id: 2b580ee8d762db5113110ec9b09ec3a093a1063a
2019-03-05 16:12:47 -08:00
Stefan Filip
ffffdd2a44 types: Add RepoPath::empty()
Summary:
This diff defines the empty `RepoPath`. This path is equivalent with the root
of the repository.
Also adding a method to check whether a `RepoPath` matches this special path.

(Note: this ignores all push blocking failures!)

Differential Revision: D14276647

fbshipit-source-id: 6e9ad5957ad39a711a1680bd084f448bb9d73f87
2019-03-05 16:12:47 -08:00
Arun Kulshreshtha
e6909b217b edenapi: pretty print keys in debug output
Summary: Now that `Key` has a `Display` implementation that produces useful output (namely the filenode and path as strings rather than bytes), we can use it to get better debug output.

Differential Revision: D14310544

fbshipit-source-id: ace5b76f07aa1216b5e9aae22dc7b6bd561e9560
2019-03-04 19:22:19 -08:00
Xavier Deguillard
5ede544f83 asyncpacks: remote unecessary Arc<Mutex> from the mutable packs
Summary:
Since all the methods of an aync mutable pack are taking the ownership of self,
there can only be one accessor to self, and therefore the Mutex is not
required. For the same reasons, the Arc can be removed.

This saves a bunch of atomic operation when operating on the mutable packs.

Reviewed By: kulshrax

Differential Revision: D14287252

fbshipit-source-id: 792bc41aa0dc372e2114dfca4895cca7083f3a56
2019-03-04 13:48:11 -08:00
Xavier Deguillard
073c33a933 asyncpacks: AsyncWrapper only accept Sync types
Summary:
Since most of the datastore/historystore types are already Sync, we don't
really need to wrap them in a Mutex. For the ones that aren't Sync, we can
easily wrap them in a Mutex and pass that to AsyncWrapper.

Reviewed By: kulshrax

Differential Revision: D14287253

fbshipit-source-id: 0f5c04c651592561403caa6e4627017ab1731d0a
2019-03-04 13:48:11 -08:00
Arun Kulshreshtha
2ab9df3b9d types: implement Display for Key
Summary: Implement the `Display` trait for `Key`. This is important for human-readable output for debugging since both filenode and path inside the `Key` are stored as byte arrays, which are just printed out as numbers by the derived `Debug` implementation.

Differential Revision: D14294970

fbshipit-source-id: a601dc9a0c23ac40894ec27135171928f5635507
2019-03-04 12:11:23 -08:00
Stefan Filip
82bbd0326f manifest: improve store imports in tree/mod.rs
Summary:
We currently alias many of the imports from the store submodule. It is nicer
if we just import the submodule name and prefix with the submodule.

Differential Revision: D14276638

fbshipit-source-id: 6661df7f9cb5d976b11153003f653a1f66301c9a
2019-03-03 12:35:50 -08:00