Commit Graph

72 Commits

Author SHA1 Message Date
Stanislau Hlebik
e6c8ef00aa mononoke: fix computing of changed files
Summary:
The problem was in using `file_changes()` of a bonsai object. If a file
replaces a directory, then it just returns an added file, but not a removed
directory.

However `changed_entry_stream` didn't return an entry if just it's mode was changed (i.e. file became executable, or file became a symlink). This diff fixes it as well

Let's use the same computing changing files method instead of `file_changes()`.

Differential Revision: D14279470

fbshipit-source-id: 976b0abd93646f7d68137c83cb07a8564922ce17
2019-03-08 06:28:49 -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
Stanislau Hlebik
a75a1453f7 mononoke: add bookmark reason moves
Summary:
This is the first step in adding support for tracking all bookmark moves. They
will be recorded in the separate mysql table in the same transaction as
bookmark is updated.

That gives us two things:
1) Ability to inspect all bookmark moves and debug issues with them
2) Also record which mercurial bundle moved a bookmark if any so that we could
later replay these bundles in correct order on hg

Add a struct that let us track bookmark moves.

Reviewed By: ikostia

Differential Revision: D13958872

fbshipit-source-id: 9adfee6d977457db5af4ad5d3a6734c73fcbcd76
2019-02-11 05:50:54 -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
0b0a5b93b2 mononoke: extract blobrepo_factory and postcommit from blobrepo
Summary:
`blobrepo_factory` is a crate that knows how to create blobrepo given
a configuration i.e. it creates blobstores, filenodes, changesets etc and
initializes blobrepo with them.

`post_commit` is a small part of blobrepo which can also be extracted from
blobrepo crate.

There are a few upsides with this approach
1) Less dependencies on Blobrepo, meaning we have to rebuild it fewer times
2) BlobRepo compilation is faster

Reviewed By: jsgf

Differential Revision: D13896334

fbshipit-source-id: 1f5701341f01fcefff4e5f9430ddc914b9496064
2019-02-05 01:23:15 -08:00
Stanislau Hlebik
bd52c0918d mononoke: set bookmark only for heads in fixtures repo
Summary:
This diff fixes TODO. Previously there was a bookmark on every commit in the repo. This is not necessary
and make testing harder (in particular, testing phases). Let's clean it up

Reviewed By: HarveyHunt

Differential Revision: D13454832

fbshipit-source-id: c7d545841073d2030431ef4aed2307a55785f8db
2018-12-17 14:28:55 -08:00
Stanislau Hlebik
541ec421e1 mononoke: remove duplicate commit from fixture
Summary: We have the same commit a few lines above

Reviewed By: HarveyHunt

Differential Revision: D13457024

fbshipit-source-id: 5a3262abf7d39a34c858b2bbc6c0a9ba78afe181
2018-12-17 14:28:55 -08:00
Lukas Piatkowski
5d9a151d85 mononoke: pass CoreContext down to blobstore
Reviewed By: jsgf

Differential Revision: D13324220

fbshipit-source-id: af7a2a650338ea66e504ea0acae1d103af10f8e3
2018-12-04 11:40:15 -08:00
Lukas Piatkowski
02e79837a4 mononoke: pass CoreContext down to bookmarks
Reviewed By: StanislavGlebik

Differential Revision: D13302943

fbshipit-source-id: 356ec3cd3c47f843a5869edb7079d4cbd0ee33aa
2018-12-04 01:16:32 -08:00
Lukas Piatkowski
14636545aa mononoke: pass CoreContext down to changesets
Reviewed By: StanislavGlebik

Differential Revision: D13277448

fbshipit-source-id: 6e9a8dac77af8ab991005d14f654e315c234fe44
2018-11-30 10:14:22 -08:00
Lukas Piatkowski
08db0a35eb mononoke: pass CoreContext down to bonsai-hg-mapping
Reviewed By: aslpavel

Differential Revision: D13277450

fbshipit-source-id: 97cfbd917b321727bb4d960c91a784787660eb5b
2018-11-30 10:14:22 -08:00
Pavel Aslanov
38c5145e9b hadle change only in executable bit same way as Hg
Summary:
Mercurial stores executable bit as part of the manifest, so if changeset only changes that attribute of a file Hg reuses file hash. But mononoke has been creating additional file node. So this change tries to handle this special case. Note this kind of reuse only happens if file has only one parent [P60183653](P60183653)

