Commit Graph

98 Commits

Author SHA1 Message Date
Stanislau Hlebik
60c09b8a0c mononoke: do not change timezone during pushrebase
Summary: That matches mercurial pushrebase behaviour.

Reviewed By: ikostia

Differential Revision: D14149754

fbshipit-source-id: 66c0d09e78a21f2f308aba4d334c2db3118cfe9f
2019-02-21 05:47:31 -08:00
Stanislau Hlebik
d0eac0f60f mononoke: save bundles for replay
Summary:
Together with logging bookmark moves, let's also log bundle handle. It will be
used during replay from Mononoke to mercurial.

Reviewed By: ikostia

Differential Revision: D13990929

fbshipit-source-id: 4039322903b13e84fb31c8e65cc2e097ca765213
2019-02-11 05:50:55 -08:00
Kostia Balytskyi
4f2aa75fd7 mononoke: add RawBundle2 boilerplate
Summary:
This diff adds some needed boilerplate for saving raw Bundle2 contents into the
blobstore. This is needed for Mercurial replay.

See the attached task for details.

Reviewed By: StanislavGlebik

Differential Revision: D14018131

fbshipit-source-id: 1130f1ae07c53098e2447b0f8b46e5869f49acdf
2019-02-10 17:00:37 -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
Zeyi Fan
ef0272abca Convert thrift to failure
Summary: Migrate `rust-thrift` from `error-chain` to `failure`.

Reviewed By: Imxset21

Differential Revision: D13853559

fbshipit-source-id: 4bab8c544588265c85dee2f668ed47b8e97d321e
2019-02-06 10:34:10 -08:00
Jeremy Fitzhardinge
42fc72cc54 mononoke: move BlobstoreBytes to blobstore crate
Summary:
This avoids making blobstore depend on mononoke-types, which itself
has complex dependencies.

Reviewed By: StanislavGlebik

Differential Revision: D13944481

fbshipit-source-id: ade338a03efee2107256a91f6b622df98246a11f
2019-02-05 15:21:15 -08:00
Zeyi Fan
52c88d5a39 Reformat code
Reviewed By: Imxset21

Differential Revision: D13950826

fbshipit-source-id: ff7aa5acc92a11576e41609496f56db6e902fd0c
2019-02-04 20:30:27 -08:00
Stanislau Hlebik
8ef5d4ba64 mononoke: change the way file content blobs are hashed
Summary:
File content blobs are thrift encoded in Mononoke. This is done so
that we can change the encoding of content blobs easily. For example, we can
add compression or we can add split the blobs in chunks.

However there is a problem. At the moment file content blob key is a hash of
the actual data that's written to blobstore i.e. of a thrift encoded data. That
means that if we add compression or change thrift encoding in any way, then the
file content blob key changes and it changes the commit hashes.

This is wrong. To fix it let's use hash of the actual file content as the key.

Reviewed By: farnz

Differential Revision: D12884898

fbshipit-source-id: e60a7b326c39dad86e2b26c6f637defcb0acc8e8
2019-01-17 02:33:35 -08:00
Lukas Piatkowski
e785b92bf0 mononoke sql: use from_value_opt instead of parsing numbers from sql manually
Summary: the from_value_opt already knows how to properly parse an integer from sql response, no need to reinvent the wheel and introduce bugs

Reviewed By: aslpavel

Differential Revision: D13651328

fbshipit-source-id: 55af810c99b93bd2f9c67c721a9d0be6034ee466
2019-01-15 07:16:13 -08:00
David Budischek
1558f571c1 Add JSON printing of 'mononoke_admin bonsai-fetch', j...
Reviewed By: StanislavGlebik

Differential Revision: D13622701

fbshipit-source-id: b0b61c23966f9485b99ead7196e276efa8e1e267
2019-01-15 04:02:05 -08:00
Jeremy Fitzhardinge
b4240c995f mononoke: fix MPath Debug formatting
Summary: Fix Debug formatting for MPath - no need to include the full hex name

Reviewed By: aslpavel

Differential Revision: D13494406

