Commit Graph

306 Commits

Author SHA1 Message Date
Lukas Piatkowski
dd3c638c1d api cleanup: clean api of mercurial and mercurial_types NodeHash
Summary:
This is a cleanup of NodeHash API. There were few unused methods and few ways to convert between mercurial and mercurial_types hashes. With this diff it is very easy to identify the places where this converstion happens.
A followup of this diff will be to use this new API to easily replace the NodeHash convertions in places where it requires remapping.

Reviewed By: sid0

Differential Revision: D7592876

fbshipit-source-id: 6875aa6df1a3708ce54ca5724f6eb960d179192b
2018-04-13 10:00:03 -07:00
Stanislau Hlebik
89befdb26d mononoke: avoid using linknodes
Summary: They are replaced by filenodes

Reviewed By: farnz

Differential Revision: D7443320

fbshipit-source-id: 13c7d07bc00dcbaa991663c8da8a07fcb0de1332
2018-04-13 02:47:24 -07:00
Siddharth Agarwal
8e7a1acc0f mercurial-types: rename Blob to HgBlob
Summary:
This will probably go away soon, but for now I want to be able to
disambiguate the new Thrift-encoded blobs in Mononoke from these.

Reviewed By: StanislavGlebik

Differential Revision: D7565808

fbshipit-source-id: d61f3096fa368b934a923dee54a0ea1e3469ae0d
2018-04-11 13:42:31 -07:00
Siddharth Agarwal
ead5f3be95 mercurial-types: rename left -> from, right -> to
Summary:
`left` and `right` are too vague in this context, since there's
already `Added` and `Removed` which imply an explicit direction.

Reviewed By: StanislavGlebik

Differential Revision: D7560975

fbshipit-source-id: 847f600508434d62857ff60a6e6678a4426ffa88
2018-04-11 13:42:31 -07:00
Siddharth Agarwal
32f1a4ef03 mercurial-types: represent symlinks as blobs, not paths
Summary:
There's no guarantee that a symlink is a valid `MPath` -- in fact, it
frequently will be an absolute symlink which is not a valid `MPath`.

Reviewed By: lukaspiatkowski

Differential Revision: D7541672

fbshipit-source-id: c7eca54cd06e811cf54932ab8f671c13a62b5f71
2018-04-09 12:06:57 -07:00
Siddharth Agarwal
7cb68c0c60 mercurial-types: make the Type enum use FileType
Summary:
Since `FileType` now exists, the `Type` enum can use it instead of
defining its own stuff.

Reviewed By: farnz

Differential Revision: D7526046

fbshipit-source-id: 3b8eb5502bee9bc410ced811dc019c1ce757633f
2018-04-06 13:16:55 -07:00
Arun Kulshreshtha
f3e27be2eb Make TimedFuture take asynchronous callback
Summary: Previously, the `.timed()` combinator exported by the `futures-stats` would accept a synchronous callback to log the recorded stats. In practice, logging the stats may require blocking IO, so this combinator should be modified to accept a closure that returns a Future instead.

Reviewed By: farnz

Differential Revision: D7492957

fbshipit-source-id: c634b511e5a93a18787ab3e11ab8e1c19de7566e
2018-04-06 11:34:00 -07:00
Stanislau Hlebik
618308b470 mononoke: use filenodes to get copy and parent info
Summary:
filenodes are faster than blobstore in answering `get_parents` and
`get_copy_info` queries. So let's use them instead of going to blobstore.

Reviewed By: jsgf

Differential Revision: D7485151

fbshipit-source-id: f9e2ce9dd42b3e9b18140cc3de2c9718f20ab6d4
2018-04-06 06:56:47 -07:00
Stanislau Hlebik
9587c7e694 mononoke: use filenodes in blobrepo
Summary:
Use filenodes in BlobRepo instead of linknodes.

That involves changes in commit API because we need to write filenodes not linknodes.
Also it involves changes to memblob test repos.
Note that in this diff they are basically "broken" - linknodes were replaced with empty filenodes. However looks like our unittests haven't exercised this functionality, so no unit-tests has failed. In the next diffs the correct filenodes will be added.

Reviewed By: farnz

Differential Revision: D7413481

fbshipit-source-id: 7f994ea55887b96a0eacf8e6ffdebd1f8c5f025d
2018-03-29 03:29:57 -07:00
Stanislau Hlebik
fc3971aa62 mononoke: remove a few BlobRepo constructors
Summary:
They do not provide a lot of value, so let's not have them at all. It will make
adding filenodes easier.

Reviewed By: farnz

Differential Revision: D7428601

fbshipit-source-id: 647fa36d962cb6a8996f92246e4d900751040a52
2018-03-29 03:29:57 -07:00
Stanislau Hlebik
7fd6e274ea mononoke: remove blob_files
Summary: We are not using it, so there is no point in keeping it around

Reviewed By: farnz

Differential Revision: D7400428

fbshipit-source-id: 481ef3ec8ef1f188e01add36e81da789f186548e
2018-03-28 04:22:46 -07:00
Simon Farnsworth
2d0c41cf06 Make manifests contain MPathElement instead of MPath
Summary:
For historical reasons (back when we thought Mononoke might need to handle both flat and tree manifests natively), we decided to make the entry type in a Manifest be `MPath`, not `MPathElement`.

In the tree manifest only world we're now in, it's a bug if a Manifest contains a path instead of a path element - enforce this through the type system, so that we can't backslide accidentally.

Reviewed By: StanislavGlebik

Differential Revision: D7413870

fbshipit-source-id: fa13b676475ea8a3265fc962910542f2f555d7de
2018-03-27 07:44:39 -07:00
Simon Farnsworth
86ba6a7715 Run perf tests against a simulated blobstore
Summary: Make it possible to use a simulated remote backend as a blobstore. This allows me to look at the test results and be happy that Mononoke is at fault for any slowness.

Reviewed By: kulshrax

Differential Revision: D7353229

fbshipit-source-id: 57528af704b517a70570bb2b9b140caa9120a956
2018-03-26 05:11:00 -07:00
Jeremy Fitzhardinge
3373c16b62 scm/mononoke: run changeset operations in worker threads
Summary:
Run changeset db operations in worker threads to make them async as
far as the rest of the system is concerned.