Some of our fixtures repo were effected, hence this hashes were replaced with updated ones
```
396c60c14337b31ffd0b6aa58a026224713dc07d => a5ab070634ab9cbdfc92404b3ec648f7e29547bc
339ec3d2a986d55c5ac4670cca68cf36b8dc0b82 => c10443fa4198c6abad76dc6c69c1417b2e821508
b47ca72355a0af2c749d45a5689fd5bcce9898c7 => 6d0c1c30df4acb4e64cb4c4868d4c974097da055
```

Reviewed By: farnz

Differential Revision: D10357440

fbshipit-source-id: cdd56130925635577345b08d8ed0ae6e229a82a7
2018-10-15 02:16:50 -07:00
Stanislau Hlebik
a1b12f6beb mononoke: remove broken assert
Summary:
This assert was just broken - it's fine to call `get_full_path()` on file
entry. What's disturbing is that there were no tests that cover this behaviour
i.e. no tests returned modified file!

This diff fixes both problems

Reviewed By: farnz

Differential Revision: D10237589

fbshipit-source-id: dcb7f1977768262491b4624a30a5e861c3c1eadf
2018-10-08 09:06:25 -07:00
Stanislau Hlebik
91dceba40a mononoke: add logic to do batch creation of bonsai changesets
Summary:
Profiling showed that since we are inserting objects into blobstore
sequentially it takes a lot of time for long stacks of commit. Let's do it in
parallel.

Note that we are still inserting sequentially into changesets table

Reviewed By: farnz

Differential Revision: D9683037

fbshipit-source-id: 8f9496b97eaf265d9991b94243f0f14133f463da
2018-09-11 09:53:22 -07:00
Pavel Aslanov
c7badc8b47 store bonsai changesets in bookmarks instead of hg changesets
Summary: - Use `ChangesetId` instead of `HgChangesetId` in `Bookmarks`

Reviewed By: StanislavGlebik

Differential Revision: D9333273

fbshipit-source-id: 96a4d585f9a0479b87556a5f05ae7a9692dd8926
2018-08-15 07:36:15 -07:00
Lukas Piatkowski
9f08d1d60f Back out "[mononoke] store bonsai changesets in bookmarks instead of hg changesets"
Summary: Original commit changeset: e18661793d14

Reviewed By: StanislavGlebik

Differential Revision: D9317492

fbshipit-source-id: 5959936d604d7f2bf9e493e72977bf02003bc247
2018-08-14 11:47:56 -07:00
Pavel Aslanov
fafa719365 store bonsai changesets in bookmarks instead of hg changesets
Summary: - Make `Bookmakrs` work with `ChangsetId` instead of `HgChangesetId`

Reviewed By: StanislavGlebik, farnz

Differential Revision: D9297139

fbshipit-source-id: e18661793d144669354e509271044410caa3502a
2018-08-14 03:21:30 -07:00
Stanislau Hlebik
9abd29d4c3 mononoke: use ChangesetId in Changesets
Summary:
Alas, the diff is huge. One thing is changing Changesets to use ChangesetId.
This is actually quite straightforward. But in order to do this we need to
adapt our test fixtures to also use bonsai changesets. Modifying existing test
fixtures to work with bonsai changesets is very tricky. Besides, existing test
fixtures is a big pile of tech debt anyway, so I used this chance to get rid of
them.

Now test fixtures use `generate_new_fixtures` binary to generate an actual Rust
code that creates a BlobRepo. This Rust code creates a bonsai changeset, that
is converted to hg changeset later.
In many cases it results in the same hg hashes as in old test fixtures.
However, there are a couple of cases where the hashes are different:
1) In the case of merge we are generating different hashes because of different
changed file list (lukaspiatkowski, aslpavel, is it expected?). this is the case for test
fixtures like merge_even, merge_uneven and so on.
2) Old test fixtures used flat manifest hashes while new test fixtures are tree
manifest only.

Reviewed By: jsgf

Differential Revision: D9132296

fbshipit-source-id: 5c4effd8d56dfc0bca13c924683c19665e7bed31
2018-08-06 10:36:43 -07:00
Rain ⁣
b3b1b0e4ed fixtures: fix and update fixtures
Summary:
So the fixtures were broken -- there was apparently a bug that would
cause p2 of root tree manifests to always be null. Fix them by regenerating
trees.

Also the directory name the tarball got extracted to had hyphens in it instead
of underscores. Fix that to make it all underscores.

