Commit Graph

18 Commits

Author SHA1 Message Date
Siddharth Agarwal
e46ec63724 mercurial-types: allow converting strs to MPaths and RepoPaths
Summary:
This allows (actually forces) us to drop a bunch of `as_ref` calls. It also
makes upcoming diffs look cleaner.

Reviewed By: jsgf

Differential Revision: D6585202

fbshipit-source-id: a53902696cf12050a851c30b557aeefe09c41903
2017-12-18 22:08:37 -08:00
Simon Farnsworth
4d6f3fa51b Remove generics from Linknode
Summary:
Like the other  BlobState components, Linknode was too generic -
reduce down to a practical set for live implementations.

Error handling is not great here or in Bookmarks, but I'm going to await the
decision on moving to Failure before I improve it.

Reviewed By: jsgf

Differential Revision: D6459012

fbshipit-source-id: 00314309f62ba070b5908a28f5174a31b6dd0d84
2017-12-11 07:05:53 -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
Arun Kulshreshtha
40339c1f89 Upgrade to Rust 1.22.1
Summary:
This diff upgrades the version of rustc in fbcode to version 1.22.1,
including the requisite third-party2 symlink updates for  the `rust` and
`rust-crates-io` projects, config.py changes in the third-party2 and
third-party-buck directories, and code fixes for Rust targets in common/rust
and scm/mononoke.

Reviewed By: jsgf

Differential Revision: D6489808

fbshipit-source-id: 48377ea937916beb7dae7a3806de1fce1e29dd24
2017-12-05 18:57:32 -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
Siddharth Agarwal
a6c5093cc8 blobimport: write out linknodes
Summary:
This makes it quite easy to write out linknodes.

Also regenerate linknodes for our test fixtures -- the next commit will bring
them in.

Reviewed By: jsgf

Differential Revision: D6214033

fbshipit-source-id: 3b930fe9eda45a1b7bc6f0b3f81dd8af102061fc
2017-11-13 22:01:55 -08:00
Siddharth Agarwal
e91886ae05 memlinknodes: add test conveniences for adding linknode data
Summary: This will be used by generate_memblob_repo.py

Reviewed By: jsgf

Differential Revision: D6215395

fbshipit-source-id: d8dfb14514dad4396a1923b034500c1a67ac94dc
2017-11-02 13:10:56 -07:00
Siddharth Agarwal
ed298889af filelinknodes: also write out path and node info
Summary: Needed for the generate_memblob script.

Reviewed By: jsgf

Differential Revision: D6214835

fbshipit-source-id: 130f8946748490c31a38dc7530fec8f4027379f1
2017-11-02 13:10:56 -07: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
1d299009d3 use hyphen instead of colon for file-based linknodes
Summary: Colons are reserved on Windows

Reviewed By: farnz

Differential Revision: D6202655

fbshipit-source-id: 0918b43dd36aa3990064bf1c79893b20570ee82c
2017-11-01 16:27:30 -07:00
Siddharth Agarwal
e9036ade06 make the Linknodes trait Sync
Summary: All implementations are expected to be, and this simplifies downstream code.

Reviewed By: farnz

Differential Revision: D6192078

fbshipit-source-id: bf63bbe84db7919e3c6fa808da1c5c25c25d2ec8
2017-10-31 12:29:45 -07:00
Siddharth Agarwal
6afdfc7f00 linknodes: switch from MPath to RepoPath
Summary:
RepoPath also captures whether this is a file or a directory (tree), which is
important for linknodes.

Also pass a `RepoPath` in, not just a `&RepoPath` -- the path is pretty much
always going to be cloned, so might as well.

Reviewed By: StanislavGlebik

Differential Revision: D6098520

fbshipit-source-id: c1a8d5defa841960b53fa919e6d8d59fb33d5c28
2017-10-19 09:39:17 -07:00
Siddharth Agarwal
a7ea7884d6 linknodes: add definition for Arc<L> where L: Linknodes
Summary: Upcoming work will want to use this.

Reviewed By: StanislavGlebik

Differential Revision: D6097836

fbshipit-source-id: 23532e3d1182179ea2e454df0329ba10f50d565f
2017-10-19 09:39:17 -07:00
Siddharth Agarwal
55db1caebd linknodes: add a file-based linknodes implementation
Summary: This implementation uses the `filekv` library extracted in earlier series.

Reviewed By: jsgf

Differential Revision: D6072674

fbshipit-source-id: 01f443fb614fea7087f8a09a4d6b3eb371c34852
2017-10-17 00:36:29 -07:00
Siddharth Agarwal
d2067ebf52 linknodes: move common tests out into a test module
Summary: We'll reuse these tests for a file-based implementaion as well.

Reviewed By: farnz

Differential Revision: D6059222

fbshipit-source-id: ff63e21badda455bc83c34da2acd08395e906826
2017-10-17 00:36:28 -07:00
Siddharth Agarwal
8d9864c260 linknodes: make the old linknode optional
Summary:
Some implementations like file-based linknodes won't have this data.

The wrapper struct is required so that `Display` can be implemented.

Reviewed By: farnz

Differential Revision: D6059220

fbshipit-source-id: 705e0152abcff59cf0584741430b20e34a2cd652
2017-10-17 00:36:28 -07:00
Siddharth Agarwal
050622ba1f linknodes: initial interface + in-memory implementation
Summary: Add a basic interface and an in-memory implementation.

Reviewed By: jsgf

Differential Revision: D5898868

fbshipit-source-id: 458069cb79a27cb3b0d63ab1a82eeb9e43e74efe
2017-09-26 04:35:12 -07:00