Reviewed By: farnz

Differential Revision: D7350002

fbshipit-source-id: 66fadf9ad2f16929e0c07a6907aa9d5f5a7075a8
2018-03-23 13:47:55 -07:00
Jeremy Fitzhardinge
d6504de44c scm/mononoke: make Changesets::add take ChangesetInsert by value
Summary:
There's no point passing it by reference since callers don't need to
retain it, and the async implementation needs to move it into another context.

Reviewed By: farnz

Differential Revision: D7350001

fbshipit-source-id: 5947557a84621afae801dc20e3994496244e3a10
2018-03-23 13:47:54 -07:00
Lukas Piatkowski
d0e66cc5f7 mercurial: distinguish between NodeHash used in mercurial Revlogs and in Mononoke Blobstore
Summary:
This codemod tries not to change the existing behavior of system, only introduce new types specific to Mercurial Revlogs.
It introduces a lot of copypasta intentionally and it will be cleaned in following diffs.

Reviewed By: farnz

Differential Revision: D7367191

fbshipit-source-id: 0a915f427dff431065e903b5f6fbd3cba6bc22a7
2018-03-22 12:24:35 -07:00
Arun Kulshreshtha
c12923a087 Use std::time instead of time crate in futures-stats
Summary: Remove usage of deprecated `time` crate in `futures-stats`, and fix all callsites using the new `time-ext` crate.

Reviewed By: farnz

Differential Revision: D7349956

fbshipit-source-id: 10ef86c4942b8533a734c7daadfa895f5ef92f23
2018-03-22 06:01:43 -07:00
Siddharth Agarwal
9eb63ab31f ensure all MPaths are non-empty
Summary:
A lot of Mononoke expects MPath instances to be non-empty, and some
Mononoke code wants empty MPaths. Have formerly-empty `MPath` instances be
represented as `None` instead.

There's a bit of a wart where we have to check for some instances being empty
even though they should never be. This is not a regression -- this is actually
a deficiency in our current type hierarchy being exposed. `Entry` can sometimes
represent a root manifest, but a root path and a root manifest will never be
joined together in practice. We may want to figure out a better way to
represent that in the future.

Also clean up a bunch of code that checks for empty `MPath` instances. That
just isn't possible any more -- yay.

Reviewed By: StanislavGlebik

Differential Revision: D7359048

fbshipit-source-id: 684f908dabaa06cb25b1dd33f4fd7bb021cb5e1b
2018-03-22 05:21:57 -07:00
Siddharth Agarwal
df5c6c7202 use Option<MPath> instead of empty MPaths whenever desired
Summary:
Lots of places specifically want a non-empty `MPath`, and earlier those cases
weren't type-checked. Now `Option<MPath>` stands for an empty `MPath`. In the
next diff `MPath::empty()` will go away and the only way to represent an
`MPath` that doesn't exist will be with `Option<MPath>`.

Reviewed By: farnz

Differential Revision: D7350970

fbshipit-source-id: 1612aec67134e7a0ebad15dbaa93b5ea972f8ddf
2018-03-21 15:59:31 -07:00
Stanislau Hlebik
6c2bb328aa mononoke: update bookmarks in pushkey part
Summary:
Actually update the bookmarks using pushkey part. Note that bookmark deletion
doesn't currently work. It will be fixed in the next diffs

Reviewed By: farnz

Differential Revision: D7271600

fbshipit-source-id: fd13d1adfd3ea490174c31e23289e8560dc2b737
2018-03-21 14:25:00 -07:00
Stanislau Hlebik
91d795ec72 mononoke: use diesel bookmarks
Summary: Replace old_bookmarks with the new diesel implementation

Reviewed By: farnz

Differential Revision: D7271599

fbshipit-source-id: cb6433fe44a8e6f87046a3820f7c3e68725505f6
2018-03-21 14:24:51 -07:00
Siddharth Agarwal
2c2dabdd38 use Option<&MPathElement> instead of &Option<MPathElement>
Summary:
The `Option<&MPathElement>` type is more general -- it's easy to
convert from `&Option<MPathElement>` to it, but the other way around can
require a clone.

Reviewed By: farnz

Differential Revision: D7339161

fbshipit-source-id: 0c8ab57a19bc330245c612e3e0e3651e368ab8cb
2018-03-21 09:32:11 -07:00
Lukas Piatkowski
4d4d90928f integration tests: use RocksDb based blobs rather than File based for testing
Summary: just to excersise our RocksDb blobstore which might come in handy more often than file based as it should be more efficient

Reviewed By: StanislavGlebik

Differential Revision: D7290069

fbshipit-source-id: ce776cfa14e43dc45cca796ef187655ba665d177
2018-03-16 13:41:55 -07:00
Simon Farnsworth
54618629b5 Gather a full set of changeset creation timings
Summary:
To diagnose slow changeset creation, we need to know which chunk was
slow. As with upload_blob and process_entries in past diffs, measure key
phases.

The idea is that we can combine all these times (5 per changeset, 2 per blob)
to work out what needs tracing when we're looking for slowness

Reviewed By: StanislavGlebik

Differential Revision: D7195013

fbshipit-source-id: 9769ead981f02d6ecf0258190763e90762936387
2018-03-16 10:36:44 -07:00
Simon Farnsworth
3864f2e0d3 Record the time spent processing entries during changeset creation
Summary:
Processing entries does two things:

1. Polls all the upload futures until they're all complete.
2. Works out what entries are required to be present for this changeset.

This is the bulk of the Blobstore operations in creating a changeset, so we
know that if this is slow, then we either have a slow Blobstore, *or* we have a
bug. Further, we can combine this with the metrics for upload_blob to know
whether we're doing uploads nicely in parallel, or whether there's
serialization we didn't intended (time taken here greater than sum of time
taken in blob uploads)

Reviewed By: StanislavGlebik

Differential Revision: D7182445

fbshipit-source-id: 205b43700f28ff7e5461235e16a6955b8c597a52
2018-03-16 10:36:44 -07:00
Siddharth Agarwal
76027dfac0 verify that MPathElement instances are sane
Summary:
While writing Thrift deserialization code I realized there was nothing
that actually checked that MPathElement instances don't have embedded nulls or
slashes.

Reviewed By: farnz

Differential Revision: D7296838

