Commit Graph

34 Commits

Author SHA1 Message Date
Mateusz Kwapich
c3c877527c implementation for commit_file_diffs
Reviewed By: krallin

Differential Revision: D18169624

fbshipit-source-id: e010cf4ccc5f5491c0356190f5441ad91a9d5b21
2019-11-06 08:14:45 -08:00
Mark Thomas
3ddc9fe2e9 mononoke_api: add WarmBookmarksCache to mononoke_api::Repo
Summary: Add the WarmBookmarksCache to the Mononoke API Repo, and use this to resolve bookmarks.

Reviewed By: mitrandir77

Differential Revision: D18135758

fbshipit-source-id: 5c674fd55deef486b648fc2982e4ec7c4a540068
2019-10-28 08:00:07 -07:00
Simon Farnsworth
df9c822f13 Wire the Thrift API for cross repo lookups into place
Summary: Earlier commits add a Mononoke API call for cross repo lookups, and a thrift interface for it. Provide the last piece.

Reviewed By: ikostia

Differential Revision: D17856468

fbshipit-source-id: c5c5714a5cea14b550954af8b19f676a89260342
2019-10-18 03:30:38 -07:00
Kostia Balytskyi
9040ebbf6e mononoke: do not use i32 instead of RepositoryId
Summary:
While we have the `RepositoryId` dedicated type, the `RepoConfig` struct used
`i32` for its `repoid` field, so in a lot of places, which referenced or used
this config we continued to use `i32`. This is sad, so let's fix this.

This diff changes `RepoConfig` and everything that depends on it.
Ideally we would also just remove the `.id()` method of the `RepositoryId`
struct, so that our clients have to use the struct, but in a few places it
is deserialized into thift/SQL types, so unless we move those transformations
into the same file (which also seems bad and not future-proof), we cannot get
rid of the method.

Reviewed By: farnz

Differential Revision: D17928574

fbshipit-source-id: 3d9355272cfcd20af787edd6417cc529be640356
2019-10-16 08:11:03 -07:00
Simon Farnsworth
d6f84ca10f Support cross-repo hash lookup in mononoke API
Summary: This lets a user of a megarepo look up subrepo hashes

Reviewed By: ikostia

Differential Revision: D17831869

fbshipit-source-id: 16962fd7b09053e4a7be196ccd0f52c700626bdd
2019-10-13 09:25:45 -07:00
Andres Suarez
cf36295fa4 Yearless license header
Summary:
This diff updates all license headers to use the new text and style.
Also, a few internal files were missing the header, but now they have it.
`fbcode/common/rust/netstring/` had the internal header, but now it has
GPLV2PLUS - since that goes to Mononoke's Github too.

Differential Revision: D17881539

fbshipit-source-id: b70d2ee41d2019fc7c2fe458627f0f7c01978186
2019-10-11 13:52:34 -07:00
Mark Thomas
f39045a35b apiserver: implement SourceControlService file_content_chunk
Summary: Implmement the `file_content_chunk` method, which gets a chunk of file content.

Reviewed By: StanislavGlebik

Differential Revision: D17686286

fbshipit-source-id: 0330aef9f0be1dea3040e9ba3e767867165827e7
2019-10-02 09:08:08 -07:00
Mark Thomas
81828fa498 mononoke_api: add methods for fetching file contents
Summary:
Add methods to fetch file contents, either for the full file, or part of the
file.

Reviewed By: StanislavGlebik

Differential Revision: D17686294

fbshipit-source-id: 8bceee63db13e5eac274f8372631e554a6583036
2019-10-02 09:08:08 -07:00
Mark Thomas
34eb7ee23e apiserver: implement SourceControlService file_info
Summary: Implement the `file_info` method, which returns information about a file.

Reviewed By: krallin

Differential Revision: D17547874

fbshipit-source-id: 89c360d043601beb9e6e55b8bc28cd88eb528ea7
2019-09-25 07:26:46 -07:00
Mark Thomas
b8b4dadc8a apiserver: refactor out methods to get contexts and create errors
Summary:
All source control service methods will need to get contexts and could create
errors if the requested objects don't exist.  Refactor this code out so that it
can be re-used in each method.

