Commit Graph

375 Commits

Author SHA1 Message Date
Stanislau Hlebik
4c717285ca mononoke: improve integration tests infra
Summary:
1) Do not use system hg in tests.
Let's use current version of hg in the tests. It will simplify debugging
because we can now easily tweak both hg client and server. It will also result
in fewer test breakages, because previously our tests were broken when system
hg was updated.

2) Run integration tests in parallel with -j option

Reviewed By: quark-zju

Differential Revision: D6998535

fbshipit-source-id: dac4eb6d33978161ffe42d9d6a5a39a3ddf3a4e3
2018-02-16 03:08:40 -08:00
Lukas Piatkowski
bc4c116138 bundle2-resolver: add code for converting changegroup into changesets and filelogs
Summary: The changesets and filelogs can later be handled separately and applied on BlobRepo

Reviewed By: jsgf

Differential Revision: D6988952

fbshipit-source-id: 9959b6acb7913db208c2b4eeea8a1c9913d13678
2018-02-15 09:52:45 -08:00
Lukas Piatkowski
8d5a946ee0 mercurial-bundles: replace the flat Bundle2Item with better structured one
Summary:
The previous Bundle2Stream is a stream of enum that can represent any part of bundle2 - being it a header, inner payload or end marker.

This commit changes the Bundle2Stream to be a stream of more structured elements, where each element is a header with corresponding payload attached.

This new approach is easier to handle, because the way a bundle2 stream is supposed to be dealt with is running an operation per header (where the type of operation depends on type of header). With the old Bundle2Stream the "handling" of bundle2 required basically reparsing it's content to the structures that the new design returns directly.

Reviewed By: jsgf

Differential Revision: D6965529

fbshipit-source-id: 03f7cf57fec5c38addf32bdef3ca56d3239288b9
2018-02-15 09:52:45 -08:00
Lukas Piatkowski
52470ce76c mercurial-bundles: hardcode 'static lifetime in Bundle2Stream
Summary: The only real use case of Bundle2Stream requires it to be 'static, so the is no real point of preserving 'a.

Reviewed By: StanislavGlebik

Differential Revision: D6965528

fbshipit-source-id: 3d5c9c74c1d17980befd3742c54cdde9279aa62c
2018-02-15 09:52:45 -08:00
Lukas Piatkowski
329afcf975 integration test: fix mistyped line in push protocol test
Reviewed By: farnz

Differential Revision: D6998593

fbshipit-source-id: d65fa1c5ccb1558547d1e9c031e95d29048ab3ca
2018-02-15 07:26:29 -08:00
Stanislau Hlebik
48c5ac631a mononoke: fix tests
Summary:
In D6923197 we've made it so that nullid always exists. This is necessary for
pull, because client can send nullids (for example, if client has an empty
repo). That has broken revset test.

Also gettreepack capability was added, that has broken test-push-protocol.t

Reviewed By: quark-zju

Differential Revision: D6988301

fbshipit-source-id: 2deafc3489de9f50126de7212656ffc075ef3537
2018-02-14 08:37:01 -08:00
Stanislau Hlebik
9242864e64 mononoke: implement b2xtreegroupparser
Summary:
This code will be used to convert incoming b2xtreegroup in wirepack
format into TreemanifestEntry, then later can be used in Commit Api.

Reviewed By: lukaspiatkowski

Differential Revision: D6965828

fbshipit-source-id: aff798ea52343d6f64564c9eff34dc5bc2510b38
2018-02-14 08:22:20 -08:00
Stanislau Hlebik
e40bd8bd3d mononoke: add wirepack converter
Summary:
Wirepack packer code has an interesting logic that can be generalized.
For example, it can be used on the push side to convert b2xtreegroup wirepack
stream into stream on entries that can be used by Commit Api. This logic will
be implemented in the next diffs.

In this diff we separate wirepack logic into
two parts: converter stream, that converts wirepack stream into another stream,
and a trait that is used by converter.

Reviewed By: lukaspiatkowski

Differential Revision: D6965830

fbshipit-source-id: 726a84ba44c7f85b5aac48e702755dc904c9c6ab
2018-02-14 08:22:20 -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
Lukas Piatkowski
23be53b205 mercurial-bundles: rustfmt files that are going to be touched in next diff
Reviewed By: StanislavGlebik

Differential Revision: D6965530

fbshipit-source-id: ec350440a0845b49b55977b3c889cf67b936d70c
2018-02-14 06:31:41 -08:00
Lukas Piatkowski
ed54079826 futures_ext: added StreamExt::return_remainder
Summary: This new method is useful in my future work where I rely on this easy to use and readable API to be able to get over the fact that futures combinators take Stream by value. With this one can chain on the end of consuming Stream and by using the "remainder" Future get the consumed Stream.

