Commit Graph

22 Commits

Author SHA1 Message Date
Jun Wu
2a99866d7b codemod: update license headers
Summary:
The "Portions" license cannot be updated automatically. So this is a manual
update using:

  sd -s 'Portions Copyright (c) Facebook, Inc. and its affiliates.' 'Portions Copyright (c) Meta Platforms, Inc. and affiliates.' `rg -l Facebook`
  sd -s 'Copyright (c) Facebook, Inc. and its affiliates.' 'Copyright (c) Meta Platforms, Inc. and affiliates.' `rg -l Facebook`

Differential Revision: D33420114

fbshipit-source-id: 49ae00a7b62e3b8cc6c5dd839b3c104a75e72a56
2022-01-05 14:43:32 -08:00
Jun Wu
90f5ca704e hgmain: disable chg if stdin is not a tty but stdout is
Summary:
If stdout is a tty, then interactive is enabled, pager can start with stdio.
However, if the stdin is not a tty, then the user loses key bindings control to
the pager.

I also spent some time trying to get the `/dev/tty` passed from client to the
forked worker. The fd can be passed, but the worker cannot set that fd to
`/dev/tty`. POSIX does not provide a way. Linux has `ioctl(fd, TIOCSCTTY)`,
but when the terminal is owned by a different session, it requires
`CAP_SYS_ADMIN` to "steal" the ctty.

Maybe streampager can provide a `Pager::from_tty_fd` API. But for now let's
just disable chg in this case.

See also the next diff.

Reviewed By: DurhamG

Differential Revision: D32598519

fbshipit-source-id: cb7cf78aaf32f12fabca7b15eceabdea721e23dc
2021-11-29 09:33:03 -08:00
David Tolnay
e6c5e4fcc6 Even more 2021 edition Cargo.tomls
Summary: Generated by `rg -g Cargo.toml 'edition = "2018"' -l | xargs sed 's/edition = "2018"/edition = "2021"/' -i`. I guess these are all the handwritten Cargo.tomls. I confirmed that `cargo autocargo` does not revert any of the changed files in this diff.

Reviewed By: aaronabramov

Differential Revision: D31832704

fbshipit-source-id: ac4ea947ae80d25911fa9eedf2951eeead9d5636
2021-10-21 19:39:32 -07:00
Zeyi (Rice) Fan
b76da76b9b tweak error message on Windows when repo is not mounted to avoid confusing people
Summary:
The old message was a little misleading as in some case EdenFS was running while it couldn't mount the repository. Mercurial will still tell the user that EdenFS is not running. It is not accurate.

The new message is trying to cover this case to avoid confusing people.

Reviewed By: zhengchaol

Differential Revision: D31278947

fbshipit-source-id: dd3e599654390269b6cf31d8842105970cb29cc0
2021-09-29 15:40:02 -07:00
Jun Wu
784bc61b3d hgmain: enable virtual termainal processing on Windows
Summary: This is needed for rendering multiple progress bars in `cmd.exe`.

Reviewed By: andll

Differential Revision: D27887601

fbshipit-source-id: 9aa987cef327de91408f2e38b4d2e551fe10e39b
2021-04-20 15:50:41 -07:00
Jun Wu
ae8a4340f7 clidispatch: add an API to obtain "writable" stdout stream
Summary:
Similar to D26518021 (3aba8d89b0), provide a way to obtain the "output" stream
that implements `std::io::Write`.

The "output" stream is then used to replace the `std::io::Write`
implementation on the `IO` itself.

This has 2 benefits:
- Removes the `&mut` methods on `IO`. So all `&mut IO` can be replaced by `&IO` without exceptions.
- Make it possible to drop `Clone` on `IO` (strong ref is not clonable, but weak ref can). So we can control the lifetime of the streams more predicatably.

Reviewed By: sfilipco

Differential Revision: D26538452

fbshipit-source-id: b00c65ae0ef5ef4a609104111706365028f47ef7
2021-02-23 15:09:14 -08:00
Jun Wu
bbe2489e04 hgmain: set the global IO reference
Summary:
Set the global IO reference to the IO created by hgmain. This allows
other crates like `pypager` to use the `IO` without cloning or passing
the reference across layers (Rust references do not actually work for
across the Python boundary).

Reviewed By: sfilipco

Differential Revision: D26518027

fbshipit-source-id: 6144b06035d0ef9384cc1a37245c306071e35a9d
2021-02-23 15:09:13 -08:00
Jun Wu
25230c0c2a clidispatch: make IO clonable
Summary:
Make it possible for IO to be cloned. This allows, for example, tracing or
progress bar logic to keep a reference of IO.

Reviewed By: sfilipco

Differential Revision: D26518028