Reviewed By: krallin

Differential Revision: D17547879

fbshipit-source-id: 16c6206ad0fae2adc555f8de8b840ced33dd849f
2019-09-25 07:26:46 -07:00
Mark Thomas
9f61c7e41b apiserver: implement SourceControlService file_exists
Summary: Implement the `file_exists` method, which returns true if the file exists.

Reviewed By: krallin

Differential Revision: D17547876

fbshipit-source-id: 55dbc3472a7f06a1878ebd409ed8b5d56fda3033
2019-09-25 07:26:46 -07:00
Mark Thomas
770d5c6621 apiserver: implement SourceControlService tree_list
Summary: Implement the `tree_list` method, which lists all the subentries in a tree.

Reviewed By: krallin

Differential Revision: D17547878

fbshipit-source-id: 12d296cad69fdb90be7bcaf4cedc9ba82cda3f2f
2019-09-25 07:26:45 -07:00
Mark Thomas
63b8d5373a apiserver: implement SourceControlService commit_path_info
Summary:
Implement the `commit_path_info` method, which returns entry information
describing the file or tree at a particular path in a commit.

Reviewed By: krallin

Differential Revision: D17547877

fbshipit-source-id: 9f7f01ae601ab5b618916caa268e038d7240bf21
2019-09-25 07:26:45 -07:00
Mark Thomas
d93ed35d91 mononoke_api: add files
Summary:
Add representations of files to the Mononoke API.

Like trees, files can exist either at paths within commits (which are
represented by a `ChangesetPathContext`, and may also refer to trees), or on
their own (which are represented by a `FileContext` and uniquely identified by
their content id, or one of their content hashes).  We keep these separate, as
history information is only relevant for `ChangesetPathContext`, and
`FileContext` may be more useful for clients that don't care about history.

Reviewed By: krallin

Differential Revision: D17547880

fbshipit-source-id: 4d2fdb27f4e9ebca98a9f7e902af064468a27e71
2019-09-25 07:26:45 -07:00
Mark Thomas
fae4b3c4eb mononoke_api: add trees
Summary:
Add representations of trees to the Mononoke API.

Trees can exist either at paths within commits (which are represented by a
`ChangesetPathContext`, and may also refer to files), or on their own (which
are represented by a `TreeContext` and uniquely identified using their fsnode
id).  We keep these separate, as history information is only relevant for
`ChangesetPathContext`, and `TreeContext` may be more useful for clients that
don't care about history.

Reviewed By: krallin

Differential Revision: D17547881

fbshipit-source-id: be1b742303be84b816f632f1f1185f6fd1969d9e
2019-09-25 07:26:44 -07:00
Stanislau Hlebik
c2b9a2bbb0 mononoke: move function to fetch skiplist
Summary: It will be used in the next diffs

Reviewed By: krallin

Differential Revision: D17498798

fbshipit-source-id: c71319a21aa586208871555f2055c81afb021b52
2019-09-22 04:02:00 -07:00
Mark Thomas
8d43883d93 mononoke_api: switch tests back to old tokio
Summary:
Some parts of mononoke don't yet work inside the new tokio runtime, so switch
back to the old runtime.  This means we can't use `#[tokio::test]`, and
instead must construct our own runtime during the test.

Reviewed By: StanislavGlebik

Differential Revision: D17398589

fbshipit-source-id: 8acc2af92851fb50b89a8fe4087ff3cd3d5707ef
2019-09-17 02:49:41 -07:00
Mark Thomas
019727a0eb mononoke_api: add accessors for inner context fields
Summary: Long chains of field accessors are awkward to use.  Add convenience methods to let us go straight to the context field we are interested in.

Reviewed By: StanislavGlebik

Differential Revision: D17398588

fbshipit-source-id: 9ad789e93a713ab6cded9c2b88e11552f69ee8f8
2019-09-17 02:49:41 -07:00
Mark Thomas
aa6ad17e93 unodes: move crate to derived_data
Summary:
Collect together all derived data in the `derived_data` directory.  This moves
the `unodes` derivation crate.

Reviewed By: StanislavGlebik

