Commit Graph

141 Commits

Author SHA1 Message Date
Greg Cowan
041770b090 Transition fbcode Rust crates to 2018 edition
Summary: Marking all Cargo.tomls in fbcode as 2018 edition.

Reviewed By: jsgf

Differential Revision: D15951175

fbshipit-source-id: edf18449c214ee1ff285d6a2cb61839aaf58a8cd
2019-06-24 13:15:17 -07:00
Pavel Aslanov
7c7e084825 Convert MPathElement to a newtype around Bytes
Summary: We are copying `MPath` a lot, this change should reduce amount of allocations and memory reuse for `MPath`

Reviewed By: farnz

Differential Revision: D15939495

fbshipit-source-id: 8da8f2c38f7b46f27d0df661210c9964aed52101
2019-06-21 15:40:55 -07:00
Pavel Aslanov
a0a3a421f2 make HgEntryId an enum
Summary: `HgEntryId` is much more useful in a typed from (enum of `(FileType, HgFileNodeId)` and `HgManifestId`), most of the time we now which type entry should contain and it makes it harder to make and error, all other use cases which require just hash should use `HgNodeHash` instead. This diff includes minimal changes which are necessary to make it work. Some of the cases which do sequence of `Entry::get_hash().into_nondehash() -> HgManifestId::new() | HgFileNodeId::new()` are left for future diffs.

Reviewed By: farnz

Differential Revision: D15866081

fbshipit-source-id: 5be9ecc30dbfd0a49ae6c5d084cdfe2dac351dac
2019-06-18 11:11:52 -07:00
Jeremy Fitzhardinge
ae4a4a5b6c tp2/rust: update to Rust 1.35.0
Summary:
Side-effect changes:
- Doc comments on macro invocations generate a warning that they don't document what the macro expands to => make them non-doc comments
- New warnings from some bad borrowing patterns which were not previously diagnosed (T45010740)

Reviewed By: Imxset21

Differential Revision: D15515133

fbshipit-source-id: a71db51433598e338b660cbf9d2079f4bd51cfba
2019-05-28 14:28:48 -07:00
Jeremy Fitzhardinge
31c5ccb46c Convert scm/mononoke/mercurial to Rust 2018
Summary:
Rust 2018 updates to:
  //scm/mononoke/mercurial:mercurial
  //scm/mononoke/mercurial:mercurial-unittest

Reviewed By: markbt

Differential Revision: D15466962

fbshipit-source-id: bbef671201af064c0454cd45347b3c45ed700a6f
2019-05-23 12:02:07 -07:00
Thomas Orozco
cf6cd664fa remove HgNodeHash from HgChangesetEnvelopeMut
Summary: This removes HgNodeHash (and uses HgChangesetId instead) in HgChangesetEnvelopeMut.

Reviewed By: StanislavGlebik

Differential Revision: D14855029

fbshipit-source-id: c1f343870e18266ae3e636c1b36dfa05fce00bd3
2019-05-21 12:25:06 -07:00
Kostia Balytskyi
e561682ecd mononoke: rename crates to contain underscores instead of dashes
Summary: Let's not use dashes in crate names.

Reviewed By: StanislavGlebik

Differential Revision: D14341596

fbshipit-source-id: 85a7ded60cf2e326997ac70ee47a29116af97590
2019-03-06 07:18:28 -08:00
Johan Schuijt-Li
616654450b unify lz4 compression with hg
Summary:
Mononoke and hg both have their own implementation wrappers for lz4
compression, unify these to avoid duplication.

Reviewed By: StanislavGlebik

Differential Revision: D14131430

fbshipit-source-id: 3301b755442f9bea00c650c22ea696912a4a24fd
2019-02-21 06:27:53 -08:00
Johan Schuijt-Li
50b7d93014 rustfmt before editing
Summary: Code format.

Reviewed By: StanislavGlebik

Differential Revision: D14131431

fbshipit-source-id: 1b6f89382bbbe8b5bb033e3ecf7620d161d587e8
2019-02-21 06:27:53 -08:00
Lukas Piatkowski
c163368a07 blobrepo/src/file.rs: use HgFileNodeId instead of HgNodeHash and propagate it
Summary: HgFileNodeId is a stronger typed id, so it is prefered to use it instead of HgNodeHash whenever it is identifying a filenode