fbshipit-source-id: fc2b5e8f2737f3cb5ac0a804b4e9b69ffca49553
2018-12-19 16:49:24 -08:00
Jeremy Fitzhardinge
408e7665d9 mononoke: move RepositoryId into mononoke-types
Summary: There's nothing Mercurial-specific about identifying a repo. This also outright removes some dependencies on mercurial-types.

Reviewed By: StanislavGlebik

Differential Revision: D13512616

fbshipit-source-id: 4496a93a8d4e56cd6ca319dfd8effc71e694ff3e
2018-12-19 10:24:27 -08:00
Jeremy Fitzhardinge
a9817cfec1 mononoke-types: simplify Debug output for MPath
Summary: No need to print the hex.

Reviewed By: StanislavGlebik

Differential Revision: D13457386

fbshipit-source-id: f6063b94e4f095d9ffed06b9de6e302b38e29334
2018-12-14 13:27:44 -08:00
Pavel Aslanov
d5153e0c3a multiplexed blobstore synchronization queue implementation
Summary: This diff implements interface necessary to synchronize multiplexed blobstore

Reviewed By: StanislavGlebik

Differential Revision: D13234501

fbshipit-source-id: 1969ba342c55fe871af9eb45396c80d6aaefb3dd
2018-12-12 05:43:53 -08:00
Pavel Aslanov
87904b1a6d Multiplexed blobstore implementation
Summary: Multiplexed blobstore. More details in this [post](https://fb.facebook.com/groups/scm.mononoke/permalink/743876145974963/)

Reviewed By: StanislavGlebik

Differential Revision: D13062167

fbshipit-source-id: 6db226ae6fbdc7c621a2733a4b11f1cd17238dc3
2018-12-06 07:51:01 -08:00
Stanislau Hlebik
0f5153e1df mononoke: skiplist thrift serialization
Summary:
We'd like to save skiplist data in blobstore so that we won't have to recompute
it. Let's use thrift serialization for it

Reviewed By: lukaspiatkowski

Differential Revision: D13122386

fbshipit-source-id: f44cdcf38fa6a219df9217906a872e60c319e391
2018-11-29 08:19:30 -08:00
Anastasiya Zhyrkevich
d713993c60 mononoke: [lfs] upload blake2 ->sha256 mapping on fetch
Summary:
According to [Git-LFS Plan](https://www.mercurial-scm.org/wiki/LfsPlan), `getfiles` instead of file content should return file in the [following format](https://www.mercurial-scm.org/wiki/LfsPlan#Metadata_format)
```
oid: sha256.SHA256HASH
size: size_int
```

Hg client requests files using sha1 hgfilenode hash. To calculate sha256 of the content, Mononoke is fetching the file from blobstore to memory, and calculate sha256.
It does not give any profit in time and memory consumptions, comparing to non-LFS transfer of Mononoke.

*Solution:*
To put a `key-value` to blobstore, after first request of the file. This means, that after hg client requested sha256 of the file for the first time, after calculation, put it to the blobstore.
Next request of the sha256 of the file content avoid recalcualtion of sha256 in Mononoke. It return sha256 saved in the blob.

Reviewed By: StanislavGlebik

Differential Revision: D13021826

fbshipit-source-id: 692e01e212e7d716bd822fa968e87abed5103aa7
2018-11-22 10:27:46 -08:00
Anastasiya Zhyrkevich
322945ad81 get rid of hardcoded blobstore_key prefixes
Summary:
Mononoke requires several references to the same blob in the blobstore.
Sha256 aliases are good example. [post](https://fb.facebook.com/groups/scm.mononoke/permalink/739273266435251/)

Short description of alias mechanism:
- we have `key: value` blob in blobstore.
- put a `key1: key` blob in blobstore to have 2-step access from `key1` to `value`.

All the keys in Mononoke are of the form `type_prefix.hash_name.hash`

I expanded MononokeId interface to have an access to the prefix `type_prefix.hash_name` for verification `key` content (see alias mechanism description).

Reviewed By: farnz

Differential Revision: D13084145

fbshipit-source-id: 5b8a4e80869481414a7356ccd7c9aab6e24a5138
2018-11-20 01:43:06 -08:00
Lukas Piatkowski
fc352b60fe mononoke: remove diesel from codebase
Reviewed By: StanislavGlebik

Differential Revision: D10512736

fbshipit-source-id: 9cd8d3abdc896a9e7b01aaec63ff69380efc4f0c
2018-10-29 05:18:29 -07:00
Lukas Piatkowski
4adfa5732b bonsai-hg-mapping: convert from diesel to sql
Reviewed By: StanislavGlebik

Differential Revision: D10483793

fbshipit-source-id: 0d76843e702d510fc655eed52a8c0a68b169d06c
2018-10-29 05:18:29 -07:00
Pavel Aslanov
653a77a998 correctly handle case conflicting reenames
Summary:
Correctly handles case conflicting renames (only change in casing).
-  path can now be removed from `CaseConlictingTrie`
- `check_case_conflicts` operates on `BonsaiChangeset` in pushrebase logic

Reviewed By: StanislavGlebik

Differential Revision: D10447522

fbshipit-source-id: d5342e7aa48154debee123b38bf3168e3371baa6
2018-10-19 04:19:56 -07:00
Arun Kulshreshtha
c2de99cd02 Update rust-crates-io to add HTTP/2 crates
Summary:
Updates rust-crates-io to add several HTTP/2 related crates, namely, `h2`, `httpbis`, and `curl`.

Additionally, fix any breakages introduced by new crate versions. (In particular, the `blake2` crate had breaking changes from 0.7.1 -> 0.8.)

Reviewed By: DurhamG

Differential Revision: D10346164

fbshipit-source-id: 6805261542b5b9c46a34cad6cf6e9fe38f074e87
2018-10-11 15:10:23 -07:00
Jun Wu
5828eb48a2 mononoke-types: clarify that copy_from cs_id must match one of parents
Summary:
Add a comment about the restriction of cs_id used in CopyInfo. It must match
one of parents mentioned in BonsaiChangeset.

This makes it clear the cs_id won't be the commit introducing the file
revision. It cannot be other things like an ancient commit in the history, or
a future commit in a different branch, either.

Reviewed By: sunshowers

Differential Revision: D10137729

fbshipit-source-id: 9b2afd7689bb93d45514ea9ab66667eb46a3a11f
2018-10-01 18:06:42 -07:00
Simon Farnsworth
1c3f40aaf5 Log a JSON blob to Scribe for every commit to Manifold repos
Summary:
JSON blobs let other users of Mononoke learn what they need to know
about commits. When we get a commit, log a JSON blob to Scribe that other users can pick up to learn what they want to know.

Because Scribe does not guarantee ordering, and can sometimes lose messages, each message includes enough data to allow a tailer that wants to know about all commits to follow backwards and detect lost messages (and thus fix them up locally). It's expected that tailers will either sample this data, or have their own state that they can use to detect missing commits.

Reviewed By: StanislavGlebik

Differential Revision: D9995985

fbshipit-source-id: 527b6b8e1ea7f5268ce4ce4490738e085eeeac72
2018-09-27 04:25:16 -07:00
Jeremy Fitzhardinge
d865e4dfad tp2/rust: update to Rust 1.29
Reviewed By: StanislavGlebik

Differential Revision: D9978034

fbshipit-source-id: 439ef4f558202980585ba8a4660986b31ade3061
2018-09-21 11:37:10 -07:00
Pavel Aslanov
4ea641671f handle case-conflicts during pushrebase
Summary: Adds case-collision check during push-rebase

Reviewed By: StanislavGlebik

Differential Revision: D9940717

fbshipit-source-id: 30492066aa9d12b784b0dff37c0faf9cf6aed798
2018-09-20 05:06:57 -07:00
Anastasiya Zhyrkevich
f33ea55653 download mononoke api
Summary:
WIP

Mononoke API download  for lfs
support get request
curl http://127.0.0.1:8000/{repo_name}/lfs/download/{sha256}

Reviewed By: StanislavGlebik

Differential Revision: D9850413

fbshipit-source-id: 4d756679716893b2b9c8ee877433cd443df52285
2018-09-20 01:37:00 -07:00
Stanislau Hlebik
72e4b21ba9 mononoke: check case conflicts in commit API
Summary:
Let's check that new case conflicts are not added by a commit.
That diff also fixes function check_case_conflict_in_manifest - it needs to
take into account that if one of the conflicting files was removed then there
is no case conflict.

There should be a way to disable this check because we sometimes need to allow
broken commits. For example, during blobimport

Reviewed By: aslpavel

Differential Revision: D9789809

fbshipit-source-id: ca09ee2d3e5340876a8dbf57d13e5135344d1d36
2018-09-18 07:23:13 -07:00
Anastasiya Zhyrkevich
c603c9d19b Add additional reference to blob
Summary:
Additional 2-step reference for blob:

For each file add an additional blob with:
   key = aliases.sha256.sha256(raw_file_contents)
   value = blob_key

Pay attention, that sha256 hash is taken `from raw_file_content`, not from a blob content.

Additional blob is sent together with the file content blob.

Reviewed By: lukaspiatkowski, StanislavGlebik

Differential Revision: D9775509

fbshipit-source-id: 4cc997ca5903d0a991fa0310363d6af929f8bbe7
2018-09-13 07:53:00 -07:00
Stanislau Hlebik
831e52a98c mononoke: do not generate Blob<Id> unnecessarily
Summary:
In `fetch_file_contents()` `blobstore_bytes.into()` converted the bytes to
`Blob<Id>`. This code calls `MononokeId::from_data()` which calls blake2
hashing. Turns out it causes big problems for large many large files that
getfiles can return.

Since this hash is not used at all, let's avoid generating it.

Reviewed By: jsgf

Differential Revision: D9786549

fbshipit-source-id: 65de6f82c1671ed64bdd74b3a2a3b239f27c9f17
2018-09-13 05:53:10 -07:00
Pavel Aslanov
af69be4b3b case-conflict checking functions
Summary:
Adds case conflict checking functions
- `manifest + path` case
- `[path]` case

Reviewed By: StanislavGlebik

Differential Revision: D9700760

fbshipit-source-id: 582430f61bed1ae279dafbe7804a562d5b2ddf59
2018-09-07 09:06:17 -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
Pavel Aslanov
57d5ddcaf8 added pushrebase configuration options
Summary:
- added `PushrebaseParams` to `RepoConfig`
- configurable recursion_depth and rewritedates

Reviewed By: StanislavGlebik

Differential Revision: D9578661

fbshipit-source-id: df26be4f0f54a54ab6a82fc89d6733099469ce98
2018-08-31 08:55:19 -07:00
Simon Farnsworth
1ffa07da46 Derive Abomonation for all interesting types
Summary:
These are the types that we currently need to be able to serialize if we're to
replace `Asyncmemo`'s caching uses with cachelib. Derive the `Abomonation`
trait for all of them.

Reviewed By: jsgf

Differential Revision: D9082597

fbshipit-source-id: 910e90476a3cc4d18ba758226b8572c3e8d264c6
2018-08-07 13:37:08 -07:00
Rain ⁣
e284a0dac2 bonsai-utils/diff: add ChangedReusedId state
Summary: See the doc comment for what this state represents and why it is necessary.

Reviewed By: StanislavGlebik

Differential Revision: D9025772

fbshipit-source-id: b0588d037365194bbf2d9889ead60237ef097359
2018-07-31 10:36:31 -07:00
Stanislau Hlebik
a9ccfe8cc1 mononoke: create BonsaiChangeset in commit API
Summary:
Now bonsai changesets are created at the same time as hg changesets, and
the mapping between bonsai and hg changesets is recorded

One important piece is missing. At the moment copy info information is ignored.
I'll add it in the next diffs.

Before diff is landed, I re-run the blobimport to prefill missing bonsai changesets.

Reviewed By: farnz

Differential Revision: D8893504

fbshipit-source-id: 1cc4bbcca2f489a0ef6990d6c04d5b3fd8bef92c
2018-07-31 02:24:28 -07:00
Matthew Dippel
5b7be281d2 distance_from method for Generation struct
Summary: Previously there was no way to get at the underlying `u64` in a Generation object. I want to use this in order to determine how deep into the commit graph I need to lazily index nodes while answering queries. This will help keep the indexing limited to only what is relevant to incoming queries.

Reviewed By: StanislavGlebik

Differential Revision: D9009058

fbshipit-source-id: 1b4ec44b8245ead75f3097048e85b0a1aafe84f6
2018-07-30 18:06:25 -07:00
Stanislau Hlebik
3664b775fe mononoke: add get_changeset_id to BonsaiChangeset
Summary:
It's useful to get the hash of the changeset. Looks like we have to clone, but
I'm happy to avoid doing it if that's possible.

Reviewed By: farnz

Differential Revision: D9013977

fbshipit-source-id: bdf06b457fb11c222afddc623c71f3b6b6be30fc
2018-07-30 06:36:31 -07:00
Stanislau Hlebik
5397b3698a mononoke: make commit extras values byte strings
Summary:
Extras value may be non-utf8, for example, hg-git extension generate binary
diff which may be non-utf8.

At the same time it seems that it's better to leave extras key as a utf8
string. However, I'm open to changing it if there is a big pushback

Reviewed By: sunshowers, farnz

Differential Revision: D8991340

fbshipit-source-id: 8f9f33ab3ea77281ae33e0bc735b15201720b761
2018-07-30 06:36:31 -07:00
Rain ⁣
6d1e9a91bc mononoke-types: add a way to construct a DateTime from an RFC3339 string
Summary:
RFC3339 is a standard way to represent dates. See https://tools.ietf.org/html/rfc3339

We're going to use this in code to check for commits older than a certain time.

Reviewed By: farnz

Differential Revision: D9017006

fbshipit-source-id: a4e4325f32d84d4be9b160adf428411d014fb62b
2018-07-29 21:21:33 -07:00
Lukas Piatkowski
6b934172a6 filenodes: add thrift structures for FilenodeInfo
Summary: Those structures will be used in next diffs to store the FilenodeInfo inside memcache for caching purposes

Reviewed By: farnz

Differential Revision: D9014213

fbshipit-source-id: 4952a90415d4b8ab903387fd5cdfaf08d9870c07
2018-07-27 08:21:13 -07:00
Rain ⁣
e66afee5d3 mononoke-types: add a Display for Option<&MPath>
Summary: would like there to be an easier way to print these out.

Reviewed By: StanislavGlebik

Differential Revision: D8888556

fbshipit-source-id: 67634ba81ca7ed5789dbc744ef5ab2a4f26be07e
2018-07-18 14:07:41 -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
Pavel Aslanov
fcb58cf972 sql mapping between {Bonsai|Hg} changesets
Summary:
We need to store relation between Hg changesets and Bonsai changesets.
- `BonsaiHgMapping` is exactly this mapping which establishes injective relation between `{Hg|Bonsai}Changeset`

Reviewed By: StanislavGlebik

Differential Revision: D8801254

fbshipit-source-id: c7df14172e6c2d67c039a24e1bb821e6d92860af
2018-07-11 09:07:13 -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
Matthew Dippel
d5541e465d Move Generation struct to mononoke-types
Summary: Moved the Generation struct, which is a u64 wrapper, from repogen to mononoke-types, and updated the according usages. This should make it easier to phase out RepoGenCache.

Reviewed By: farnz

Differential Revision: D8725538

fbshipit-source-id: cfd39be03bae56d2288053b7b5e212e6d547c833
2018-07-04 13:51:23 -07:00
Rain ⁣
064747b1be mononoke-types: change definition of path-conflict-free slightly
Summary: Only consider changed prefixes, not deleted ones.

Reviewed By: farnz

Differential Revision: D8653065

fbshipit-source-id: 16803cfa56d2be888ad99573db2a56530308b62a
2018-06-27 13:05:55 -07:00
Rain ⁣
c4ec5f571b bonsai: add a method to perform a bonsai diff
Summary:
I really liked how expressing the problem in terms of data structures
made it fairly straightforward to understand.

Reviewed By: farnz

Differential Revision: D8586383

fbshipit-source-id: d1e3c92a3a5b760a0f13f4912420e2a73b937e8d
2018-06-26 15:54:56 -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 ⁣
8b05fd5c16 blobrepo: use thrift blobs for manifests
Summary:
Store manifests as Thrift blobs instead. Required fixing up a lot of
different places, but they should all be pretty clear now.

Reviewed By: farnz

Differential Revision: D8416238

fbshipit-source-id: 523e3054e467e54d180df5ba78445c9b1ccc3b5c
2018-06-20 13:24:56 -07:00