Reviewed By: StanislavGlebik

Differential Revision: D6965532

fbshipit-source-id: 3ab19851b3d48c43c8d7e3a96ae5c03a7d242960
2018-02-14 06:31:41 -08:00
Stanislau Hlebik
ea4e34d811 mononoke: add failing infinitepush integration test
Summary:
Add an integration infinitepush test. Currently infinitepush is not implemented
in mononoke, so the test fails. We'll use it later to test our functionality.

Also add infinitepush wireproto capability, otherwise the test is useless - it
sends no infinitepush parts at all.

Reviewed By: quark-zju

Differential Revision: D6948967

fbshipit-source-id: 3b479c2c7f036c2b9424de0f160f742bb8ff7412
2018-02-14 03:35:33 -08:00
Stanislau Hlebik
22a09370b7 mononoke: basic lookup implementation
Summary:
Wireproto method to lookup if a revision/bookmark exists.
Currently supports only full hashes, later we'll add support for bookmarks and
node prefixes.

Reviewed By: farnz

Differential Revision: D6948358

fbshipit-source-id: af92a892eae8f787053447e601ebf95dfd638fa4
2018-02-13 10:21:43 -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
4542e7dc1a mononoke: fix tests
Reviewed By: farnz

Differential Revision: D6977472

fbshipit-source-id: 370f0a5a902b98539075da65adc15f67ce4a7080
2018-02-13 10:08:42 -08:00
Stanislau Hlebik
f76937cbc7 mononoke: support renames in hg pull
Reviewed By: quark-zju

Differential Revision: D6922881

fbshipit-source-id: 69fb667ec222d7cc65db8f687178b8db61bd4912
2018-02-13 08:54:31 -08:00
Stanislau Hlebik
97032c01fc mononoke: fetch full file history
Summary:
remotefilelog getfiles method requires fetching the whole history. Current
implementation is naive and it's going to be slow on big repos.
But later we're going to replace it with mysql

Reviewed By: quark-zju

Differential Revision: D6913180

fbshipit-source-id: 9244272a0339a2a83cf5b5615963b65ad2fcdc07
2018-02-13 08:54:31 -08:00
Stanislau Hlebik
9fa48d87d0 mononoke: simple getfiles implementation
Summary:
Currently missing a few things:
1) Fetching the whole history for a file
2) Dealing with renames

That will be fixed in the next diffs

Reviewed By: quark-zju

Differential Revision: D6913179

fbshipit-source-id: f847c61791488bb2842a245ae00de7420b97145e
2018-02-13 08:54:31 -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
0ad9a311ff mononoke: getfiles arguments parsing
Summary:
getfiles is a remotefilelog method to fetch file content. Mercurial client
calls it on-demand, usually during `hg update` command. So normal `hg pull`
with remotefilelog doesn't send filelogs back to the client.

This diff implements getfiles arguments parsing. The code is tricky, so I've
added lots of comments to explain what's going on.

Reviewed By: farnz

Differential Revision: D6913178

fbshipit-source-id: 0248993c3ac487956e0ff547996d51b75cdaee96
2018-02-13 08:54:31 -08:00
Lukas Piatkowski
2ae06415d7 bundle2: add parsing of check:heads part header
Reviewed By: StanislavGlebik

Differential Revision: D6950213

fbshipit-source-id: 107574ac3b1fa35af578ae47b4b23d973dd117d1
2018-02-13 06:22:17 -08:00
Lukas Piatkowski
dfd17c9d57 mononoke: create integration test for a basic push case to treemanifest repo
Summary: making this test work is a 2018 m1 milestone

Reviewed By: farnz

Differential Revision: D6950112

fbshipit-source-id: 798a1b8e722e96b27f0cb8267b82232d3fe0496d
2018-02-13 06:22:17 -08:00
Lukas Piatkowski
09bb644610 bundle2-resolver: initial code to move bundle2 handling to it's own crate
Reviewed By: StanislavGlebik

Differential Revision: D6949669

fbshipit-source-id: 0fcfd05da83f3066cdcb6285e255ddd78282fdef
2018-02-13 06:22:16 -08:00
Lukas Piatkowski
119225d8a7 mercurial-bundles: add replycaps params and payload parsing
Reviewed By: StanislavGlebik

Differential Revision: D6872304