fbshipit-source-id: d5ca7f4347251c68f7491f784f647ee80c47d159
2021-02-19 15:22:06 -08:00
Durham Goode
0830e9a481 Add --cfg=fb_buck_build to all builds
Summary:
In Mercurial we're finding use cases for conditioning on buck vs
non-buck builds. For instance, in some cases we specify #[link] directives for
non-buck builds, but don't need to for buck builds
(https://fb.workplace.com/groups/rust.language/permalink/4568487309866515/).  In
other cases we want to depend on internal buck libraries when building with
buck, and not otherwise.

Let's add a fb_buck_build cfg so other projects may distinguish the same.

Reviewed By: jsgf

Differential Revision: D24493974

fbshipit-source-id: 1d558cbe0ae01ab4a7b4b5d6d4be75bb8ab0f41a
2020-11-02 12:51:56 -08:00
Zeyi (Rice) Fan
c78cf6ca3b hgmain: check if EdenFS is running on Windows
Summary:
On Windows, some Mercurial commands may create files in `.hg` directory even if
EdenFS is not running. As a result, the command itself will fail while the file
still left in the directory. Users typically will then start EdenFS and repeat
the same command.

However, due to the current design of EdenFS, it will not be able to recognize
these files created when it is stopped and return errors for any attempts to
write/remove the file, generate another error. Users then need to stop EdenFS
and manually remove the file in `.hg` directory to recover the repository. This
creates a very bad user experience.

The correct way to fix this is to teach EdenFS to track the modifications
happened when it is not running, however this will take a few weeks to get
there. For a temporary measurement, we teach Mercurial to abort when EdenFS
isn't running to avoid trickier recoveries.

Reviewed By: quark-zju

Differential Revision: D24001090

fbshipit-source-id: abc1ebcdae3819756fe64b5321f52a6e62c0c360
2020-09-30 15:39:34 -07: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
Durham Goode
3ac2be361a configs: move fbrules to a Facebook only part of the crate
Summary:
We'll be adding a bunch of Facebook specific configuration and values
here. Let's move it to someplace not open source.

Reviewed By: quark-zju

Differential Revision: D21241038

fbshipit-source-id: 2ac9cdce40b1b46f15f171d9d1f6b6692dcd29bf
2020-05-01 13:17:21 -07:00
Andres Suarez
7ebf66c8b8 chg: avoid needless allocations
Summary:
* Unnecessary clone of `osstring_to_local_cstring` value.
* Unnecessary UTF-8 conversion in `file_decision`.
* Neater "debugpython" if.
* Unnecessary `CHGDISABLE` `OsString` allocation.

Reviewed By: quark-zju

Differential Revision: D21171329

fbshipit-source-id: 1241066b4a01600c436709d1a5fe95d6a13634ba
2020-04-22 09:34:27 -07:00
Jun Wu
52bb1ab77e clidispatch: add start_pager API for IO
Summary:
Implement the core API to start pager in native Rust. For now it is only
enabled for the entire command if `--pager=always` is set.

Reviewed By: DurhamG

Differential Revision: D20849644

fbshipit-source-id: 860b4e18d841da607864c3447d78dbac126f5f18
2020-04-07 15:57:06 -07:00
Jun Wu
6e7cffbda4 chg: disable chg when file paths like /proc/self/... are used
Summary: This will allow bash users to use things like `hg commit -l <(echo foo)`.

Reviewed By: krallin

Differential Revision: D20810653

fbshipit-source-id: 42e420e608d41704387a9011cf14a28f92192e5d
2020-04-02 10:09:50 -07:00
Durham Goode
0913d16fb1 py3: support python3 for the builtin interpretter
Summary:
The builtin interpreter currently only responds to "python" as the
input arg. Let's also support python3.

Reviewed By: farnz

Differential Revision: D19613372

fbshipit-source-id: 5d2eed85c2d9546808c1661f12681b03f1edc40f
2020-01-29 10:11:24 -08:00
Jun Wu
8703970cea py3: update Cargo.toml to make py3 buildable
Summary:
This makes `make hg3` work. It requires cleaning up the `build` directory when
switching between py2 and py3 build, which will be fixed later.

Reviewed By: DurhamG

Differential Revision: D19604824

fbshipit-source-id: 060ff313420126a5dba935c4451b45dc9af45f13
2020-01-28 13:39:38 -08:00
Xavier Deguillard
fe8855e9fb hgmain: initialize fbinit
Summary:
The memcache code assumes it's initialized, let's actually do it.

The test change is required due to fbinit installing its own SIGTERM handler
that shows a backtrace. Installing our own SIGTERM handler makes it closer to
what Mercurial does already.

Reviewed By: quark-zju

Differential Revision: D19518698

fbshipit-source-id: bc8c2311e65c9c00678756abae3979ccda4453ea
2020-01-23 08:57:22 -08:00
Jun Wu
1be7e2ea4c hgmain: explicitly flush IO on exit
Summary: Without this, `hg status --print0` can output nothing and break tests.

Reviewed By: xavierd

Differential Revision: D19387317

fbshipit-source-id: 4feb82889df9bd1705526027f491db90a2a5f946
2020-01-14 09:42:48 -08:00
Jun Wu
4dd04bf02f hgpython: replace hgpython interpreter with native Rust implementation
Summary:
The hgpython interpreter was used to run Python scripts in tests that might
rely on Mercurial modules.

The previous hgpython implementation is Python PAR based, which does not have
access to native Rust modules like bindings. Change it to use the native
"hg debugpython" implementation that is more compatible.

Reviewed By: markbt

Differential Revision: D19190496

fbshipit-source-id: 9791dbf9ba0ed92de702291faa9145f01b05ec40
2019-12-22 11:27:27 -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
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