I used the following commands to do this -- apologies for the hacky zsh:

```
$ for tar in *.tar.gz; do (x=${tar//.tar.gz/}; cp $x.tar.gz ~/local/tmp &&
pushd ~/local/tmp && rm -rf $x ${x//_/-} && tar xf $x.tar.gz && mv ${x//_/-} $x
&& pushd $x/.hg/store && rm 00manifesttree.i && hg backfilltree && popd && tar
cf $x.tar.gz $x && popd && cp ~/local/tmp/$x.tar.gz .); done

$ buck run scm/mononoke/tests/fixtures:regenerate -- *.tar.gz --overwrite
```

Reviewed By: farnz

Differential Revision: D8854625

fbshipit-source-id: 08be7a1e89150b70a308343b43b299a0030708b9
2018-07-17 11:08:18 -07:00
Pavel Aslanov
6a77477d4d added BonsaiHgMapping to BlobRepo
Summary: Makes `BonsaiHgMaping` accessible from `BlobRepo` object

Reviewed By: StanislavGlebik

Differential Revision: D8821709

fbshipit-source-id: 03070ac4f9f390b76740c5d493f5a86b14024158
2018-07-13 08:03:13 -07:00
Rain ⁣
5a29953c59 cmds: move creating blobrepo to cmdlib
Summary: This will be useful for the bonsai verification tool.

Reviewed By: StanislavGlebik

Differential Revision: D8792562

fbshipit-source-id: f409d0fa042528b04462a1539fd3c2a8064a4f6e
2018-07-11 18:36:50 -07:00
Rain ⁣
93c181c35d mercurial-types: simplify Manifest API significantly
Summary:
Manifests are always able to return entries immediately, and never
fail.

Reviewed By: lukaspiatkowski, farnz

Differential Revision: D8556499

fbshipit-source-id: e21a2522f1219e47db9b55b24b6ac6c0c463933e
2018-06-20 18:22:55 -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 ⁣
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
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 ⁣
e3ff3de80c blobstore: move memblob into main blobstore
Summary: It's really straightforward and useful for internal blobstore testing.

Reviewed By: farnz

Differential Revision: D8374496

fbshipit-source-id: 8501e31218ecb5d80530a114e0be5e5d0e8f6c91
2018-06-12 15:40:10 -07:00
Rain ⁣
388474e1bf rename new_blobimport to blobimport
Summary: The old blobimport is dead.

Reviewed By: farnz

Differential Revision: D8372593

fbshipit-source-id: 63595dbcd3ac6da1cad3c5ae6761ef01be6619ed
2018-06-12 15:40:10 -07:00
Rain ⁣
72ba438c95 switch fixture generation to new_blobimport
Summary:
Mostly this was about adding support for file stores to
`new_blobimport`.

Reviewed By: StanislavGlebik

Differential Revision: D8372063

fbshipit-source-id: 2e3791c6222ec430015008f038e1df0464d3f0ba
2018-06-12 15:40:10 -07:00
Rain ⁣
022879f49e generate_memblob_repo: don't read from heads file any more
Summary:
Mononoke hasn't written out heads in a while, so use the topology file
instead.

Reviewed By: StanislavGlebik

Differential Revision: D8371751

fbshipit-source-id: f9af9dddc3349a41c5e9f3a67033bcb3c739f511
2018-06-12 15:40:10 -07:00
Rain ⁣
cf102a1d53 simplify memblob generation code slightly
Summary: Makes upcoming code simpler.

Reviewed By: StanislavGlebik

Differential Revision: D8371506

fbshipit-source-id: 95480058aa78d3a21998ed42a1b52254136146e8
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
Stanislau Hlebik
e99fce6bd4 mononoke: add separate types for Bookmark and BookmarkPrefix
Summary:
This will make it easier to change the "real" bookmark type from AsciiString to
String if we decide to do that.

BookmarkPrefix is a separate type because we may want to change it from
AsciiString to String. Also we don't want to confuse a bookmark prefix with a
bookmark name.

Reviewed By: jsgf

Differential Revision: D7909992

fbshipit-source-id: 3d4d075c204ed5ef1114a743430982c2836bac04
2018-05-09 02:11:17 -07:00
Lukas Piatkowski
18800e00ea heads: remove related crates
Summary: the idea of Mercurial heads in Mononoke will be represented by bookmarks, so there is no need to have them around

Reviewed By: StanislavGlebik

Differential Revision: D7775032