fbshipit-source-id: 8fbf2e7c77b5cd12397b67745e20d06a838d69b9
2018-02-13 06:22:16 -08:00
Simon Farnsworth
03c30f7067 Extend blobstore with methods for commit API
Summary:
The commit API would like to avoid uploading and downloading data when
it doesn't need to - extend the blobstore API so that blobstores can avoid
wasted work

Reviewed By: StanislavGlebik

Differential Revision: D6966729

fbshipit-source-id: 17783e2123d47e43824af724da0b4358a163fa5b
2018-02-13 04:36:20 -08:00
Stanislau Hlebik
0c29c5361a mononoke: fix maybe_copied logic
Summary:
In hg file is maybe_copied if first parent is null
(see https://www.mercurial-scm.org/repo/hg/file/tip/mercurial/filelog.py#l61)
We need to use the same logic for mononoke.

Reviewed By: farnz

Differential Revision: D6948175

fbshipit-source-id: 28c46ecd5ad72a56077d08a8f3756e2500f61ec9
2018-02-12 09:05:39 -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
e2d6103e27 mononoke: gettreepack implementation
Summary:
Simple gettreepack implementation. Current limitations:
1) only one mfnode
2) only one basemfnode
3) only empty rootdir

There is nothing in particular that doesn't allow us to lift this limitations,
I left them for the simplicity of the diff

Reviewed By: jsgf

Differential Revision: D6845032

fbshipit-source-id: 6ecc1f4ab7de4000d29923215592f95685b1ad87
2018-02-07 07:53:48 -08:00
Stanislau Hlebik
04c30c3e46 mononoke: gettreepack command and param parsing
Summary:
Everything needed for gettreepack method to work except for the gettreepack
implementation

Reviewed By: lukaspiatkowski

Differential Revision: D6845034

fbshipit-source-id: b675a2c38c7f6204fac5a6a0885caef246ba7987
2018-02-07 07:53:48 -08:00
Stanislau Hlebik
dc20cc2051 mononoke: add compress function
Summary: Will be used in remotefilelog getfiles method.

Reviewed By: jsgf

Differential Revision: D6884919

fbshipit-source-id: e8037123a4843322c29b37c6b5749444781f4fa7
2018-02-06 11:23:57 -08:00
Stanislau Hlebik
8f0916fdf0 mononoke: add pylz4 crate
Summary:
Add a separate crate that uses lz4 in the same way as python lz4 library. The
main difference is that first 4 bytes are length of the raw data in le32
format. The reason for moving it in a separate crate is to use pylz4 for
remotefilelog getfiles method.

Also removed one panic and replaced it with error.

Reviewed By: jsgf

Differential Revision: D6884918

fbshipit-source-id: 1b05381c045a1f138ab28820175289233b07a91d
2018-02-06 11:23:57 -08:00
Katherine McKinley
95e8874519 Use ChangesetId when initializing RevlogRepo
Summary: Initialize the RevlogRepo using the ChangesetId instead of the NodeHash.

Reviewed By: lukaspiatkowski

Differential Revision: D6867296

fbshipit-source-id: 12f0847324d138466421acc3b1f159a03655333b
2018-02-06 10:21:33 -08:00
Lukas Piatkowski
3124d1b7e0 mercurial-bundles: add debugging log to part_outer to investigate received headers
Summary: If part header send by the client is non-mandatory and unknown then we silently ignore it. Let's add some debug logs to be able to investigate them

Reviewed By: farnz

Differential Revision: D6871679

fbshipit-source-id: c37f9913dd455e47d75356ad0723650528674aab
2018-02-06 06:22:20 -08:00
Lukas Piatkowski
b37a79b66d mercurial-bundle: give stronger types to Bundle2's PartHeader's type
Reviewed By: farnz

Differential Revision: D6871446

fbshipit-source-id: 58879e4e19ffd1de1eed83d622d77768edd03b99
2018-02-06 06:22:20 -08:00
Lukas Piatkowski
7d74c4c0d9 hgproto: return stream of responses to get infinite back-and-forths in handler
Summary: This change let's the handler return multiple responses to the client that is required for commands like `unbundle` to work

Reviewed By: jsgf

Differential Revision: D6820845

fbshipit-source-id: 5f17c2a6100aa989f35d468c188322da4a921059
2018-02-06 06:22:20 -08:00
Lukas Piatkowski
0572acd0f2 hgproto: Dechunker for decoding streaming arguments of a request
Summary: Dechunker parses a hgproto stream of bytes by taking the chunks and letting the code to read them via BufRead API

Reviewed By: jsgf

Differential Revision: D6619521