Reviewed By: aslpavel

Differential Revision: D13986172

fbshipit-source-id: c0334652345acb868e86c38b8c0045e9c023c176
2019-02-07 04:04:28 -08:00
Lukas Piatkowski
515a2909eb monononoke hashes: remove usages of borrows of hashes which are Copy
Summary: The Copy trait means that something is so cheap to copy that you don't even need to explicitly do `.clone()` on it. As it doesn't make much sense to pass &i64 it also doesn't make much sense to pass &<Something that is Copy>, so I have removed all the occurences of passing one of ouf hashes that are Copy.

Reviewed By: fanzeyi

Differential Revision: D13974622

fbshipit-source-id: 89efc1c1e29269cc2e77dcb124964265c344f519
2019-02-06 15:11:35 -08:00
Stanislau Hlebik
b64f2a7136 mononoke: change how copy information is found
Summary:
Mercurial has a hack to determine if a file was renamed. If p1 is None then
copy metadata is checked. Note that this hack is purely to make finding renames
faster and we don't need it in Mononoke. So let's just read copy metadata.

This diff also removes `maybe_copied()` method and unused code like `Symlink`

Reviewed By: farnz

Differential Revision: D12826409

fbshipit-source-id: 53792218cb61fcba96144765790278d17eecdbb1
2019-01-17 02:33:35 -08:00
Stanislau Hlebik
c608944cfd mononoke: remove unused code
Summary:
Removed:

cmd-line cmd tool for filenodes and bookmarks. These should be a part of
mononoke_admin script

Outdates docs folder

Commitsim crate, because it's replaced by real pushrebase

unused hooks_old crate

storage crate which wasn't used

Reviewed By: aslpavel

Differential Revision: D13301035

fbshipit-source-id: 3ae398752218915dc4eb85c11be84e48168677cc
2018-12-05 05:58:07 -08:00
Anastasiya Zhyrkevich
bb31c81995 RevIdx flags ExtStored parsing
Summary:
Mononoke blobimports filenodes from Mercurial Host Machines to its blobstore.
It parses revlogs to retrieve flags used for parsing.
Revlogs Contains the flags for Marking Ext Stored FIles. This flag means that the file is not stored at the  Mercurial Host machine, but somewhere remotely.
This diff provides the api to get the extstored flag from revlog.

Reviewed By: farnz

Differential Revision: D13081950

fbshipit-source-id: ba5bc04ad3659d4880960995d1cc46594d89e220
2018-11-22 10:33:58 -08:00
Anastasiya Zhyrkevich
fa18b025e4 Get parents without reconstructing file
Summary:
According to [blobimport logic](diffusion/FBS/browse/master/fbcode/scm/mononoke/cmdlib/src/blobimport_lib/changeset.rs;fd16808edd6e51c1d0b82f4812fe843e797025e0$163-164)  blobimport requests
for parents and node content

Previous implementation was reconstructing filenode to
current revidx for both cases: for getting raw_content and for getting parents.

New implementation avoid reconstruction of the file content to retrieve parents.

Reviewed By: quark-zju

Differential Revision: D12857440

fbshipit-source-id: e1118affe85647931dd551b9ca7be5297afe56ce
2018-10-31 11:37:59 -07:00
Anastasiya Zhyrkevich
d2a4f4e042 getfiles, config lfs threshold
Summary:
getfiles implementation for lfs

