Commit Graph

23 Commits

Author SHA1 Message Date
Mark Juggurnauth-Thomas
0fc1697815 rust: fix compiler warnings
Summary:
Warnings in Rust code can often indicate real problems, so it's important to
keep the build warning-free.  This fixes all warnings where the fix is obvious.

Reviewed By: liubov-dmitrieva

Differential Revision: D29933213

fbshipit-source-id: d1a418c1a70630a2aa1a5740fcbafc66ce8bdf91
2021-07-29 10:01:02 -07:00
Victoria Tsai
ad9e1b0d4b Fix rust lint errors
Summary: unused import and unused variable

Differential Revision: D29365367

fbshipit-source-id: 39d625eba232deeb8e70e8ba11c6043b4ea60122
2021-06-24 15:54:45 -07:00
Jun Wu
a7c3458c82 clidispatch: split dispatch() method
Summary:
Split `dispatch()` into 2 parts: config parsing and command execution.
This allows callsite to do extra work based on the config before running the
command.

Reviewed By: andll

Differential Revision: D26853749

fbshipit-source-id: 459918b43341f7e14df6958056b6e07453bb691b
2021-03-12 11:39:09 -08:00
Lukas Piatkowski
ad106958f2 eden/scm/lib: autogenerate all Cargo.toml files with autocargo
Summary: This diff removes the split between manually managed and autocargo managed Cargo.toml files in `eden/scm/lib`, now all files are autogenerated.

Reviewed By: quark-zju

Differential Revision: D26830884

fbshipit-source-id: 3a5d8409a61347c7650cc7d8192fa426c03733dc
2021-03-05 04:29:49 -08:00
Meyer Jacobs
2f0d2c4105 util: introduce a select_drop stream combinator
Summary: Introduce a new stream combinator, `select_drop`, based on `futures::stream::select`, which performs the same function except dropping the contained streams when they terminate, rather than when the combined stream is exhausted. This prevents a deadlock in cases where one stream will not terminate until the other terminates.

Reviewed By: DurhamG

Differential Revision: D26139816

fbshipit-source-id: d28da32244a215741476e1c3882154ea9e3116a5
2021-02-08 10:39:32 -08:00
David Tolnay
e62b176170 Prepare for rustfmt 2.0
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like https://github.com/rust-lang/rustfmt/issues/4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: zertosh

Differential Revision: D23568779

fbshipit-source-id: 477200f35b280a4f6471d8e574e37e5f57917baf
2020-09-07 20:47:59 -07:00
Mark Thomas
4d18561ab8 bgprogress: Stdio is only used on Unix
Summary: This fixes the Windows build.

Reviewed By: farnz

Differential Revision: D23212195

fbshipit-source-id: 159f3ddebf6a97f52f9b6c80ef19315c8f4b0c85
2020-08-21 13:00:45 -07:00
Durham Goode
26564596a1 utils: add background process utility
Summary:
Similar to the Python runbgcommand (extutil.py), this is a Rust utility that runs a
detached background process in a cross platform way.

This will be used in a later diff to run dynamicconfig generation in the
background.

Reviewed By: quark-zju

Differential Revision: D22712629

fbshipit-source-id: a317465bf03c96d977a203678e2bef13ce57cc12
2020-08-16 16:55:59 -07:00
Jun Wu
ddad0cf115 util: use concrete error types
Summary:
`util` as a low-level library should use concrete error types so callsite can
type check their type conversions.

Reviewed By: sfilipco

Differential Revision: D22855448

fbshipit-source-id: 37b3fce36f1ae82a9604ef8ac0dc22c02280ceb2
2020-08-06 12:31:56 -07:00
Jun Wu
e440d3ce2b revlogindex: update nodemap even if it's non-symlink and mmaped on Windows
Summary: On Windows a mmap file cannot be replaced. Detect that and delete manually.

Reviewed By: farnz

Differential Revision: D22428731

fbshipit-source-id: 4d308a07aae02dcaf2aedb7b0267a535c2e09c92
2020-07-08 11:31:21 -07:00
Jun Wu
5c66d921c6 util: implement a symlink-based atomic_write
Summary:
This diff aims to solve `atomic_write` issues on Windows. Namely:
- `tempfile` left overs if temp files are not deleted on Drop.
- `tempfile` does unnecessary `chmod`.
- For mmap-ed files, it has to be deleted before `atomic_write`, causing
  reader to have a chance to see inconsistent data.

This diff solves the above issues by:
- Use extra GC to clean up older files. Do not realy on successful `Drop`.
- Do not use `tempfile` and do not set permissions.
- Use a symlink so the symlink can still be atomic-replaced while the real
  content is being mmaped.

Reviewed By: DurhamG

Differential Revision: D22225039

fbshipit-source-id: d45bb198a53f8beeef71798cdb9ae57f9b4b8cd3
2020-06-25 13:56:12 -07:00
Jun Wu
570dbef1db util: add PathLock
Summary: RAII lock on a filesystem path.

Reviewed By: DurhamG

Differential Revision: D22226017

fbshipit-source-id: 4e26358bf0b6d4b2440fb77058032dbde8b6d02c
2020-06-25 13:56:12 -07:00
Jun Wu
bc09039a7d util: make remove_file work with mmap on Windows
Summary:
Make it possible to delete files that are mmap-ed. This avoids the extra
complexity of cleaning leftover files.

Reviewed By: xavierd

Differential Revision: D22168135