fbshipit-source-id: 6a23d559da11e5e935e23d7b9a13f58894efaf62
2018-03-16 10:15:05 -07:00
Siddharth Agarwal
b338897dc4 prefix ChangesetId, ManifestId and BlobHash with Hg
Summary:
Mononoke will introduce its own ChangesetId, ManifestId and BlobHash, and it
would be good to rename these before that lands.

Reviewed By: farnz

Differential Revision: D7293334

fbshipit-source-id: 7d9d5ddf1f1f45ad45f04194e4811b0f6decb3b0
2018-03-15 17:45:29 -07:00
Simon Farnsworth
7452236c99 Refactor special stats drain into a macro
Summary:
I'm going to reuse this for unit-testing changeset timings. Make it a
macro so that I don't keep repeating myself.

Reviewed By: StanislavGlebik

Differential Revision: D7182442

fbshipit-source-id: de40e0f10892b2268c4d39cf771b7a8be6e1cf76
2018-03-13 12:28:20 -07:00
Simon Farnsworth
050c7d95d8 Support a key prefix in ManifoldBlob Blobstore
Summary:
I want to be able to work in a private Manifold namespace when testing
that my hunches about Manifold/Mononoke interactions are good, and when testing
changes to the ManifoldBlob that should make life better. Make that possible.

In the future, once I have a Blobstore that simulates Manifold locally, this
also makes it possible to compare the simulation to Manifold without tripping
over other users.

Reviewed By: StanislavGlebik

Differential Revision: D7194754

fbshipit-source-id: 601bf1c2ded1af5db6a123fdd05600bc3eb5d7cf
2018-03-12 07:59:56 -07:00
Lukas Piatkowski
c4ede3aa71 blobrepo: wrap Error in Compat for SharedError<Compat<Error>>
Summary: SharedError has a default implementation for std Error, but the parameter must implement std Error, that is why I wrapped failure::Error in failure::Compat. Thanks to that we can use SharedError as any other normal std Error (including the fact that it implements failure::Fail)

Reviewed By: farnz

Differential Revision: D7213459

fbshipit-source-id: 54899c64c2627dfdba276630d986a3d6007ea59a
2018-03-09 08:44:32 -08:00
Simon Farnsworth
6d53f3e310 Add timing information to BlobRepo upload_blob
Summary:
We want to be able to measure the time it takes to upload individual
blobs, to confirm that we don't have a concurrency issue to chase down (e.g.
blobs accidentally uploaded in series).

Measure content upload time separately, so that we know not to dive down a
rabbit hole if the measured slowness is just the time spent uploading content

Reviewed By: StanislavGlebik

Differential Revision: D7172154

fbshipit-source-id: 08729a8ffaa69a364a64f6277edfa591a8712592
2018-03-07 13:45:51 -08:00
Simon Farnsworth
868e95e831 Split up the BlobRepo commit tests
Summary:
I'm going to be adding more to test the timing features, so split this
up to make code sharing easier

Reviewed By: StanislavGlebik

Differential Revision: D7172156

fbshipit-source-id: 056be70268dd1c8a37aff8e8d53342b8cea4a355
2018-03-07 04:37:27 -08:00
Simon Farnsworth
bb8c39183e Thread a logger into BlobRepo
Summary: I'm going to need a logger to log future-stats output to (and later trace output). Thread one through to BlobRepo

Reviewed By: StanislavGlebik

Differential Revision: D7167450

fbshipit-source-id: 4ed729e4d448b66e491cefa19380d3be9bc99091
2018-03-06 08:09:19 -08:00
Simon Farnsworth
98bc1a4e81 Fix blob size calculation
Summary:
We had two separate issues in blob size, which were breaking `test-eden-server.t`:

1. The value documented as "blob size without metadata" was calculated with metadata included (because we didn't strip the metadata from the content blob).
2. If the BlobNode was clean (i.e. had both data and a hash), the size was the size of the hash, not the data.

Reviewed By: StanislavGlebik

Differential Revision: D7167581

fbshipit-source-id: 965778c1d053af36c760a988f0d34130052e8a1a
2018-03-06 07:05:52 -08:00
Dino Wernli
fa2b14cd8b Remove the generic types from Blob and BlobNode in favor of Bytes
Summary: Replace the generic types if `Blob` and `BlobNode` with `Bytes`.

Reviewed By: lukaspiatkowski

Differential Revision: D7115361

fbshipit-source-id: 924d347377569c6d1b3b4aed14d584510598da7b
2018-03-02 09:45:04 -08:00
Dino Wernli
36917d583a Address some leftover comments from D7106766.
Reviewed By: lukaspiatkowski

Differential Revision: D7123890

fbshipit-source-id: 73d2531413d34bff6db8baaf959e11084def616e
2018-03-02 09:02:59 -08:00
Dino Wernli
5c84d1d8de Return file contents as Bytes in blobrepo.
Summary: This starts porting uses of Vec<u8> for file contents to the Bytes type.

Reviewed By: jsgf

Differential Revision: D7106766

fbshipit-source-id: 15d531836132317cede7a6f9d6b047a423deb5bb
2018-02-28 17:59:12 -08:00
Lukas Piatkowski
d24a501e9e blobrepo: write commit to HeadStore
Summary:
This is a hacky way of getting the push/pull working. We should instead remove the commits that are no longer heads from HeadStore and add those that are the new heads.
In this diff though we add all the commits as heads, just because this does not break the client

Reviewed By: farnz

Differential Revision: D7112279

fbshipit-source-id: 036f0fd230de52e96cbf4168c2cda7c2a1c5bd89
2018-02-28 14:15:13 -08:00
Lukas Piatkowski
37aedb6a7c bundle2-resolver: fetch missing file content from BlobRepo in DeltaCache
Summary: The assumption that deltas can be decoded using only bundle2 was wrong, we need to be able to fetch content of other files from the BlobRepo for delta application.

Reviewed By: StanislavGlebik

Differential Revision: D7085957

fbshipit-source-id: 2f6803d7f61389c5ba38b1207ede42579b9cf2e6
2018-02-27 11:14:52 -08:00
Jeremy Fitzhardinge
aeff388fef tp2: update rust-crates-io
Summary: Update to include num_cpu and blake2. Also update bincode to 1.0.0

Reviewed By: StanislavGlebik

Differential Revision: D7098292

fbshipit-source-id: 67793a6f458d50fc049781f34abaf313c8ff7a79
2018-02-27 09:27:19 -08:00
Simon Farnsworth
282db746c5 Make the commit API record completion in the Changesets table
Summary:
We want to use the Changeset table as source of truth for changesets.
Record completed changesets in the database.

Additionally, now that completion is a database matter, increase the available
parallelism marginally, by allowing the changeset to upload while its parents
are still uploading

Reviewed By: jsgf

Differential Revision: D7071700

fbshipit-source-id: 405bf84eba4a06e3d6c6299ade2fbea99edf9c19
2018-02-27 02:19:11 -08:00
Simon Farnsworth
5e074bdd43 Create changesets API in BlobRepo
Summary:
Provide an API to ask BlobRepo to create changesets for you from
pieces that you either have to hand, or have created via upload_entry().

Parallelism is maintained in as far as possible - if you commit N changesets,
they should all upload blobs in parallel, but the final completion future
depends on the parents, so that completion order can be maintained.

The ultimate goal of this API is to ensure that only valid commits are added to the `BlobRepo` - this means that, once the future returned by `create_changeset` resolves, you have a repo with commits and blobs in place. Until then, all the pieces can be uploaded, but are not guaranteed to be accessible to clients.

Still TODO is teaching this to use the complete changesets infra so that we
simply know which changesets are fully uploaded.

Reviewed By: StanislavGlebik

Differential Revision: D6743004

fbshipit-source-id: 813329058d85c022d75388890181b48b78d2acf3
2018-02-27 02:19:11 -08:00
Stanislau Hlebik
3526e7137b mononoke: use changesets table in repoinfo
Summary:
Changesets table gives us a relatively fast way to get generation number. Let's
use it inside repoinfo crate.

Reviewed By: sid0

Differential Revision: D7043829

fbshipit-source-id: 82557340a7f2fd6361f4e29c1a11e38e473eeb15
2018-02-26 09:43:24 -08:00
Stanislau Hlebik
e8b335468a mononoke: use changesets table in blobimport
Summary:
Iff all the inserts finished successfully, then it's safe to mark changesets as complete.
This diff fills up changesets store after blobimport successfully finishes.

For simplicity if --commit-limit or --skip is set then we skip filling up the changeset store.

Reviewed By: sid0

Differential Revision: D7043831

fbshipit-source-id: 8ae864b45222d52281c885a49c2dca44ba577137
2018-02-26 09:43:24 -08:00
Stanislau Hlebik
9beeaeadc5 mononoke: add repoid to BlobRepo
Summary: Changests store requires it in it's api methods. Let's pass repoid from configs

Reviewed By: farnz

Differential Revision: D7043830

fbshipit-source-id: e4e4d5852d0ca8488cabe2140555508c143ab8df
2018-02-26 09:43:24 -08:00
Stanislau Hlebik
f88f3fbb21 mononoke: use changesets table in Mononoke
Summary:
For now it does nothing. In the next diffs it will be used to tell if commit
exists in the repo or not and to speed up revsets

Reviewed By: farnz

Differential Revision: D7043828

fbshipit-source-id: 9fcc668e68ba238123a89f18ff67828848ba0cec
2018-02-26 09:43:24 -08:00
Lukas Piatkowski
358fd89ff4 bundle2-resolver: use future::Shared to store futures of uploaded blobs
Summary: This is required in further diffs where a single blob can be referenced by multiple Changesets and thus must be Sharable

Reviewed By: farnz

Differential Revision: D7056227

fbshipit-source-id: 81de95fbd933d7888347ffdfbab392b1f0398e89
2018-02-23 11:22:58 -08:00
Lukas Piatkowski
4eab1b3a13 blobrepo: make get_changeset_by_changesetid return BlobChangeset rather than Box<Changeset>
Summary: BlobChangeset has some methods that are useful also outside of blobrepo crate, like getting it's node.

Reviewed By: farnz

Differential Revision: D7056035

fbshipit-source-id: 197d261fd21ab9332950d3fda401e7dab3730cb5
2018-02-23 11:22:58 -08:00
Stanislau Hlebik
9c710056bc mononoke: remove useless Arc::new
Summary: We wrap it in Arc below anyway.

Reviewed By: farnz

Differential Revision: D7043827

fbshipit-source-id: afacd10ebb000bd8311891723437d838cd136d61
2018-02-22 07:38:33 -08:00
Lukas Piatkowski
4e8389525b bundle2-resolver: upload filelogs and manifests using BlobRepo::upload_entries
Reviewed By: farnz

Differential Revision: D7031532

fbshipit-source-id: 349889da8c7d3f0c572408b61f956fc2ca9f8fd3
2018-02-22 04:53:56 -08:00
Lukas Piatkowski
2237f2180d mercurial: extract BTreeMap to ManifestContent for better sharing with other crates
Summary: This is needed for the next diff where the ManifestContent is used in TreemanifestBundle2Parser

Reviewed By: StanislavGlebik

Differential Revision: D7030689

fbshipit-source-id: cf199e3f1317d8950446782de9899eb2ef97a149
2018-02-22 03:45:26 -08:00
Katherine McKinley
28ce2f6211 Replace NodeHash with ChangesetId in BlobRepo
Summary:
This change removes get_changeset_by_nodeid and replaces it with
get_changeset_by_changesetid, and propagates the changes to callers.

A few places still have ChangesetId::new() because I'm not sure where
the original NodeHash comes from. If you have any pointers, I would be
happy to fix them before landing.

Reviewed By: lukaspiatkowski

Differential Revision: D7031923

fbshipit-source-id: cd00ea1d2b955538e26d7b5735aed33fe0ae0330
2018-02-21 10:42:06 -08:00
Simon Farnsworth
9e366eacd4 Introduce a LazyMemblob test blobstore
Summary:
The current Memblob store is eager; this is great for finding certain
classes of bugs (those that assume an ordering that is not guaranteed), but not
so good for exposing other classes of bugs (those that assume that the future
has done its work before it resolves).

Add a lazy variant that functions in the same way as Memblob, but that waits
until it's polled to return.

Reviewed By: StanislavGlebik

Differential Revision: D7033792

fbshipit-source-id: 4c2d8a8150d908bcb26347757f96f99e20d74fc2
2018-02-21 07:17:00 -08:00
Stanislau Hlebik
c0b25700db mononoke: add support many mfnodes and basemfnodes in gettreepack
Summary:
Quick recap: gettreepack is a treemanifest wireproto method.
It's used to send treemanifest data to the client. Client sends list of
manifest nodes it's interested in (mfnodes), and list of nodes it already has
(basemfnodes). Server should find the difference and send it back. Client
usually call this wireproto method when it checks out new revision (`hg
update`), but it uses in other cases too (for example, in `hg prefetch`).

Before we supported exactly one mfnode and exactly one basemfnode. This is
usually fine for `hg update` use-case, but `hg prefetch` can request many
mfnodes and can send empty basemfnode. So let's support this too.

Note that current implementation isn't efficient. It uses at most one
basemfnode, meaning that it can send data that client already has. Also for
each mfnode we generate separate stream of changed entries. That means that the
same entries can be fetched many times.

Reviewed By: lukaspiatkowski

Differential Revision: D6923197

fbshipit-source-id: d25f9a01ca568c84811ee1a13181e70eb217eb53
2018-02-14 06:36:04 -08:00
Simon Farnsworth
1769c661c3 Upload entries as phase 1 of commit API
Summary:
We want to be able to upload raw entries to the backing store, so that
we can assemble files + manifests into a commit. Provide the API to just upload
raw entries

Reviewed By: lukaspiatkowski

Differential Revision: D6966727

fbshipit-source-id: 8eb0dce210f2646f29b38d216c54bb60a2b1ff60
2018-02-13 10:08:42 -08:00
Stanislau Hlebik
590b166d09 mononoke: add new methods to blobrepo
Summary:
These methods are
1) get_file_copy(node) -> returns copy info for a file (copyfrom revision and copyfrom filename). Can be None.
2) get_parents(node) -> returns parents of the node