fbshipit-source-id: 1618a1e51862d7c115b2955082f40ee890a045f1
2018-04-27 04:35:21 -07:00
Lukas Piatkowski
35656a1e7d blobrepo: use all server side bookmarks as heads for the sake of discovery
Summary: Although this change is breaking with the traditional definition of heads in Mercurial, we decided that using bookmarks as heads is sufficient for fbsource use case as well as it matches the git model where every unnamed branch is garbage collected.

Reviewed By: jsgf

Differential Revision: D7745541

fbshipit-source-id: 2ec716db7799bf7bab8b2b77a85d1521a880f3df
2018-04-25 04:22:19 -07:00
Siddharth Agarwal
4e9f826728 blobstore: restrict the types that can be stored
Summary:
Currently, any sort of `Bytes` can be stored in the blobstore. That
caused me to make several mistakes while writing the code to store bonsai
changesets, because I'd just end up storing the wrong set of `Bytes`.

Introduce stronger typing so that only types that explicitly implement
`BlobStorable` can be stored in the blobstore.

Currently, these sorts of blobs can be stored in the blob store:

* `ChangesetBlob` and `ContentBlob` in `mononoke-types` (these are Thrift-serialized structures)
* The envelope `RawNodeBlob` and `RawCSBlob` types in `blobrepo`, once converted to `EnvelopeBlob` instances
* `HgBlob`, which contains revlog data (manifests or files) exactly as serialized by Mercurial

Reviewed By: StanislavGlebik

Differential Revision: D7627290

fbshipit-source-id: d1bcbde8881e365dec99618556e7b054985bccf7
2018-04-18 19:53:32 -07:00
Siddharth Agarwal
cc57855b90 mercurial: use FileContents for file contents
Summary:
This is not only the newer, more specific type -- it also makes a couple
of upcoming diffs more straightforward.

Reviewed By: StanislavGlebik

Differential Revision: D7622906

fbshipit-source-id: 4e453b827512c538f4f9777ae4d24627f3b124cf
2018-04-17 11:37:29 -07:00
Lukas Piatkowski
f6c3f72745 CODEMOD: rename mercurial_types::HgChangesetId to DChangesetId
Summary: mercurial_types::DChangesetId should be replaced by types from mononoke_types in most cases and by mercurial::HgChangesetId in others. This rename should help with tracking this

Reviewed By: sid0

Differential Revision: D7618897

fbshipit-source-id: 78904f57376606be99b56662164e0c110e632c64
2018-04-16 03:40:24 -07:00
Lukas Piatkowski
16cbfd5133 CODEMOD: rename mercurial_types::NodeHash to DNodeHash
Summary: mercurial_types::NodeHash should be replaced by types from mononoke_types in most cases and by mercurial::NodeHash in others. This rename should help with tracking this fact.

Reviewed By: sid0

Differential Revision: D7618389

fbshipit-source-id: a876e723d911df626c7851fba56a056843b4e049
2018-04-16 03:40:24 -07:00
Stanislau Hlebik
c1e33531e1 mononoke: regenerate test fixtures
Summary:
Blobimport no longer create linknodes, instead it creates filenodes.
Update test fixtures

Reviewed By: farnz

Differential Revision: D7443318

fbshipit-source-id: c400f9fa780cbc10942b413ceca3990de1132802
2018-04-13 02:47:24 -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
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
6bb13fabf0 mononoke: update test fixture repos
Summary:
Our test repos had flatmanifests. Now blobimport doesn't work with flat manifests.
Generate tree manifests with `hg backfilltree`

Also run `backfilltree` as a part of regenerate script

Reviewed By: farnz

Differential Revision: D7427344

fbshipit-source-id: 134bd0caa7e2b6724664d07598718000f41c69db
2018-03-29 03:29:56 -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
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
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
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
Siddharth Agarwal
6204e214d1 create a mononoke-types crate
Summary:
These are types that are going to be used throughout Mononoke -- I'm hoping to
avoid references to current Mercurial data structures in here.

For now, the only module I've moved is part of the `path` module. The
Mercurial-specific `fsencode` bits have been kept in mercurial-types (though
maybe they should move to `mercurial`?)

In the future, this module will also include definitions for unodes, etc.

Reviewed By: jsgf

Differential Revision: D7188722

fbshipit-source-id: fc097ca12c38a787f83e35af9b8dd308f2b910ea
2018-03-08 10:57:35 -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