Commit Graph

49 Commits

Author SHA1 Message Date
Lukas Piatkowski
744c909225 bookmarks: convert from diesel to sql
Reviewed By: StanislavGlebik

Differential Revision: D10512737

fbshipit-source-id: 7c2612c7799972a63d9865c77f1599f39da0c762
2018-10-29 05:18:29 -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
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
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
Christopher Kuklewicz
6cc2cd49f8 Unifying sql code for Mononoke/Diesel
Summary:
Unify all uses of Sqlite and of Mysql

This superceded D8712926

Reviewed By: farnz

Differential Revision: D8732579

fbshipit-source-id: a02cd04055a915e5f97b540d6d98e2ff2d707875
2018-07-08 09:06:22 -07:00
Jeremy Fitzhardinge
a5937a5424 mononoke/dbbookmarks: return txn success as bool
Summary:
We need to be able to distinguish logical transaction failure from
infrastructure failure, so change the `Transaction::commit` future to
`Future<Item=bool, Error=Error>`, where `false` indicates a logical transaction
failure. This allows the caller to determine whether a retry or other recovery
logic is needed.

Reviewed By: lukaspiatkowski

Differential Revision: D8555727

fbshipit-source-id: 8ab64f3019f2644e7eaabc8d699d99aa8eb08fbb
2018-06-29 20:37:09 -07:00
Stanislau Hlebik
9d5c2f4c84 mononoke: add missing repo_id to bookmarks update queries
Summary:
All sorts of weird can happen. The reason it didn't is because we had just one
repo

Reviewed By: lukaspiatkowski

Differential Revision: D8530459

fbshipit-source-id: aa3acd393f2dc96ea2141d09deb0209cbc29a740
2018-06-20 00:21:59 -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
Jeremy Fitzhardinge
a2daf8c2d5 mononoke: no need to pass Mysql connection params by value
Summary: It only needs to borrow them.

Reviewed By: kulshrax

Differential Revision: D8244267

fbshipit-source-id: 2a24a3b7c6eb65177e4e26c57650dd7e096b4202
2018-06-04 08:51:25 -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
7e6b69046c blobrepo: persist bookmarks in on-disk Sqlite database
Summary: For on-disk-rocksdb use cases we should persist bookmarks like any other table we use

Reviewed By: farnz

Differential Revision: D7728717

fbshipit-source-id: f63a6410f5ed254a719a16a7504d1b31da5a20a8
2018-04-24 11:17:06 -07:00
Stanislau Hlebik
0392799c87 mononoke: add mysql bookmarks
Summary:
The diff size is formidable, however it's not that bad really. This is just
about moving the code inside the macro and tests in a separate file.
This is similar to changesets or filenodes crates

Reviewed By: lukaspiatkowski

Differential Revision: D7639681

fbshipit-source-id: 4216652780bf99939245ae39e508b3b46cf96a03
2018-04-21 11:24:24 -07:00
Stanislau Hlebik
27d38be015 mononoke: make SqliteDbBookmarks cloneable and pass it to transaction object
Summary:
Instead of passing Connection, let's pass SqliteBookmarks struct.
This makes adding mysql bookmarks easier.

Reviewed By: lukaspiatkowski

Differential Revision: D7639679

fbshipit-source-id: 7c12e4dbc56b5ad00ecb3a00877da0e2600c3039
2018-04-21 11:24:24 -07:00
Stanislau Hlebik
fb45846aa2 mononoke: add get_conn method to bookmarks
Summary:
This is similar to what we've already done in filenodes and changesets. Sqlite
implementation just grabs the lock, future mysql implementation will get a
connection from pool.

Reviewed By: lukaspiatkowski

Differential Revision: D7585387

fbshipit-source-id: 95a046808f4d78d7776a26bdf3f7d939b1ee0451
2018-04-21 08:40:24 -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
Stanislau Hlebik
27d46fd45c mononoke: change the schema of bookmarks table
Summary:
Bump bookmark size limit - we use 512 for infinitepush, let's use the same
here. Also add a primary key

Reviewed By: farnz

Differential Revision: D7534967

fbshipit-source-id: aeef926de910a3a9934fb1588778f8f503821071
2018-04-09 08:03:51 -07:00
Stanislau Hlebik
7e3daf753c mononoke: implement bookmarks using diesel
Summary:
Implementation of the bookmarks trait using diesel. Currently it's quite slow
because it uses mutex to make the struct sync. Also it's not really async, even
though it returns future. The plan to make it async is to move the computation
on a separate thread pool.

Reviewed By: kulshrax

Differential Revision: D7255935