It will be used in remotefilelog getfiles method to construct file history.

Reviewed By: jsgf

Differential Revision: D6913176

fbshipit-source-id: ba74a71926c5ca80249f8cc0f300a0aa20a65bbc
2018-02-13 08:54:31 -08:00
Stanislau Hlebik
1d7668ffba mononoke: remove get_mpath and get_path and use get_name
Summary:
As we discussed before, let's add get_name() method that returns MPathElement,
and remove get_path() and get_mpath().

Except for renaming, diff also make repoconfig work with tree manifest, and
fixes linknodes creation in blobimport - previously basename was used instead
of the whole path.

Reviewed By: jsgf

Differential Revision: D6857097

fbshipit-source-id: c09f3ff40d38643bd44aee8b4488277d658cf4f6
2018-02-07 07:53:48 -08:00
Stanislau Hlebik
5041338494 mononoke: rename get_blob and fetch_blob_from_blobstore
Summary:
Give them correct names, because this functions actually fetch node from
blobstore and strip copy metadata if it exists.

Reviewed By: farnz

Differential Revision: D6871271

fbshipit-source-id: 4d8c83786b223f5cd4f55188fbcb8f438713d3b7
2018-02-06 02:20:39 -08:00
Stanislau Hlebik
ba80d2e419 mononoke: make it possible to create root entry
Summary:
Currently there is no easy way to create Entry that represents root manifest.
More importantly, `get_mpath()` fails if internal RepoPath is root. This diff
fixes this issue and adds method to create root entry.

It will be used in `gettreepack` wireproto method implementation

Reviewed By: jsgf

Differential Revision: D6845033

fbshipit-source-id: 0999db89441e9ab783b8bca8047b01e4c6832187
2018-02-02 07:01:57 -08:00
Stanislau Hlebik
5b968c201c mononoke: add get_linknode method to BlobRepo
Summary: It will be used by many things, in particular by gettreepack method

Reviewed By: jsgf

Differential Revision: D6845036

fbshipit-source-id: 3174dfafeeab830ededb70ddff3dd62f6a608d54
2018-02-02 07:01:57 -08:00
Katherine McKinley
5c1e5825b0 Convert NodeHash to ChangesetId in BlobChangeset
Summary: Change BlobChangeset and callers to use ChangesetId instead of NodeId

Reviewed By: lukaspiatkowski

Differential Revision: D6835450

fbshipit-source-id: 7b20359837632aef4803e40965380c38f54c9d0a
2018-01-31 13:36:45 -08:00
Julian Priestley
67e908efe0 Use ChangesetId rather than NodeHash in bookmarks
Summary: Update the bookmarks module to use ChangesetId to represent bookmarks, rather than NodeHash.

Reviewed By: lukaspiatkowski

Differential Revision: D6774650

fbshipit-source-id: 1742e4e78798ad68a7f17ebd345eef14a7de2cec
2018-01-22 10:23:36 -08:00
Simon Farnsworth
6703981f74 Remove Blobstore parameter from BlobEntry et al
Summary:
This will (in practice) always be `Arc<Blobstore>`, so push down and
make it the concrete type.

Reviewed By: jsgf

Differential Revision: D6761690

fbshipit-source-id: c279751d98a8882c209b79faa7cbfd3e635beda5
2018-01-22 05:22:14 -08:00
Xiaotian Wu
2c4d93ceb8 modify entryid related code
Summary: modify entryid code

Reviewed By: lukaspiatkowski

Differential Revision: D6722202

fbshipit-source-id: 1df45071709f4a425374a87a29553830071b5d2d
2018-01-16 07:57:25 -08:00
Xiaotian Wu
92c0528b1f modify manifestid related code
Summary: nodehash -> manifestid

Reviewed By: lukaspiatkowski

Differential Revision: D6719378

fbshipit-source-id: 1ec59b33270e389da8e74b3864c37a86c9d89f81
2018-01-16 07:57:25 -08:00
Xiaotian Wu
ed94c6702c modify changesetid related code
Summary: modify the parameter type

Reviewed By: lukaspiatkowski

Differential Revision: D6695443