Differential Revision: D17314208

fbshipit-source-id: f1b575446192cb9799e443efb1cb863b80ef72d6
2019-09-17 02:49:41 -07:00
David Tolnay
713973975d Replace *fbinit::FACEBOOK with #[fbinit::main]
Summary:
This diff moves initFacebook calls that used to happen just before FFI calls to instead happen at the beginning of main.

The basic assumption of initFacebook is that it happens at the beginning of main before there are additional threads. It must be allowed to modify process-global state like env vars or gflags without the possibility of a data race from other code concurrently reading those things. As such, the previous approach of calling initFacebook through `*fbinit::FACEBOOK` near FFI calls was prone to race conditions.

The new approach is based on attribute macros added in D17245802.

 ---

The primary remaining situations that still require `*fbinit::FACEBOOK` are when we don't directly control the function arguments surrounding the call to C++, such as in lazy_static:

    lazy_static! {
        static ref S: Ty = {
            let _ = *fbinit::FACEBOOK;
            /* call C++ */
        };
    }

and quickcheck:

    quickcheck! {
        fn f(/* args that impl Arbitrary */) {
            let _ = *fbinit::FACEBOOK;
            /* call C++ */
        }
    }

I will revisit these in a separate diff. They are a small fraction of total uses of fbinit.

Reviewed By: Imxset21

Differential Revision: D17328504

fbshipit-source-id: f80edb763e7f42b3216552dd32f1ea0e6cc8fd12
2019-09-13 20:17:29 -07:00
Mark Thomas
78af568a01 apiserver: implement SourceControlService commit_is_ancestor_of
Summary:
Implement the `commit_is_ancestor_of` call, which returns whether this commit
is an ancestor of some other commit.

Reviewed By: krallin

Differential Revision: D17183595

fbshipit-source-id: be7826e778c48dd86f116d7fbcaabe18bdffab44
2019-09-09 04:23:37 -07:00
Mark Thomas
75efc1c5fd apiserver: implement SourceControlService repo_list_bookmarks
Summary:
Implement the `repo_list_bookmarks` call, which lists bookmarks.

Listing scratch bookmarks requires the user to provide a prefix to match on an
a limit for the number of bookmarks to fetch.  There is currently no provision
for paging.

Reviewed By: krallin

Differential Revision: D17157497

fbshipit-source-id: 247f02299f40a9e9142c6ca838fca1d1de874382
2019-09-09 04:23:36 -07:00
Mark Thomas
879c6d9900 apiserver: implement SourceControlService repo_resolve_bookmark
Summary:
Implement the `repo_resolve_bookmark` call, which resolves a bookmark in a repo
to the commits that the bookmark points to.

Reviewed By: krallin

Differential Revision: D17157498

fbshipit-source-id: e7e53df2cb9e3efaddcd22a8d0db344a8d279f08
2019-09-09 04:23:36 -07:00
Mark Thomas
0338560712 apiserver: create new Mononoke alongside apiserver Mononoke
Summary:
Instantiate the new Mononoke internal API's `Mononoke` object alongside the
existing apiserver `Mononoke` abstraction.  We will migrate all uses of the
existing one to the new one and then remove the apiserver's `Mononoke`.

For now, construct the new one by assembling it from the parts of the existing
`Mononoke` abstraction.  When that is removed, we will create the new one
directly.

Provide the new Mononoke object to the HTTP server and the Source Control
Service Thrift server, as both of these will need it.

Reviewed By: krallin

Differential Revision: D16984061

fbshipit-source-id: eb8c237dfa6d82a96d4cb0baf29e4bfa39119bc9
2019-09-09 04:23:35 -07:00
Mark Thomas
cfd62d35f5 mononoke_api: implement From<MononokeError> for source control exceptions
Summary:
Implement `From<MononokeError>` for the source control service thrift exceptions.

This isn't really the right place, as the `mononoke_api` crate shouldn't need
to know anything about thrift, however Rust trait rules mean we have to declare
the implementation in the same crate as `MononokeError`.

Reviewed By: krallin

Differential Revision: D17208631