fbshipit-source-id: ce622a14af777ae470aecc039cef8c6cab9db41e
2018-03-21 14:24:43 -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
Stanislau Hlebik
1de996bcc6 mononoke: RFC: new bookmarks crate
Summary:
First draft of the new bookmarks trait. Note that it doesn't support Bookmarks
& Heads simultaneous transactions.

There are a few notable differences from old bookmarks trait:
1) New `Transaction` trait was added that handles all write operations.
2) It has two different set methods: `set()` and `set_unconditionally()`.
   `set()` checks the current bookmark value before updating it,
   and `set_unconditionally()` doesn't.

Reviewed By: farnz

Differential Revision: D7138038

fbshipit-source-id: 8cbec5caa972d847a30baa0a351df651306b4fd1
2018-03-15 10:17:23 -07:00
Stanislau Hlebik
801591845e mononoke: move bookmarks to bookmarks_old
Summary:
We are going to significantly change Bookmark trait and implementation.
We are going to use Diesel, and new Bookmark trait won't use Version. Instead
of changing the current implementation, let's just move it to the separate
directory which will soon be deleted.

Reviewed By: lukaspiatkowski

Differential Revision: D7138039

fbshipit-source-id: 72b81bf7f6524052b3a360bac23ab56a978b08cb
2018-03-06 04:47:34 -08:00
Julian Priestley
67e908efe0 Use ChangesetId rather than NodeHash in bookmarks
Summary: Update the bookmarks module to use ChangesetId to represent bookmarks, rather than NodeHash.

Reviewed By: lukaspiatkowski

Differential Revision: D6774650

fbshipit-source-id: 1742e4e78798ad68a7f17ebd345eef14a7de2cec
2018-01-22 10:23:36 -08:00
Jeremy Fitzhardinge
ac31713c84 rust: failure cleanup pass
Summary:
Don't use failure's bail!() and ensure!() macros.

Instead, failure_ext provides:
- bail_err!(err) - Converts its single parameter to the expected error and returns; ie `return Err(From::from(err));`
- bail_msg!(fmt, ...) - takes format string parameters and returns a `failure::err_msg()` error
- ensure_err!(), ensure_msg!() - corresponding changes