fbshipit-source-id: 26dfab554a8e4c79079f4c4666c272ec2924c7d2
2018-02-06 06:22:19 -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
d317ac60fc mononoke: fix error message
Reviewed By: farnz

Differential Revision: D6871203

fbshipit-source-id: a3700d898bcaecf3ff94993fc5c84089b115bef0
2018-02-06 02:20:39 -08:00
Stanislau Hlebik
c7c6c8be53 mononoke: reverse nodes in the pull
Summary:
Pulling more than one node doesn't work, because mononoke revsets return
children before the parents. In that case mercurial client fails because new
child points to non-existent parents. To fix it let's reverse the output.
It's bad, because we lose the advantages of streaming, but we do it now anyway
because `getbundle()` method returns Bytes. Besides changelog data should be
fairly small.

Reviewed By: farnz

Differential Revision: D6899239

fbshipit-source-id: 67b3954bfbed8e0aaa69e0da453dae443cd24912
2018-02-06 02:20:39 -08:00
Lukas Piatkowski
2e0a2819d2 hgproto: return '0\n' as response for unbundle request
Summary: This is what the client expexts to receive before streaming can happen

Reviewed By: farnz

Differential Revision: D6833721

fbshipit-source-id: 04a66415638187108366109b0d9062bd8481a628
2018-02-02 10:13:20 -08:00
Lukas Piatkowski
ab6de6b0cd hgproto: make the handler return future of response and future of unprocessed data
Summary:
The client sends us a request that we parse and return response for it. As simple as that.

When the client sends `unbundle` request we need to return an acknowledgment that we are ready to read a bundle2 stream from it.
This means that we first parse the request, then send the response, then parse the stream.

This will be changed in future diffs so that we might:
Parse request from client -> [send acknowledgments -> parse data from client]* -> send response;

Reviewed By: farnz

Differential Revision: D6833723

fbshipit-source-id: 0c13b1e3253bd664bc565eacb5b58a9fc53d4efa
2018-02-02 10:13:20 -08:00
Lukas Piatkowski
bae8272caf hgproto: add unbundle to capabilities
Reviewed By: farnz

Differential Revision: D6833722

fbshipit-source-id: 821562196941bc1f8450242bd173312e5375daed
2018-02-02 10:13:19 -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
Stanislau Hlebik
8c64a71028 mononoke: move changed_entry_stream to manifest_utils
Summary:
It will be used in other places, such as repoconfig.
Unfortunately I had to split tests and implementation. The reason is that tests
depend on blobrepo. Blobrepo crate depends on mercurial_types and that causes
circular dependency. It shouldn't be the case, because
mercurial_types_unittests should be a separate crate, so there may be a bug in
the build system. For now I've split the tests and implementation.

Reviewed By: jsgf

Differential Revision: D6857098

fbshipit-source-id: 1c0af234564dd5628ba6d63d28cf54d7a2dc9217
2018-02-02 07:01:56 -08:00
Arun Kulshreshtha
3e619d7095 Enable mysql and sqlite features for diesel crate
Summary:
Per the title, enable the mysql and sqlite backends for diesel, so
that we can experiment with using diesel with those two DBMSs.

Reviewed By: jsgf

Differential Revision: D6854679

fbshipit-source-id: 66581db1bcafbcc422ababb969500e5d4dd5fafc
2018-02-01 15:38:04 -08:00
Jeremy Fitzhardinge
9df09a500c mononoke/hgproto: remove dep on tokio-proto
Summary: It wasn't needed

Reviewed By: Imxset21

Differential Revision: D6862155

fbshipit-source-id: 21a0d1202e32caba96fb7d6e0923bf2f99f028ea
2018-01-31 13:36:45 -08:00
Jeremy Fitzhardinge
284eb54252 mononoke: documentation pass over mercurial-types/manifest
Summary:
Add some doc comments. Also added tasks for things that at least need
to be looked at.

Reviewed By: StanislavGlebik

Differential Revision: D6836570

fbshipit-source-id: 107f1f4799a369f11fdec7dbe051764a287e3a24
2018-01-31 13:36:45 -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
Stanislau Hlebik
28939bbf11 mononoke: add changed_entry_stream
Summary:
This is a stream of diffs between two manfiests. It will be used in
`gettreepack` wireproto method of treemanifest.

This implementation is slow and simple, because it fetches from blobstore sequentially. We'll make it faster later if needed

Reviewed By: lukaspiatkowski

Differential Revision: D6808892

fbshipit-source-id: 3edcd02a287276b6015ac73fbe977a5b6d8573b5
2018-01-30 01:33:06 -08:00