fbshipit-source-id: edb33a75638c668945feae49608c3fff25e742a4
2020-06-23 22:53:36 -07:00
Zeyi (Rice) Fan
39583bb2e3 be graceful when trying to fix dir permission
Summary:
In some rare cases, we would have hgcache that contains broader permission than we are expecting. We shouldn't be fixing it if that's the case.

We also might be in situations where hgcache directory isn't entirely created by Mercurial, and the owner of the directory will be different than the process. This will cause the `chmod` call to fail with permission error. In that case, this will cause EdenFS to panic. This is undesirable. We should be handling this case more gracefully and let the original error populate.

Reviewed By: xavierd

Differential Revision: D21854542

fbshipit-source-id: e9d11399aeb40b375725b49f4bcd54050afdcbad
2020-06-03 10:25:03 -07:00
Xavier Deguillard
9d18e2eae6 revisionstore: fix permissions on shared directories
Summary:
Now that the shared directories are created with the right permissions, we
could still have some in the wild with the incorrect permissions. Let's make
sure that we fix these up.

Reviewed By: wez

Differential Revision: D21832436

fbshipit-source-id: d8ee40f61b16857d29e1360ec6df50b2a95ea7aa
2020-06-02 08:46:57 -07:00
Xavier Deguillard
1c0668e512 revisionstore: set sgid bit when creating directories
Summary:
This is required for the shared cache to avoid permissions issues when multiple
users are trying to use it.

Reviewed By: fanzeyi

Differential Revision: D21830490

fbshipit-source-id: 3db0dbd674b6d2e10b9361ff3c3a668d046f5d78
2020-06-02 08:46:56 -07:00
Zeyi (Rice) Fan
8830ed55df util: not try to create the directory when it already exists
Summary: Fix permission issues we are seeing with the latest Mercurial release.

Reviewed By: xavierd

Differential Revision: D21294499

fbshipit-source-id: bcfb13dd005258b2e3b74fa281dbd8df36133ef6
2020-04-28 20:33:59 -07:00
Zeyi (Rice) Fan
3374b99f28 util: ensure correct permission is set when creating directories
Summary:
When creates directories sometime we want to make sure other users within the same group have the write access to it to enable data sharing. Previously we rely on setting umask for the entire process to make sure the newly created directories have the correct permission bit. This is kind fragile and error-prone when running in a multi-thread environment.

This diff introduces an internal function `create_dir_with_mode` to create directory with specified permission mode. It first creates a temporary directory within the parent of the directory being created, setting up the correct permission bit, then attempts to rename the temporary directory to the desired name. This ensures that we never leave a directory without the correct permission in the place we need and without changing umask for the process.

Reviewed By: xavierd

Differential Revision: D21188903

fbshipit-source-id: 381bff7d3aaca097b9d50150e86cbbf70a90a0a5
2020-04-24 17:17:05 -07:00
Xavier Deguillard
42f1213efa util: address clippy warnings
Summary: The lifetime is unecessary.

Reviewed By: DurhamG

Differential Revision: D20452750

fbshipit-source-id: 184f5e109a0ff59931bdddaf611a7581d2255e78
2020-03-18 09:35:36 -07:00
Xavier Deguillard
283b120bb6 pyconfigparser: use PyPath instead of PyByte
Summary:
Also, add a util::path::strip_unc function that is more clear than the
normalize_for_display

Reviewed By: DurhamG

Differential Revision: D19595961

fbshipit-source-id: 330bcb708bf64320a3562d79db685d6cb1e14f16
2020-01-28 10:14:14 -08:00
David Tolnay
d1d8fb939a Switch from failure::Fail trait to std::error::Error for errors
Summary:
This diff replaces eden's dependencies on failure::Error with anyhow::Error.

Failure's error type requires all errors to have an implementation of failure's own failure::Fail trait in order for cause chains and backtraces to work. The necessary methods for this functionality have made their way into the standard library error trait, so modern error libraries build directly on std::error::Error rather than something like failure::Fail. Once we are no longer tied to failure 0.1's Fail trait, different parts of the codebase will be free to use any std::error::Error-based libraries they like while still working nicely together.

Reviewed By: xavierd

Differential Revision: D18576093

fbshipit-source-id: e2d862b659450f2969520d9b74877913fabb2e5d
2019-11-22 08:53:31 -08:00
David Tolnay
b1793a4416 rust: Rename Fallible<T> to Result<T>
Summary:
This diff is preparation for migrating off of failure::Fail / failure::Error for errors in favor of errors that implement std::error::Error. The Fallible terminology is unique to failure and in non-failure code we should be using Result<T>. To minimize the size of the eventual diff that removes failure, this codemod replaces all use of Fallible with Result by:

- In modules that do not use Result<T, E>, we import `failure::Fallible as Result`;
- In modules that use a mix of Result<T, E> and Fallible<T> (only 5) we define `type Result<T, E = failure::Error> = std::result::Result<T, E>` to allow both Result<T> and Result<T, E> to work simultaneously.

Reviewed By: Imxset21

Differential Revision: D18499758

fbshipit-source-id: 9f5a54c47f81fdeedbc6003cef42a1194eee55bf
2019-11-14 14:11:01 -08:00
Adam Simpkins
ab3a7cb21f Move fb-mercurial sources into an eden/scm subdirectory.
Summary:
In preparation for merging fb-mercurial sources to the Eden repository,
move everything from the top-level directory into an `eden/scm`
subdirectory.
2019-11-13 16:04:48 -08:00