Also:
- remove all stray references to error-chain
- remove direct references to failure_derive (it's reexported via failure and failure_ext)
- replace uses of `Err(foo)?;` with `bail_err!()` (since `bail_err` unconditionally returns, but `Err(x)?` does not in principle, which can affect type inference)

Reviewed By: kulshrax

Differential Revision: D6507717

fbshipit-source-id: 635fb6f8c96d185b195dff171ea9c8db9e83af10
2017-12-07 14:10:17 -08:00
Jeremy Fitzhardinge
dc5e78c1c1 rust: mass convert scm/mononoke/... to use failure
Summary:
Convert scm/mononoke to use failure, and update common/rust crates it depends on as well.

What it looks like is a lot of deleted code...

General strategy:
- common/rust/failure_ext adds some things that are in git failure that aren't yet in crates.io (`bail!` and `ensure!`, `Result<T, Error>`)
- everything returns `Result<T, failure::Error>`
- crates with real error get an error type, with a derived Fail implementation
  - replicate error-chain by defining an `enum ErrorKind` where the fields match the declared errors in the error! macro
- crates with dummy error-chain (no local errors) lose it
- `.chain_err()` -> `.context()` or `.with_context()`

So far the only place I've needed to extract an error is in a unit test.
Having a single unified error type has simplified a lot of things, and removed a lot of error type parameters, error conversion, etc, etc.

Reviewed By: sid0

Differential Revision: D6446584

fbshipit-source-id: 744640ca2997d4a85513c4519017f2e2e78a73f5
2017-12-05 18:11:13 -08:00
Arun Kulshreshtha
fd2c414961 Update to Rust 1.21
Summary:
This diff does a few things:
  - Change the rust versions in `third-party{2,-buck}/config.py` to 1.21.
  - Update the tp2 symlinks for `rust` and `rust-crates-io`
  - Fix build breakages due to new errors/warnings from rustc.

Reviewed By: jsgf, Imxset21

Differential Revision: D6319954

fbshipit-source-id: cd4fe9e0d6f26c1a6c9c3f1256d84cb002bb83d6
2017-11-29 15:21:41 -08:00
Simon Farnsworth
5519eae489 Make Bookmarks a parameterless trait
Summary:
As part of removing excess genericism, make Bookmarks a trait with no
associated types or type parameters. I will revisit error types here once I
have removed the Repo trait - these are not ideal, but enough to get things
going

Reviewed By: StanislavGlebik

Differential Revision: D6405315

fbshipit-source-id: 814c106612a061e1766f1ea9a9428a13a73bd007
2017-11-27 08:05:02 -08:00
Arun Kulshreshtha
2ac5581e5d Add DbBookmarks to bookmarks-test
Summary: Add DbBookmarks to the common bookmarks test crate, which runs tests that all bookmarks implementations must pass.

Reviewed By: farnz

Differential Revision: D6215852

fbshipit-source-id: 64238c584eb05cbccdef78a68cec6c8f93b14df1
2017-11-08 16:16:27 -08:00
Arun Kulshreshtha
918b1f2dbe Add MySQL-backed Bookmarks implementation
Summary: Add a new implementation of the Bookmarks trait backed by a MySQL database.

Reviewed By: farnz

Differential Revision: D6215856

fbshipit-source-id: 4258a6195a946917a1878e87a53f9bbc6ca64400
2017-11-08 16:16:27 -08:00
Arun Kulshreshtha
43b85874f3 Use NodeHashes instead of Strings for values in bookmarks-test
Summary: In practice, Mononoke requires that the Value associated type of the Bookmarks trait be NodeHash. As a result, in the case of DbBookmarks, rather than making the implementation fully generic over values, I've made it specialized for NodeHashes for simplicity's sake. This means in order to use these tests, they need to store NodeHashes instead of Strings.

Reviewed By: farnz

Differential Revision: D6217789

fbshipit-source-id: 3f0f04180eb0869eb9de3da7be634d95c2b24d84
2017-11-08 16:16:27 -08:00
Arun Kulshreshtha
83293f1441 Add Core to test harness in bookmarks-test
Summary:
The `Bookmarks` trait assumes that the underlying implementation is asynchronous (as evidenced by the fact that all methods return `Future`s). Most non-toy implementations of an asynchronous bookmark store will need to schedule arbitrary tasks on the Core executing the returned Futures. (In some cases, the constructor itself may need to schedule tasks on the Core.) As such, this test harness should expose a Core to each test in a first class way (rather than trying to shoehorn it in via the `state`, which doesn't actually quite work here).

Existing implementations can just ignore the Core.

Reviewed By: jsgf

Differential Revision: D6215855

fbshipit-source-id: ea3f28bdaec667111b384db29d0c7c49954398e5
2017-11-08 12:30:47 -08:00
Siddharth Agarwal
dfd53e9233 filekv: allow specifying a version during set
Summary:
This field is optional. We need to ensure in linknodes that the
version is always set to a fixed value so that linknode blobs written out to
disk are deterministic.

Reviewed By: jsgf

Differential Revision: D6214032

fbshipit-source-id: c1eea7bf28bb096c1d23165e1f50ff2dc6d21274
2017-11-02 13:10:56 -07:00
Siddharth Agarwal
acda30f2fb replace AsRef<Path> with Into<PathBuf> in a few spots
Summary:
We need ownership of the buffer in all of these cases, and
`AsRef<Path>` could potentially create unnecessary copies.

Reviewed By: jsgf

Differential Revision: D6214034

fbshipit-source-id: 806a87bfe3b125febaaaaf26c8b8dcac407de145
2017-11-02 13:10:56 -07:00
Siddharth Agarwal
a730eb9ec9 bookmarks: unify bookmark tests
Summary:
All bookmark implementations, including the upcoming MySQL-based one,
should work with these tests.  Don't duplicate them in every test crate.

Reviewed By: StanislavGlebik

Differential Revision: D6075454

fbshipit-source-id: 547e3c2c98326a6fdca55a562811924ebec93796
2017-10-17 09:09:48 -07:00
Siddharth Agarwal
10b1993ca0 factor out file-based key-value store from FileBookmarks
Summary:
This code is generally useful and will also be used for linknodes.

Note that I marked `filekv` as a copy of `filebookmarks` to preserve blame
info. Git doesn't track renames so this unfortunately won't be transferred to
the open source repo.

Reviewed By: farnz

Differential Revision: D6015776

fbshipit-source-id: 2c17e2440e25e6179dd71d16a87095ad1b346b49
2017-10-10 07:29:30 -07:00
Siddharth Agarwal
86f4489e7c move bookmarks::Version into a separate crate
Summary:
This Version type is going to form the basis for other key-value
stores like linknodes, so it needs to be moved into a separate crate.

I've chosen `storage_types` as the name because it seems to be the most obvious
candidate.

Reviewed By: jsgf

Differential Revision: D6015772

fbshipit-source-id: 52de7866d68fdec2a4908626679a6f08c5f73402
2017-10-10 07:29:30 -07:00
Siddharth Agarwal
7351b25695 rustfmt a few files
Summary:
Will be making functional changes to these files separately and don't
want the two to interfere.

Reviewed By: jsgf

Differential Revision: D6015773

fbshipit-source-id: 26529ce4075ac47e5f0e80177319e1beb90c2076
2017-10-10 07:29:30 -07:00
Siddharth Agarwal
359ca05ac8 cleanup deprecated tokio APIs in bookmarks crate
Summary:
Realized that this didn't have `#![deny(warnings)]`, so deprecated
tokio APIs hadn't been cleaned up.

Reviewed By: farnz

Differential Revision: D6015774

fbshipit-source-id: 10f8e8b28b7d6e81ef88ca2382e331cde822ac66
2017-10-10 07:29:30 -07:00
Zach Zagorski
8d043552f4 Remove deprecated tokio APIs from stockbookmarks
Summary: Change usage of BoxStream from futures crate to futures-ext crate and replace stream::iter() with stream::iter_ok().

Reviewed By: jsgf

Differential Revision: D5938460

fbshipit-source-id: bfb90844e646079d72b35495f409591a65686978
2017-10-06 09:35:37 -07:00
Siddharth Agarwal
de9df8c5e2 remove deprecated tokio APIs from filebookmarks
Summary:
I'm going to factor out some of this code into a new crate, and I want
to get these changes out of the way first.

Reviewed By: lukaspiatkowski

Differential Revision: D5924471

fbshipit-source-id: 7007638ce688e62397637ff6f9a2e51247ec9312
2017-09-28 22:10:04 -07:00
Dzmitry Dulko
63e92b7825 Remove usage of deprecated Tokio APIs
Summary: Switch to new futures API

Reviewed By: sid0

Differential Revision: D5888635

fbshipit-source-id: 22c06797ee62ce08132526369764607f3a73ceef
2017-09-23 10:50:20 -07:00
Jeremy Fitzhardinge
faa58a1052 mononoke: bookmarks: use ! for membookmarks errors
Summary: membookmarks can't fail, so use `!` for its `Error` type

Reviewed By: sid0

Differential Revision: D5849875

fbshipit-source-id: 5dbb4edf9bb57dde55877d2c90936b51dcc5d7ff
2017-09-19 16:11:54 -07:00
Siddharth Agarwal
81f2ac473b make bookmark error type implement std::error::Error
Summary: All its users need this, and it makes sense.

Reviewed By: jsgf

Differential Revision: D5847753

fbshipit-source-id: 042c7b5637e5f83918fa9bc5d131c8745d7bbc3e
2017-09-18 00:35:52 -07:00
Siddharth Agarwal
a74542da60 update and pull in uuid + subprocess
Summary:
Finally got an update working by removing the `mysql_async` crate.

Some notes:

* The `mysql_async` crate was responsible in this case: see https://github.com/rust-lang/cargo/issues/4066#issuecomment-328210204 for why.
* tokio/futures deprecated a bunch of stuff. I've filed a TODO for now.
* We finally pulled in error-chain 0.11, which has a bunch of nice improvements.

Reviewed By: kulshrax

Differential Revision: D5798282

fbshipit-source-id: a38a7b17ee0205428e2ea63334722aa408582493
2017-09-08 17:05:38 -07:00
Arun Kulshreshtha
8b6310dcef Switch from url to percent_encoding crate in FileBookmarks
Summary:
The url::percent_encoding module was split into its own crate. Use
that instead.

Reviewed By: jsgf

Differential Revision: D5769525

fbshipit-source-id: 4d95c5d791e486f56a16091ffa5114b3cfbfd47e
2017-09-07 10:50:55 -07:00
Jeremy Fitzhardinge
144bea971a mononoke: bookmarks: add helpers for boxing Bookmarks trait objects
Summary:
Add BoxedBookmark to assist in boxing a Bookmark trait, and implement Bookmark
for Box<_> and Arc<_> Bookmark trait objects.

Reviewed By: sid0

Differential Revision: D5540675

fbshipit-source-id: 7582adbd2858f6814d57b7e54089b922886a4d54
2017-08-02 17:43:24 -07:00
Jeremy Fitzhardinge
09b25e1507 mononoke: bookmarks: fold ListBookmarks into Bookmarks
Summary:
In practice, no users of Bookmarks will not want listing, and all
implementations need to be able to support it.

Reviewed By: StanislavGlebik

Differential Revision: D5540672

fbshipit-source-id: d64a3894c7cd14d329bd23809525935461289bc3
2017-08-02 17:43:24 -07:00
Jeremy Fitzhardinge
6cfc6704b6 mononoke: stockbookmarks: make Error a parameter
Summary: Allow the error type to be any type the internal errors can be converted to.

Reviewed By: sid0

Differential Revision: D5540671

fbshipit-source-id: 1077132d25bcc13ba2a3a509c916f2e07ac10dcf
2017-08-02 17:43:24 -07:00
facebook-github-bot
2b6af6b941 Initial commit
fbshipit-source-id: f75baa4ff6aa71973f677b752d7aba582cf4927f
2017-07-27 18:00:19 -07:00