The implementation is the following:
- get file size from file envelope  (retrieve from manifold by HgNodeId)
- if file size > threshold from lfs config
   - fetch file to memory, get sha256 of the file, will be fixed later, as this approach consumes a lot of memory, but we don't have any mapping from sha256 - blake2 [T35239107](https://our.intern.facebook.com/intern/tasks/?t=35239107)
   - generate lfs metadata file according to [LfsPlan](https://www.mercurial-scm.org/wiki/LfsPlan)
   - set metakeyflag (REVID_STORED_EXT) in the file header
- if file size < threshold, process usual way

Reviewed By: StanislavGlebik

Differential Revision: D10335988

fbshipit-source-id: 6a1ba671bae46159bcc16613f99a0e21cf3b5e3a
2018-10-17 02:20:06 -07:00
Anastasiya Zhyrkevich
885960087e LFS push: processing files in metadata format from hg client
Summary:
According to [Mercurial Lfs Plan](https://www.mercurial-scm.org/wiki/LfsPlan), on push, for files which size is above the threshold (lfs.threshold config) hg client is sending LFS metadata instead of actual files contents. The main part of LFS metadata is SHA-256 of the file content (oid).

The format requires the following mandatory fields: version, oid, size.

When lfs metadata is sent instead of a real file content then lfs_ext_stored flag is in the request's revflags.
If this flag is set, We are ignoring sha-1 hash verification inconsistency.
Later check that the content is actually loaded to the blobstore and create filenode envelope from it, load the envelope to the blobstore.

Filenode envelope requires the following info:
- size - retrieved on fetching the actual data from blobstore.
- copy_from - retrieved from the file, sent by hg client.

Mononoke still does the same checks for LFS push as for non-lfs push (i.e. checks that all the necessary manifests/filelogs were uploaded by a client)

Reviewed By: StanislavGlebik

Differential Revision: D10255314

fbshipit-source-id: efc8dac4c9f6d6f9eb3275d21b7b0cbfd354a736
2018-10-16 04:24:20 -07:00
Jeremy Fitzhardinge
b4f0a1e7ce tp2: update rust-crates-io
Summary:
Add libnfs, libffi and starlark.

Also nom now has "verbose-errors" feature (via bindgen -> cexpr -> nom), so make some tweaks to cope.

Reviewed By: farnz

Differential Revision: D10371391

fbshipit-source-id: ba889ad16a7b662c5eddafcb1e705b068ccc9af7
2018-10-15 23:08:01 -07:00
Pavel Aslanov
c920dcc0a6 fix copy metadata generation
Summary:
We used generate copy metadata which  mercurial understand but works a bit differently
Relevant mercurial code:
```
def packmeta(meta, text):
    keys = sorted(meta)
    metatext = "".join("%s: %s\n" % (k, meta[k]) for k in keys)
    return "\1\n%s\1\n%s" % (metatext, text)
```

Reviewed By: StanislavGlebik

Differential Revision: D10200805

fbshipit-source-id: f17a51a6aac2e1d3671fbbf3e969ed747e2fce18
2018-10-04 10:08:40 -07:00
Mark Thomas
e0a21d4deb add storerequirements support
Summary:
Add support for the storerequirements feature of Mercurial repositories, which
requires the reader to additionally check the store/requires file for store
requirements.

Reviewed By: StanislavGlebik

Differential Revision: D9850335

fbshipit-source-id: 557ea0f90f3d138d1df56edd94ee23760b9fd849
2018-09-17 04:52:40 -07:00
Jeremy Fitzhardinge
c4ece89763 mononoke: use Chain for errors
Summary:
Use .chain_err() where appropriate to give context to errors coming up from
below. This requires the outer errors to be proper Fail-implementing errors (or
failure::Error), so leave the string wrappers as Context.

Reviewed By: lukaspiatkowski

Differential Revision: D9439058

fbshipit-source-id: 58e08e6b046268332079905cb456ab3e43f5bfcd
2018-09-06 14:24:08 -07:00
Jeremy Fitzhardinge
2cfa682b33 mononoke: use err_downcast generally in mononoke
Summary: Cleans things up a bit, esp when matching Context/Chain.

Reviewed By: lukaspiatkowski

Differential Revision: D9439062

fbshipit-source-id: cde8727437f58b288bed9dfacb864bdcd7dea45c
2018-09-06 14:24:08 -07:00
Zeyi Fan
c1b1005d91 clean up HgBlob and HgBlobHash
Summary: This commits change `HgBlob` from an enum into a struct that only contains one Bytes field, completely removes `HgBlobHash` and changes the methods of `HgBlob` from returning `Option`s into directly returning results.

Reviewed By: farnz

Differential Revision: D9317851

fbshipit-source-id: 48030a621874d628602b1c5d3327e635d721facf
2018-08-19 15:52:34 -07:00
Simon Farnsworth
72d7d4db1b Remove ignored extras_roundtrip_long test
Summary:
This causes `buck test` to return an error code, as it skipped this
test. It's trivial to change `extras_roundtrip` to get a longer test run if
developing this code, and I'd like to be in a place where `buck test && jf
submit` is a good idiom to use for only submitting tested code

Reviewed By: StanislavGlebik

Differential Revision: D9334941

fbshipit-source-id: 98edb18346f75b27175b00096232471839caed71
2018-08-15 07:52:40 -07:00
Simon Farnsworth
cc1454d333 Restore cachelib blob caching
Summary: Reverts D8989404 so that we're using cachelib again.

Reviewed By: jsgf

Differential Revision: D9036003

fbshipit-source-id: 9867a12b81369156ee2e6aa7a7f1c81a638185d6
2018-08-07 11:37:37 -07:00
Lukas Piatkowski
dec3e9a444 mononoke: backout cachelib integration for blob caching
Summary:
Back out "[mononoke] Switch to cachelib for blob caching"

Original commit changeset: 2549d85dfcba

Back out "[mononoke] Remove unused asyncmemo imports"

Original commit changeset: e34f8c34a3f6

Back out "mononoke: fix blobimport"

Original commit changeset: b540201b93f1

Reviewed By: StanislavGlebik

Differential Revision: D8989404

fbshipit-source-id: e4e7c629cb4dcf196aa56eb07a53a45f6008eb4e
2018-07-26 10:09:32 -07:00
Simon Farnsworth
9ee880f90e Remove unused asyncmemo imports
Summary: These files import the asyncmemo crate but do not use it. Remove it.

Reviewed By: StanislavGlebik

Differential Revision: D8951887

fbshipit-source-id: e34f8c34a3f652156b63d795023d67260242a58e
2018-07-23 07:37:30 -07:00
Rain ⁣
aec68835af mercurial-types: don't overload Display for Type's manifest suffix
Summary:
I don't like this because particularly the empty string for regular
files looks weird.

Reviewed By: StanislavGlebik

Differential Revision: D8888553

fbshipit-source-id: 20a9048a19b3fdfe681160a637bc2dfc8932c113
2018-07-18 11:22:30 -07:00
Pulkit Goyal
fc880f518b Add Cargo.toml files to crates. (#7)
Summary:
This is a series of patches which adds Cargo.toml files to all the crates and tries to build them. There is individual patch for each crate which tells whether that crate build successfully right now using cargo or not, and if not, reason behind that.

Following are the reasons why the crates don't build:

  * failure_ext and netstring crates which are internal
  * error related to tokio_io, there might be an patched version of tokio_io internally
  * actix-web depends on httparse which uses nightly features

All the build is done using rustc version `rustc 1.27.0-dev`.
Pull Request resolved: https://github.com/facebookexperimental/mononoke/pull/7

Differential Revision: D8778746

Pulled By: jsgf

fbshipit-source-id: 927a7a20b1d5c9643869b26c0eab09e90048443e
2018-07-09 19:52:27 -07:00
Stanislau Hlebik
3a9da5606a mononoke: add new requirement
Summary:
Hg has added it, it doesn't impact Mononoke.
Without it Mononoke can't read config repo

Reviewed By: farnz

Differential Revision: D8595497

fbshipit-source-id: a5d9f1cc9b00dde805c744a7f876dbdd86bd4a55
2018-06-22 14:51:40 -07:00
Rain ⁣
972822e218 blobrepo: simplify code for converting bonsai FileChange to hg
Summary:
Fetching the blob is still required to compute the node hash, but we don't have
to reupload it.

Reviewed By: farnz

Differential Revision: D8508462

fbshipit-source-id: 341a1a2f82d8f8b939ebf3990b3467ed7ad9244c
2018-06-20 13:24:57 -07:00
Rain ⁣
4eca2ec2d9 upload file blobs as Thrift data structures
Summary:
This will also allow file blob sharing between the Mercurial and Mononoke
data models.

Reviewed By: farnz

Differential Revision: D8440330

fbshipit-source-id: a29cd07dcecf0959dffb74b7428f3cb11fbd3db6
2018-06-20 13:24:56 -07:00
Rain ⁣
9ede6636a7 BREAKING CHANGE: switch to Thrift encoding for changesets
Summary:
Pretty straightforward. Also using this opportunity to add per-repo
prefixes, since all the hashes are going to break anyway.

Note for reviewers: almost all the change is regenerated test fixtures (unfortunately necessary to make atomic). The actual substantive changes are all in the first few files.

Reviewed By: farnz

Differential Revision: D8392234

fbshipit-source-id: c93fc8c6388cb00fe5cff95646ad8c853581cb8c
2018-06-20 13:24:56 -07:00
Rain ⁣
3398f7de90 mercurial: fix EntryContent
Summary:
Shouldn't return Symlink for MPath, and a blob with stripped metadata
is not an `HgBlob`.

Reviewed By: farnz

Differential Revision: D8508834

fbshipit-source-id: 387f2bd4f9439ed6b7593b057be035ed9f5452ad
2018-06-19 13:22:46 -07:00
Pavel Aslanov
25f253d3b4 save the file FileChange as a Mercurial format HgBlobEntry
Summary: Added logic to save `FileChange` as a Mercurial format `HgBlobEntry`

Reviewed By: sunshowers

Differential Revision: D8187792

fbshipit-source-id: 4714c81ab23ebac528cfec15c4a9e66083d4fb6c
2018-06-15 12:33:23 -07:00
Rain ⁣
ed033f2b25 store and return p1 and p2 separately for changesets
Summary:
Unfortunately `HgParents` can't represent all valid parents, because
it can't represent the semantically important case where `p1` is `None` and
`p2` is not. (For incoming changesets we'd like to keep full fidelity with
Mercurial.)

All the Thrift definitions store `p1` and `p2` separately anyway, so just make
that change throughout `RevlogChangeset` and `BlobChangeset`.

Reviewed By: StanislavGlebik

Differential Revision: D8374125

fbshipit-source-id: 63674daaad05d4d4cae3778744dbf1c14b3c2e3b
2018-06-12 15:40:10 -07:00
Rain ⁣
3665c48fc7 remove the old blobimport tool
Summary:
The old blobimport tool will not be able to import commits with the new Thrift serialization they'll be switching to.

`blobrepo::utils::RawNodeBlob` is also used by the admin tool, and it will go away once we start using Thrift serialization.

Reviewed By: farnz

Differential Revision: D8372455

fbshipit-source-id: d02a37e33e1ccd4dd1f695e38dbb40851dd51cd6
2018-06-12 15:40:10 -07:00
Lukas Piatkowski
4f44c3f130 mercurial_types: remove D* types and move mercurial types around
Summary:
Now it is as it should be: mercurial_types have the types, mercurial has revlog related structures
burnbridge

Reviewed By: farnz

Differential Revision: D8319906

fbshipit-source-id: 256e73cdd1b1a304c957b812b227abfc142fd725
2018-06-07 13:19:16 -07:00
Lukas Piatkowski
f15ea2eca1 mercurial: fix extras escaping
Summary: extras use python's escaping functionality in mercurial, the '\r' case is happening in production data

Reviewed By: StanislavGlebik

Differential Revision: D7925149

fbshipit-source-id: 23c544b8a757c40a120b69d1ec1ad942c672de17
2018-05-09 02:54:09 -07:00
Rain ⁣
0a0bc2b420 mercurial: add changeset envelopes
Summary: This will replace `RawCSBlob` and the current bincode serialization.

Reviewed By: StanislavGlebik

Differential Revision: D7869524

fbshipit-source-id: 1a2f5d159a20889b10bb6b235f48769da4a187c1
2018-05-07 14:49:46 -07:00
Rain ⁣
3f75ea7084 mercurial: implement manifest envelopes
Summary:
Very similar to file envelopes.

Also add some missing `#[inline]` annotations for file envelopes.

Reviewed By: StanislavGlebik

Differential Revision: D7868445

fbshipit-source-id: 3fb0d87e087612f37c8d5d0a90065359c671ceb8
2018-05-07 14:49:45 -07:00
Lukas Piatkowski
e59fec4631 blobnode: if p1 == p2 do not treat it as Parent::One, but use Parent::Two instead
Summary: Apparently p1 == p2 is a thing that happens in Mercurial, let's keep this logic in Mercurial-facing objects

Reviewed By: StanislavGlebik

Differential Revision: D7830183

fbshipit-source-id: eb473d57cb05f6553327bee2d5aeff9cf7d50eba
2018-05-01 16:35:08 -07:00
Stanislau Hlebik
3392ed61e9 mononoke: fix delta application
Summary:
If baserev == Some(idx), we changed it to None. Also we can have None if
baserev == -1 in mercurial. However these two cases are different. In the first
case it means that we have a literal chunk, not delta. In the second case it
means that we have a delta against empty string! So this is technically almost
the same, except that delta against empty string also have a 12 bytes prefix.
Previously this prefix was used as part of a revision data.
This diff fixes it.

Reviewed By: quark-zju

Differential Revision: D7815713

fbshipit-source-id: def2e54b2cc7379ba8f931ecf3f3c0c38d716058
2018-05-01 01:34:37 -07:00
Stanislau Hlebik
d0bb9540a7 mononoke: remove unused parameter
Reviewed By: quark-zju

Differential Revision: D7815769

fbshipit-source-id: f49318398519111da351d03f73864088b73517fe
2018-05-01 01:34:37 -07:00
Lukas Piatkowski
3859718ff5 mercurial_types: return Error on malformed delta application
Summary: The current behavior of delta::apply will panic Mononke server when the client sends malformed delta request. This change will instead propagate an Error explaining why the delta was malformed.

Reviewed By: jsgf

Differential Revision: D7775544

fbshipit-source-id: a64c27c7b9f13323b8be70eb8c2cdf315ce8f08d
2018-04-28 16:33:03 -07:00
Siddharth Agarwal
782e18fe55 mercurial: add file node envelope
Summary:
We'd like to move away from `RawNodeBlob` and `RawCSBlob` to data structures
serialized by Thrift. This is the first step to doing that.

The most important thing here is that it reuses file content IDs from native
Mononoke storage.

Reviewed By: jsgf

Differential Revision: D7771990

fbshipit-source-id: de4ee0b56aa6610caeff84b2235e19855df086cb
2018-04-27 14:04:38 -07:00
Siddharth Agarwal
9e49e6da1a blobrepo: make upload_entry arguments named, move to Hg domain
Summary:
We're going to keep this around for now as part of double-writing.
All the hashes here are definitely Mercurial hashes, so use them that way.

Reviewed By: lukaspiatkowski

Differential Revision: D7683890

fbshipit-source-id: 270091cd11f3cec7ef4cf565de5ef913fcf7adea
2018-04-20 08:40:54 -07:00
Siddharth Agarwal
3591b86b9f mercurial: switch file::File to HgNodeHash
Summary:
file::File works entirely in the Mercurial domain, so these
conversions are good.

Reviewed By: StanislavGlebik

Differential Revision: D7665973

fbshipit-source-id: 8a192c5d1886492ad21593693b080c8e5ddf8f7e
2018-04-20 08:40:54 -07:00
Siddharth Agarwal
7dc019e422 blobrepo: add some context + clean up error messages
Summary:
I was trying to debug something with the new blobimport, and this was
getting in the way.

Reviewed By: StanislavGlebik

Differential Revision: D7664660

fbshipit-source-id: 2ec4ee79fbe13584f35e7dcd9e8df2b8bdf181c0
2018-04-18 19:53:34 -07:00
Siddharth Agarwal
8282139719 mercurial-types: use the base DateTime from mononoke-types
Summary:
The base type is better because it can represent dates from before
1970 as well.

Reviewed By: StanislavGlebik

Differential Revision: D7652095

fbshipit-source-id: 6d66a06e18ba28e13e70b9f0e921acbd3d55baaf
2018-04-18 19:53:33 -07:00