fbshipit-source-id: fafcdc83773cb86c08cdcf3a8d80c1c9a498eca5
2018-01-16 07:57:25 -08:00
Simon Farnsworth
ebafde00b0 Remove Repo trait completely
Summary:
We're never going to serve RevlogRepo in production, and we're down to
a single BlobRepo type that will have different backing stores. Remove the
unused trait, and use BlobRepo everywhere bar blobimport and repo_config
(because we previously hardcoded revlog here - we want to change to a BlobRepo
once blobimport is full-fidelity).

Reviewed By: jsgf

Differential Revision: D6596164

fbshipit-source-id: ba6e76e78c495720792cbe77ae6037f7802ec126
2018-01-15 06:37:27 -08:00
Simon Farnsworth
28caf3f938 Remove Error, GetBlob and PutBlob from BlobStore
Summary:
Remove the last associated types from BlobStore - this means that
BlobStore now has an associated trait object type.

Reviewed By: jsgf

Differential Revision: D6425414

fbshipit-source-id: 7186dab9b56593dd1d70be732d4ad56d1e7b3c63
2017-12-11 07:05:53 -08:00
Jeremy Fitzhardinge
ac31713c84 rust: failure cleanup pass
Summary:
Don't use failure's bail!() and ensure!() macros.

Instead, failure_ext provides:
- bail_err!(err) - Converts its single parameter to the expected error and returns; ie `return Err(From::from(err));`
- bail_msg!(fmt, ...) - takes format string parameters and returns a `failure::err_msg()` error
- ensure_err!(), ensure_msg!() - corresponding changes

