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
Summary:
The only verification that needs to be done is for if the delta base
is null.
Also move a rustfmt_skip attribute to the smallest piece of code that it needs to
apply to.
Reviewed By: jsgf
Differential Revision: D6589118
fbshipit-source-id: 287c94871ed30d196c9eaa673cfd7c7f0dd6ed93
Summary:
This allows (actually forces) us to drop a bunch of `as_ref` calls. It also
makes upcoming diffs look cleaner.
Reviewed By: jsgf
Differential Revision: D6585202
fbshipit-source-id: a53902696cf12050a851c30b557aeefe09c41903
Summary:
Add an intrinsic method that acts as an `Arbitrary::arbitrary` implementation
with parameters. The one parameter we have for now is `empty_allowed`, which stands
for whether empty components can be generated.
Reviewed By: jsgf
Differential Revision: D6584040
fbshipit-source-id: 2005e1a77b1bd53294c4386259847a3a113f8f8f
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
Summary:
This diff upgrades the version of rustc in fbcode to version 1.22.1,
including the requisite third-party2 symlink updates for the `rust` and
`rust-crates-io` projects, config.py changes in the third-party2 and
third-party-buck directories, and code fixes for Rust targets in common/rust
and scm/mononoke.
Reviewed By: jsgf
Differential Revision: D6489808
fbshipit-source-id: 48377ea937916beb7dae7a3806de1fce1e29dd24
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
Summary:
There is a complex logic of path encoding in mercurial. Previously only one
case was implemented, when both 'fncache' and 'store' requirements are present.
This commit adds implementation for the case when 'store' requirement is
present, but 'fncache' is not.
Reviewed By: jsgf
Differential Revision: D6405322
fbshipit-source-id: 3b4a0c5b0fd22f43593ffff54dfe748589294012
Summary:
There are a few different path encodings in mercurial. Next diff will add
another one, so in this let's rename fsencode to fncache_fsencode
Reviewed By: jsgf
Differential Revision: D6405324
fbshipit-source-id: 3e67d972b02ca41f29fe24250fb227dd384ea0da
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
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
Summary:
The wire pack format is quite similar to the changegroup format so we can reuse
much of the same code (like deltas).
Reviewed By: jsgf
Differential Revision: D6356906
fbshipit-source-id: 887a5f79c5cf0cf6733a7ef4fcdd2f0592a1c459
Summary:
We can't serve a repo that isn't Send + Sync; make the trait
implicitly Send + Sync so that we don't get caught by this when trying to use
a Repo implementation from the server code
Reviewed By: jsgf
Differential Revision: D6232591
fbshipit-source-id: 199798043e0718831f63b313255830b7f98ed8ca
Summary:
Rust doesn't do variant typing except for lifetimes, so an impl of
Repo for Box<Repo> doesn't apply to Box<Repo + Sync + Send>. Since in practice
all our Repos are Sync + Send, just implement it for that.
(AFAICT implementing it for both would result in a big chunk of copied code,
and it doesn't seem worth doing that or introducing a macro since we don't seem
to be using the non-Sync+Send version.)
Reviewed By: farnz
Differential Revision: D6208968
fbshipit-source-id: a039a31e360255ca104ac2de833ec3d61e8128d7
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
Summary:
This is going to be useful for linknodes, where we must differentiate between a
linknode obtained from a directory (tree) and a linknode obtained from a file.
In this case we must disallow empty `MPath` instances because `FilePath("")` in
particular should not be allowed. Also disallow `DirectoryPath("")` for
symmetry.
Reviewed By: StanislavGlebik
Differential Revision: D6097838
fbshipit-source-id: 302aed1cb03b549787e30e3f0db8c089c9ea67fa
Summary: This is going to be useful in upcoming patches.
Reviewed By: StanislavGlebik
Differential Revision: D6097837
fbshipit-source-id: 0952aa47354b9e9956f934914e73def35d1af3d1
Summary: We're going to use this in upcoming patches.
Reviewed By: StanislavGlebik
Differential Revision: D6097839
fbshipit-source-id: 1abdc62d5c81dce7b5fa3b8f0a264932dded02b8
Summary: This is useful while trying to figure out what path's having issues.
Reviewed By: StanislavGlebik
Differential Revision: D6059219
fbshipit-source-id: 0205a5519f0ea1c9e24944eed5d61907639d46f2
Summary:
This Version type is going to form the basis for other key-value
stores like linknodes, so it needs to be moved into a separate crate.
I've chosen `storage_types` as the name because it seems to be the most obvious
candidate.
Reviewed By: jsgf
Differential Revision: D6015772
fbshipit-source-id: 52de7866d68fdec2a4908626679a6f08c5f73402
Summary:
In some cases applying delta chain to a big binary file can cause an OOM. The problem was in the `Vec::split_off()` method. It creates two vectors with the same capacity. So if we have 30Mb binary that has 1000 fragments applied to it, it results in 30 Gb memory usage.
The easy fix was to run shrink_to_fit() method after Vec::split_off(). While that would work, it seems that `combine_chain()` optimization doesn't really help - I ran parsing of a huge revlog, and performance was similar. So instead of adding shrink_to_fit() method I suggest to remove `combine_chain()` optimization completely.
Reviewed By: lukaspiatkowski
Differential Revision: D5953806
fbshipit-source-id: 93111a2b6db0b76da235cf7ada727b325600d25c
Summary:
These get pretty annoying to construct in tests.
`mercurial-types-mocks` seems like a great place to have them.
I ended up using the `const_fn` feature for convenience.
Reviewed By: StanislavGlebik
Differential Revision: D5898773
fbshipit-source-id: f9ead4e7720ed8ffb0535826603656ff7115b6e4
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
Summary: Also ensure that `blobimport` doesn't use its own copy.
Reviewed By: jsgf
Differential Revision: D5847604
fbshipit-source-id: 5390848cd5fab8abd967ef9701720491d703c0f1
Summary:
Finally use hashencode to hash long path.
This is basically a translation of core mercurial python code to rust.
Tests are also copied from core mercurial
Reviewed By: jsgf
Differential Revision: D5719573
fbshipit-source-id: a53bdeafe22cc9f492b8c08d4ae302a393f9b8fb
Summary:
Let's use separate function fsencode instead of two methods fsencode_dir and fsencode_file.
There are a few reasons for that:
1) This is similar to upsteram mercurial code - it also uses separate function, not a method of the class.
2) Path is supposed to represent a file in the mercurial vfs. Previously we joined this file with "00manifest.i" - it creates a file that doesn't exist in mercurial vfs. This point is debatable though, so I'm fine with making it a method of the class. But probably it doesn't matter that much.
2) We never actually need to encode directory - even in tree manifest case we use fsencode to find location of`00manifest.*` files. That means, that we don't really need to have separate fsencode_dir function, so I was wrong when I added them in the first place.
3) Special hash encoding is used to encode paths that are longer than 120 chars (will be added in the next diff). `00manifest.i` and `00manifest.d` are used in the hash digest, and that means that one fsencode_dir() method is not enough - we'd need to add separate methods to fsencode idx file and separate method to fsencode data file.
Reviewed By: jsgf
Differential Revision: D5719576
fbshipit-source-id: ca6b38dd7d0c6c0c5a345d8fcbe1b0d6fa10a062
Summary:
Allow Arc<R> where R: Repo to be used more generally. Also Box for
completeness.
Reviewed By: farnz
Differential Revision: D5846659
fbshipit-source-id: e101647badfb18a4a59d595ee9b21814b332fe34
Summary: Switch to the implementations in `futures-ext` added in the previous diff.
Reviewed By: jsgf
Differential Revision: D5799732
fbshipit-source-id: f5d54afe5847bb09f0231d5b3c58c0e2e54c391f
Summary: Going to be making significant changes to these files soon.
Reviewed By: kulshrax
Differential Revision: D5796735
fbshipit-source-id: 879fbca3fc936a538c95e50a3333fc2c312de15b
Summary: This parsing is only to check that the modules work together. The metaconfig module still needs to have some proper parsing implemented, Error handling and tests
Reviewed By: jsgf
Differential Revision: D5698544
fbshipit-source-id: 8cd3254c10f977a17ddc31ac2199ee4c9fa98355
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
Summary: This gets us `Display` support as well.
Reviewed By: lukaspiatkowski
Differential Revision: D5734383
fbshipit-source-id: 1485cf80bb310cdd282b4546bed56c60082be8ec
Summary: Just a few minor changes that make our lives easier overall.
Reviewed By: lukaspiatkowski
Differential Revision: D5737854
fbshipit-source-id: da951d7872433bffa8fc64d15cd0e917f77144b5
Summary: auxencode panicked on path with like ' ' or '.'.
Reviewed By: jsgf
Differential Revision: D5706325
fbshipit-source-id: d2ecca2bc983e8adc581cac4e39c314002c171b6
Summary:
PathElement is a blackbox now and it is hard to read inside it.
as_bytes() should at least enable reading the content of it and allow an attempt to create a string out of it. Alternative would be to create a Path using Path::join(&[PathElement]), but that is a bit too much.
Reviewed By: jsgf
Differential Revision: D5688868
fbshipit-source-id: f30879251e3da7e6b90c70bfbadb901a3d818dd7
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
Summary:
Core mercurial takes "data/" and "meta/" prefixes into account when does
fsencode.
It doesn't make a difference now, but it will make a difference when we'll add
hashencode to the fsencode() function.
Reviewed By: jsgf
Differential Revision: D5670748
fbshipit-source-id: 661974c25e00979eedffb30b432518135f0dc631
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
Summary:
Previously `fsencode()` worked incorrectly if Path was a directory. We didn't notice it before because we've never used Path to store directories, but we will use it for TreeManifest.
I considered two options when implementing it.
1) Put some kind of flag `isDir` inside Path struct. But that would create complications with `join()` method. For example, you can't join anything to the file - what should we do in this case? panic? return result?
2) and another `fsencode_dir()` method. Clients need to know what kind of Path they have. I choose this option because it requires less changes and brings less complications compared to the option 1
Reviewed By: sid0
Differential Revision: D5574847
fbshipit-source-id: c4c476a7fc3b884de847c431a56ff5f313c1389f
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
Summary:
Instead of storing `Vec<u8>`, let's store `Vec<PathComponent>`, where PathComponent is Vec<u8> without b'\'.
To make sure len() is still `O(1)` let's store it too.
Reviewed By: sid0
Differential Revision: D5573721
fbshipit-source-id: 91967809284d79bf0fcdcabcae9fd787a37c318b