fbshipit-source-id: f74f16bbde1da9c6dc0c9e1aede769dca6e9a114
2019-09-09 04:23:35 -07:00
Mark Thomas
cb8857b0e0 mononoke_api: support Mercurial hashes as changeset specifiers
Summary:
Make it so that full Mercurial hashes can be used to specify changesets, as
well as full bonsai changeset hashes.

Reviewed By: krallin

Differential Revision: D16803204

fbshipit-source-id: 14db530bf77eb6b76e83697e00d6e2cf46586a0c
2019-09-09 04:23:34 -07:00
Mark Thomas
2e35cfcb0b mononoke_api: create new Mononoke internal API
Summary:
Start the creation of a new Mononoke internal API within the `mononoke_api` crate.

This abstraction will be used by the API server, as well as any future server types.

To create a new Mononoke instance the caller instantiates a `Mononoke` object,
passing it the configuration to load.

Queries begin by calling a method on the `Mononoke` instance, passing a
`CoreContext` for that request.  For example, calling the `repo` method returns
a `RepoContext` object which is bound to the repository and the request
`CoreContext`.  Further methods on these context objects can be called, which
will return either new data or new, more specialized, context objects.

For example, to find the author of a commit, the caller can use:
```
    let ctx = CoreContext::new(...);
    let author = mononoke.repo(ctx, "reponame").changeset(changeset_specifier).author();
```

Reviewed By: StanislavGlebik

Differential Revision: D16803206

fbshipit-source-id: 20a8e08f0075476844df4b8c5015ac3faa22d423
2019-09-09 04:23:34 -07:00
Andres Suarez
3301714eb9 Add comment to resolve linter disagreements
Reviewed By: scottrice

Differential Revision: D17132208

fbshipit-source-id: 7a1b4c659b4be7a248b0a4f662889e75779fa646
2019-08-30 12:40:55 -07:00
Mark Thomas
5e2d9273df mononoke_api: move get_content_by_path to legacy module
Summary:
The `get_content_by_path` method will be replaced by the more general
mononoke_api.  For now, move it to a legacy module so it doesn't get in the
way.

Reviewed By: krallin

Differential Revision: D16803205

fbshipit-source-id: 020f445bc042607d6d09f15014e96f81a7f22f74
2019-08-15 05:07:16 -07:00
Mark Thomas
ad4d247188 mononoke_api: remove unused get_changeset_by_bookmark
Summary: Remove `get_changeset_by_bookmark` as it is no longer used.

Reviewed By: StanislavGlebik

Differential Revision: D16803208

fbshipit-source-id: 935e4c4598aa1121d815adcf8ae3d280e60b10c3
2019-08-15 05:07:16 -07:00
Pavel Aslanov
4aab539821 remove inefficient find_path_in_manifest
Summary: remove inefficient `find_path_in_manifest`

Reviewed By: farnz

Differential Revision: D15899632

fbshipit-source-id: 6d45333b505c40acaf7ecbe7589d474ab79c840e
2019-06-19 09:33:50 -07:00
Thomas Orozco
77ba80ebd8 mononoke: Rename Bookmark to BookmarkName
Summary:
As part of adding support for infinitepush in Mononoke, we'll include additional server-side metadata on Bookmarks (specifically, whether they are publishing and pull-default).

However, we do use the name `Bookmark` right now to just reference a Bookmark name. This patch updates all reference to `Bookmark` to `BookmarkName` in order to free up `Bookmark`.

Reviewed By: StanislavGlebik

Differential Revision: D15364674

fbshipit-source-id: 126142e24e4361c19d1a6e20daa28bc793fb8686
2019-05-21 12:26:02 -07:00
Stanislau Hlebik
eb67262de4 mononoke: return HgEntryId in find_path_in_manifest
Summary:
It's cheap so let's return it. It will be used in the next diffs

Context:
There are some commit cloud commits that take ages to compute. For some reason
commit cloud sends too many manifests, which mononoke doesn't filter out and
does a lot of unnecessary checks, which take ages. This stack fixes it.

Reviewed By: farnz

Differential Revision: D14666306

fbshipit-source-id: 75e39f7d88e139f3558825faec5d4e94f6987050
2019-05-21 12:24:57 -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