Also:
- remove all stray references to error-chain
- remove direct references to failure_derive (it's reexported via failure and failure_ext)
- replace uses of `Err(foo)?;` with `bail_err!()` (since `bail_err` unconditionally returns, but `Err(x)?` does not in principle, which can affect type inference)

Reviewed By: kulshrax

Differential Revision: D6507717

fbshipit-source-id: 635fb6f8c96d185b195dff171ea9c8db9e83af10
2017-12-07 14:10:17 -08:00
Jeremy Fitzhardinge
dc5e78c1c1 rust: mass convert scm/mononoke/... to use failure
Summary:
Convert scm/mononoke to use failure, and update common/rust crates it depends on as well.

What it looks like is a lot of deleted code...

General strategy:
- common/rust/failure_ext adds some things that are in git failure that aren't yet in crates.io (`bail!` and `ensure!`, `Result<T, Error>`)
- everything returns `Result<T, failure::Error>`
- crates with real error get an error type, with a derived Fail implementation
  - replicate error-chain by defining an `enum ErrorKind` where the fields match the declared errors in the error! macro
- crates with dummy error-chain (no local errors) lose it
- `.chain_err()` -> `.context()` or `.with_context()`

So far the only place I've needed to extract an error is in a unit test.
Having a single unified error type has simplified a lot of things, and removed a lot of error type parameters, error conversion, etc, etc.

Reviewed By: sid0

Differential Revision: D6446584

fbshipit-source-id: 744640ca2997d4a85513c4519017f2e2e78a73f5
2017-12-05 18:11:13 -08:00
Simon Farnsworth
16da012250 Remove ValueIn/ValueOut from the BlobStore generic arguments.
Summary:
BlobStore is entirely generic, and puts no limits on its
implementations. Remove ValueIn and ValueOut type parameters, and insist that
all blobs are Bytes (as per production setups)

Reviewed By: StanislavGlebik

Differential Revision: D6425413

fbshipit-source-id: 455e526d8baebd0d0f1906941648acca89be4881
2017-12-04 10:22:09 -08:00
Simon Farnsworth
c1ee28dbc7 Remove Key from the BlobStore generic arguments.
Summary:
BlobStore is entirely generic, and puts no limits on its
implementations. Remove the "Key" type parameter, and insist that all keys are
String (as per production setups)

Reviewed By: StanislavGlebik

Differential Revision: D6425412

fbshipit-source-id: 1f1229bf8e001bf780964e883c6beb071e9ef1d8
2017-12-04 10:22:09 -08:00
Simon Farnsworth
5519eae489 Make Bookmarks a parameterless trait
Summary:
As part of removing excess genericism, make Bookmarks a trait with no
associated types or type parameters. I will revisit error types here once I
have removed the Repo trait - these are not ideal, but enough to get things
going

Reviewed By: StanislavGlebik

Differential Revision: D6405315

fbshipit-source-id: 814c106612a061e1766f1ea9a9428a13a73bd007
2017-11-27 08:05:02 -08:00
Simon Farnsworth
36de85eb2e Stop repo returning Bookmarks objects directly
Summary:
Returning the bookmarks object gets in the way of degenericising
bookmarks. It's also not in line with other methods on the Repo trait - the
repo handles querying the underlying storage, not the user.

Switch to providing pass-through interfaces for bookmarks.

Reviewed By: StanislavGlebik

Differential Revision: D6408644

fbshipit-source-id: 2808850a070b7bcc478cd40d824bdc8d3acb8b0f
2017-11-27 04:21:05 -08:00
Simon Farnsworth
16615b3749 Make Heads a parameterless trait
Summary:
As part of removing excess genericism, make Heads a trait with no
associated types or type parameters.

Reviewed By: StanislavGlebik

Differential Revision: D6352727

fbshipit-source-id: df9ef87e0e0abe43c30e7318da38d7f930c37c6e
2017-11-23 07:05:35 -08:00
Stanislau Hlebik
ba4e681984 mononoke: add config parameter to specify manifold bucket
Reviewed By: jsgf

Differential Revision: D6099150

fbshipit-source-id: dc8fa3e7b90f6e1ee404b553e1b96c7dec8e25fd
2017-11-20 05:35:55 -08:00
Stanislau Hlebik
2560d9ce73 mononoke: rename blobrepo functions
Summary: We are going to use them to fetch not only file blobs, but also tree blobs.

Reviewed By: kulshrax

Differential Revision: D6336010

fbshipit-source-id: 77fcc45698a447c10d180baf929465f1d7e4ee72
2017-11-16 04:19:08 -08:00
Siddharth Agarwal
e771348b76 blobrepo: incorporate linknodes in blob state
Summary: Also support them in `generate_memblob_repo.py`.

Reviewed By: jsgf

Differential Revision: D6215721

fbshipit-source-id: c8b855bbc74b619bc093b3aac449a283a1ad33ec
2017-11-13 22:01:55 -08:00
Stanislau Hlebik
5ae8299e80 mononoke: Use MemHeads and MemBookmarks in TestManifoldBlobState
Summary:
Bookmarks and heads are not used in eden server, but user still have to specify
--blobrepo-folder. Let's use MemHeads and MemBookmarks instead to avoid
specifying this parameter

Reviewed By: sid0

Differential Revision: D6099149

fbshipit-source-id: 26927bdd5c5dba2164688e72d238587f5535ccfc
2017-11-01 19:11:20 -07:00
Siddharth Agarwal
c8d6e7f954 use RepoPath instead of MPath in a few places
Summary:
`RepoPath` represents any absolute path -- root, directory or file. There's a
lot of code that manually switches between directory and file entries --
abstract all of that away.

Reviewed By: farnz

Differential Revision: D6201383

fbshipit-source-id: 0047023a67a5484ddbdd00bb57bca3bfb7d4dd3f
2017-10-31 14:26:39 -07:00
Siddharth Agarwal
9b691889fd blobrepo: use impl Future in a couple of places
Summary:
I spent too much time debugging something that was made a lot easier
once I used `impl Future`.

Reviewed By: StanislavGlebik

Differential Revision: D6094810

fbshipit-source-id: 6bdcf6159a87df56eb61d85a51ade31397ff6994
2017-10-19 09:39:17 -07:00
Stanislau Hlebik
58777d54ca mononoke: support manifold blobstore in eden server
Summary:
Manifold requires a separate thread to do the IO, so we create a separate
detached thread.

Reviewed By: sid0

Differential Revision: D6063729

fbshipit-source-id: a67d1da955aa2cd34e923a0762bbb76c858728b1
2017-10-18 01:36:22 -07:00
Stanislau Hlebik
d408fab739 mononoke: add ManifoldBlobState
Summary:
Blobrepo state with file-based bookmarks and heads and manifold blobstore.
It will be used for eden server testing.

Reviewed By: sid0

Differential Revision: D6063728

fbshipit-source-id: f0542265af015d5c20db225ed6bf85cae954a3ab
2017-10-18 01:36:22 -07:00
Stanislau Hlebik
5961c7558a mononoke: filelog metadata problem fix
Summary:
Mercurial filelog entries may have metadata fields in the beginning, usually used to track copies/renames. Previously mononoke eden server returned this metadata as part of the file blob.
This diff changes it. Now `get_content()` method returns file content without metadata, and to make it consistent, both `get_content()` of the blobrepo and revlog repo do the same.

This decision certainly has it's tradeoffs, because now it's more difficult to get metadata (`get_raw_content` needs to be used).
But we'll probably change how metadata is stored anyway, that's why I think changing `get_content` method is fine.

This diff also cleans up server/src/main.rs file, because previously it had to strip metadata itself.
Also diff fixes problem in metadata parsing - it previously failed if file is less than 2 bytes

Reviewed By: farnz

Differential Revision: D5901476

fbshipit-source-id: f3ade0179710352590068c238e6a733aab68a512
2017-09-26 00:36:55 -07:00
Siddharth Agarwal
a79b8267ae rename Path to MPath
Summary:
`Path` has the potential to be confused with `std::path::Path`.
`MPath` is nice, concise, and clearly different from `Path`.

Reviewed By: jsgf

Differential Revision: D5895665

fbshipit-source-id: dc5ed5c3866b227d753c6d904d3c6d213c882cd7
2017-09-22 17:27:03 -07:00
Stanislau Hlebik
ab14a6f6c9 mononoke: support rocksdb blobstore in eden server
Reviewed By: lukaspiatkowski

Differential Revision: D5861654

fbshipit-source-id: 036249899910c7aa1acda0632e6a3dcd15bf8f72
2017-09-21 08:25:23 -07:00
Stanislau Hlebik
a22f886276 mononoke: fix test
Summary: file blobstore was read data from incorrect folders. This diff fixes it.

Reviewed By: farnz

Differential Revision: D5852736

fbshipit-source-id: 1bc08788023ff2cc9d631985d70329475afc589f
2017-09-19 04:22:42 -07:00
Siddharth Agarwal
da22546d74 move state into a trait
Summary:
We're going to add more stores like obsmarkers and linknodes very
soon. Stuffing all of them into type parameters is going to get ugly very soon.

Instead, add a trait which represents all the state, and make `BlobRepo`
generic on that trait. Add a few implementations for common use cases like
files and RocksDB-based stores.

This allows the dependency lists for the Mononoke and Eden servers to be more
straightforward.

Reviewed By: jsgf

Differential Revision: D5850372

fbshipit-source-id: 37a0687611687b9616ebbddce70f53e1e5d3267b
2017-09-18 00:35:52 -07:00
Siddharth Agarwal
482153dff8 ensure blobstore's ValueOut implements AsRef<[u8]>
Summary:
Just like the previous diff with bookmarks, every user needs this and it makes
sense anyway.

Reviewed By: jsgf

Differential Revision: D5847877

fbshipit-source-id: b91a49e94da2d7e207061b6c52b78c55a2229dec
2017-09-18 00:35:52 -07:00
Siddharth Agarwal
81f2ac473b make bookmark error type implement std::error::Error
Summary: All its users need this, and it makes sense.

Reviewed By: jsgf

Differential Revision: D5847753

fbshipit-source-id: 042c7b5637e5f83918fa9bc5d131c8745d7bbc3e
2017-09-18 00:35:52 -07:00
Siddharth Agarwal
de4b1f6c93 use BlobHash in RawNodeBlob
Summary: Also ensure that `blobimport` doesn't use its own copy.

Reviewed By: jsgf

Differential Revision: D5847604

fbshipit-source-id: 5390848cd5fab8abd967ef9701720491d703c0f1
2017-09-18 00:35:52 -07:00
Justin Uy
73a7b58d58 Use futures-ext BoxFuture and BoxStream in blobrepo
Summary:
Removes usage of BoxFuture and BoxStream from futures crate and instead use
it from internal futures_ext lib.

Reviewed By: sid0

Differential Revision: D5847771

fbshipit-source-id: 01823513176add37caa73c0ea2810e80d7fae955
2017-09-15 17:50:24 -07:00
Siddharth Agarwal
5eea41d9d8 rustfmt blobrepo
Summary: Going to make significant changes here.

Reviewed By: jsgf

Differential Revision: D5831943

fbshipit-source-id: 923c22bc38f89846df61c75e20eb156fc5feddd6
2017-09-14 13:35:12 -07:00
Siddharth Agarwal
a74542da60 update and pull in uuid + subprocess
Summary:
Finally got an update working by removing the `mysql_async` crate.

Some notes:

* The `mysql_async` crate was responsible in this case: see https://github.com/rust-lang/cargo/issues/4066#issuecomment-328210204 for why.
* tokio/futures deprecated a bunch of stuff. I've filed a TODO for now.
* We finally pulled in error-chain 0.11, which has a bunch of nice improvements.

Reviewed By: kulshrax

Differential Revision: D5798282

fbshipit-source-id: a38a7b17ee0205428e2ea63334722aa408582493
2017-09-08 17:05:38 -07:00
Jeremy Fitzhardinge
0745e97bfe mononoke: don't use : in blob key names
Summary:
`:` is a reserved character for Windows paths, so Mercurial rejects
them from being committed. Use `-` instead, so that we can commit file blob
repo test fixtures.

Reviewed By: kulshrax

Differential Revision: D5731525

fbshipit-source-id: 8d14fc03f1b135cbc4d42aeaf2f3a0ae6d13f956
2017-09-04 15:20:06 -07:00
Lukas Piatkowski
936be76e75 mercurial_types: Added Sync to Box<Entry + Sync>
Summary: Would be nice to be able to return future that references a boxed Entry

Reviewed By: jsgf

Differential Revision: D5688859

fbshipit-source-id: acb7bcc461f886bca08b84f31dbebe4f692187f1
2017-08-24 02:49:37 -07:00
Stanislau Hlebik
b72949e3d1 mononoke: blob importing of tree manifest repo
Summary: Main part is `get_stream_of_manifest_entries` that creates a stream of all tree manifest entries by recursively going through all of them.

Reviewed By: jsgf

Differential Revision: D5622490

fbshipit-source-id: 4a8b2707df0300a37931c465bafb1ed54d6d4d25
2017-08-18 09:51:17 -07:00
Stanislau Hlebik
ee917edf1b mononoke: add path join method
Summary:
Adds method similar to https://doc.rust-lang.org/std/path/struct.Path.html#method.join.
Will be used in the next diff to prepend path prefix to the tree manifest entries

Reviewed By: jsgf

Differential Revision: D5563808

fbshipit-source-id: 3637275093c301bf159083cb9bfedaa0e490a75e
2017-08-18 04:40:23 -07:00
Stanislau Hlebik
c33e4afddf mononoke: same storage keys for manifest entries as for the file entries
Summary:
A preparation step before blob importing of tree manifest repos to blobrepo.

`get_parents()` method of BlobEntry reads parents from the blobstore. It works fine for file entries because file entries can stores its parents in the blobstore. With tree manifests BlobEntry can contain also tree manifest entries, and that means that tree manifest entries parents should also be stored somewhere in the blobstore.

I suggest to use the same logic for the tree manifest entries as for the file entries. File and manifest entries have two blobstore entries - one stores hash of the content and parents, another stores the actual content.

To do this I moved `RawNodeBlob` and `get_node()` to the separate module and made fields public.

Reviewed By: jsgf

Differential Revision: D5622342

fbshipit-source-id: c9f0c446107d4697b042544ff8b37a159064f061
2017-08-15 10:37:34 -07:00
Stanislau Hlebik
ad876328e4 mononoke: add get_file_blob() method to Blobrepo
Summary:
Let's create a separate function `fetch_file_blob_from_blobstore` that will be
used to get content of the blob without creating file::BlobEntry.
file::BlobEntry requires Path and type parameters that won't be passed to eden
server.

Reviewed By: jsgf

Differential Revision: D5537647

fbshipit-source-id: 13fb2fbba7d3068b88aac2d842cc92b4da6ca80c
2017-08-09 08:39:07 -07:00
Stanislau Hlebik
467bcb1bd7 mononoke: add get_size method
Summary: Will be used by eden server in the next diff

Reviewed By: jsgf

Differential Revision: D5553955

fbshipit-source-id: 196e2da597d0456b4337a6d9ada8fe188075e87e
2017-08-09 08:39:07 -07:00
Jeremy Fitzhardinge
aa4fe84373 mononoke: repo: allow Repo to be boxed into trait object
Summary: Add helpers to allow an implementation of a Repo object to be boxed up into a type-erased trait object.

Reviewed By: sid0

Differential Revision: D5540673

fbshipit-source-id: c16332f6a548d053125dd3376e7e06d0ddffadf9
2017-08-02 17:43:24 -07:00
Jeremy Fitzhardinge
573256c18a mononoke: Repo: add bookmarks
Summary: Add a `get_bookmarks()` method to the Repo trait and implement it for RevlogRepo and BlobRepo.

Reviewed By: sid0

Differential Revision: D5540667

fbshipit-source-id: 710849e50b1d358be1c4f95a1cbd61efb7c2cf6b
2017-08-02 17:43:24 -07:00
Jeremy Fitzhardinge
22baa86eac mononoke: blobrepo: use chaining for Heads and Blobstore errors
Summary: Blobrepo can take any Heads or Blobstore implementation, each of which may have their own error type. Error chain doesn't support type parameters, and can only have foreign links for specific concrete types. To handle this we have a couple of placeholder errors in Blobrepo's errors which are chained onto the real underlying error.

Reviewed By: sid0

Differential Revision: D5540676

fbshipit-source-id: 9543e204754f22dfd68a04aec5a484fa85d53ff8
2017-08-02 17:43:24 -07:00
Stanislau Hlebik
8027459013 mononoke: use correct path for file node
Summary:
blobimport appends ".bincode" in the end of the file.
Let's do the same in blobrepo

Reviewed By: sid0

Differential Revision: D5527661

fbshipit-source-id: d54fe52c1d282f038a47ac2f2cd0aaf917a92227
2017-08-02 01:01:59 -07:00
facebook-github-bot
2b6af6b941 Initial commit
fbshipit-source-id: f75baa4ff6aa71973f677b752d7aba582cf4927f
2017-07-27 18:00:19 -07:00