Commit Graph

40 Commits

Author SHA1 Message Date
Jun Wu
37bf3cd1eb dispatch: remove 2 calls to fancyopts
Summary: clidispatch replaces them.

Reviewed By: sfilipco

Differential Revision: D16733263

fbshipit-source-id: 32e6cef0ec289a47969b75c332a3117591862ce0
2019-08-15 10:08:36 -07:00
Jun Wu
ea0bdc4d23 ui: disable pager with --debugger
Summary:
`--debugger` starts an interactive REPL. It's incompatible with pager.
Therefore disable pager automatically.

Reviewed By: singhsrb

Differential Revision: D16786806

fbshipit-source-id: a4a219461385f472943e60ba3c2a3b3fefd09e46
2019-08-13 19:12:17 -07:00
Aleksei Kulikov
cbf11e8ca8 snapshot: add command debugcreatesnapshotmanifest
Summary:
Add a self-descriptive command `debugcreatesnapshotmanifest`.
For now it supports only deleted and unknown files.

1) Uploads all the untracked files to the local lfs storage.
2) Creates a json-like snapshot with the following structure:
```
{
  "deleted": {
    "path/to/file": None, # this is done for consistency
    "path/to/another/file": None
  },
  "unknown": {
    "added": {
        "oid": "oid in local blobstore",
        "size": 42
    }
    "another/added": {
        "oid": "another oid in local blobstore",
        "size": 24
    }
  }
}
```
...and stores it in the local blobstore.

Reviewed By: markbt

Differential Revision: D16621864

fbshipit-source-id: 6c497d1bb756561b3c3368483b838a2307b0b5f9
2019-08-05 11:10:17 -07:00
Jun Wu
cad6e0410b cliparser: rename IllformedAlias to MalformedAlias
Summary: Suggested by kulshrax, `I` and `l` are harder to distinugish. Rename it to clarify.

Reviewed By: kulshrax

Differential Revision: D16556868

fbshipit-source-id: 5892f0730f5205534851c5f7c024ff98f751423d
2019-07-29 19:35:32 -07:00
Jun Wu
d878cea953 dispatch: expand aliases correctly
Summary:
Use the "first argument position" reported by the parsing library to expand the
command name correctly.

Before this patch:

    --repo foo foo
           ^^^ this foo gets expanded (incorrectly)

After this patch:

    --repo foo foo
               ^^^ this foo gets expanded

Reviewed By: kulshrax

Differential Revision: D16556869

fbshipit-source-id: 8eca98d80cdd8f0d3d329040d6f2eb81653db99f
2019-07-29 19:35:31 -07:00
Jun Wu
a9574245ca cliparser: pass all arguments to expand_aliases
Summary:
This gives `expand_aliases` a chance to handle things like `$1`, `$2`, etc.

Related Python code assuming `expand_aliases` does not change args was removed.

Reviewed By: kulshrax

Differential Revision: D16530712

fbshipit-source-id: b81c2d29b9b9b5b93ce01627268a999a2cfd1ef0
2019-07-29 19:35:30 -07:00
Jun Wu
5a36368ef8 cliparser: merge [defaults] and [alias] handling
Summary:
With the previous change, handling `[defaults]` and `[alias]` can be done
together.

Logic handling `[defaults]` separately is removed.

Unfortunately the new logic is duplicated in clidispatch and
bindings/clidispatch. In the future, bindings/clidispatch might just call
clidispatch.

Reviewed By: kulshrax

Differential Revision: D16530608

fbshipit-source-id: 5040d02da98d04a3f5cb43cc7f9cf0ef39a0f8ed
2019-07-29 19:35:30 -07:00
Jun Wu
c4aee9c2c6 cliparser: make expand_aliases take multiple args
Summary: This is the first step to support expanding things like `$1` in aliases.

Reviewed By: kulshrax

Differential Revision: D16530515

fbshipit-source-id: 3e81c92c2e2021b99815974f53286ec789ba0733
2019-07-29 19:35:29 -07:00
Jun Wu
5dd0629478 cliparser: add an error type about illegal alias
Summary:
When the alias cannot be split via shlex::split, raise an error directly
instead of silently ignoring it and fallback to Python error handling.

Reviewed By: kulshrax

Differential Revision: D16530519

fbshipit-source-id: d81534b198555b256f062dc4e6520fa40ace7700
2019-07-29 19:35:28 -07:00
Jared Bosco
01465ad1d5 hgmain: replace hg root entirely with a native implementation
Summary: Replace original Python `hg root` implementation with Rust `hg root` implemented with the new command line dispatch library.

Reviewed By: quark-zju

Differential Revision: D16497604

fbshipit-source-id: e3d0e60d4bd4203897260c16e070ca3768ff1d22
2019-07-26 20:38:50 -07:00
Jared Bosco
d2b564dcac dispatch: add friendly prefix matching on ambiguous commands
Summary:
Add support for color prefix highlighting when Mercurial encounters an ambiguous command name.  Currently ambiguous commands will print a list of possibilities such as:

```$ hg i
hg: command 'i' is ambiguous:
    id or identify
    import
    in or incoming
    init
    isbackedup
```

Now the prefix, in this case `i` will be highlighted in all possibilities.  This works no matter how long `prefix` is so in the case of `$ hg debug` it will highlight `debug` in all the possible choices.

Reviewed By: quark-zju

Differential Revision: D16451342

fbshipit-source-id: 87f58dd6bd77c2a609e5f423f7c769d444abc66d
2019-07-25 16:17:23 -07:00
Jared Bosco
089e77642a dispatch: replace final fancyopts call with native rust
Summary: Remove final fancyopts call to have all python parsing being done through native rust codepath, as well as clean-up some deprecated flags that would be special handling.

Reviewed By: quark-zju

Differential Revision: D16156284

fbshipit-source-id: ec5ccaeb982c78426e12ff1d7342b4ea6653e98e
2019-07-20 01:06:35 -07:00
Jared Bosco
93949f4629 dispatch: replace alias expansion and fancyopts parsing call with native rust
Summary:
Replace the second to last fancyopts call with pure rust code parsing and error handling.

Make slightly nicer help messages for ambiguous commands instead of just saying every possible command possible.

Reviewed By: quark-zju

Differential Revision: D16063049

fbshipit-source-id: bfd9e58649b1de2d3485069ce8d5646927bc77f4
2019-07-20 01:06:34 -07:00
Jared Bosco
5f02e5cd5c dispatch: replace _parse's call to fancyopts with native code
Summary: Replacing another fancyopts call to be parsed by native Rust code.  This diff introduces slightly hacky feeling behavior in order to handle cycles and resolving aliases, but will be fixed in a follow-up diff where Rust will fully expand the aliases completely removing the need for this confusing alias resolving, chaining, and execution.

Reviewed By: quark-zju

Differential Revision: D15902758

fbshipit-source-id: 11d9a479989a23de09bf96f8020d2fded6c06351
2019-07-20 01:06:33 -07:00
Jared Bosco
40ca990aac dispatch: replace a fancyopts call with native code
Summary: Replace the next usage of fancyopts in dispatch.py with native rust code, and ensure all tests pass with this replacement.

Reviewed By: quark-zju

Differential Revision: D15857997

fbshipit-source-id: ec8722bfe661731a14cb324e97846f861bd60bc8
2019-07-20 01:06:33 -07:00
Jared Bosco
ee1fcc3d2d bindings: create cliparser native binding to replace fancyopts early parsing
Summary:
The current Python parsing library fancyopts does an early parse for global flags, as well as slightly different logic for parsing out flags.

Switching this fancyopts call should allow fancyopts to be completely replaced by the native code path, and start using Rust parsing for hg.

This enforces command line arguments to be utf8. At Facebook, our `hg` wrapper already crashes if that is not the case. So it shouldn't cause new issues.

Reviewed By: quark-zju

Differential Revision: D15837079

fbshipit-source-id: 95634ebc814f8865960181f23282e5283068057c
2019-07-20 01:06:32 -07:00
Jared Bosco
95b0be5bdc dispatch: remove strictflags and related tests
Reviewed By: quark-zju

Differential Revision: D15833690

fbshipit-source-id: 3469d8def660b116c0f82c674a19f06b18f29211
2019-07-20 01:06:32 -07:00
Jun Wu
0720c26f71 dispatch: do not override 'msg' in case of interruption
Summary:
The `msg` variable was unintentionally changed in the "killed" case. Use a
different variable name to solve it.

This diff changes:

  [legacy][command_finish] killed!
   exited -1 after 1.60 seconds

to:

  [legacy][command_finish] <command> exited -1 after 1.60 seconds

Reviewed By: singhsrb

Differential Revision: D16360967

fbshipit-source-id: fb52025cd743a49c18116275c2eeac7b5c436e3b
2019-07-18 15:11:57 -07:00
Jun Wu
8640eccbeb blackbox: initial integrate with mercurial Python code
Summary:
Add a `mercurial.blackbox` module which just delegates to the Rust
binding. This means blackbox is no longer optional.

Change `ui.log` to log to the native blackbox as `LegacyLog` event.
The plan is to slowly migrate users from `ui.log` to `blackbox.log`,
which supports well-defined event types (instead of `LegacyLog`).

This does not change the `blackbox` command, which still uses the
legacy blackbox implementation. That will be changed in a later diff.

Reviewed By: markbt

Differential Revision: D15640720

fbshipit-source-id: de171f46e1430060083c9b7aee0a96dde315d021
2019-06-26 11:03:27 -07:00
Mark Thomas
94257a258b blackbox: clean up blackbox logging and log more during rage
Summary:
Clean up some of the calls to `ui.log` and how they appear in blackbox logging.

* Make the names of the events consistently use `snake_case`.
* For watchman, only log once for each watchman command.  Include whether or not it failed.
* Unify `fsmonitor` logging under the `fsmonitor` event.
* Omit the second argument when it is empty - it is optional and does nothing when empty.
* Increase the number of blackbox lines included in rage to 100.

Reviewed By: quark-zju

Differential Revision: D14949868

fbshipit-source-id: a9aa8251e71ae7ca556c08116f8f7c61ff472218
2019-04-23 02:48:50 -07:00
Chad Austin
179e2d2db4 fix crash in sampling
Summary: `log` itself does the interpolation, so don't do it in advance.

Reviewed By: quark-zju

Differential Revision: D14941862

fbshipit-source-id: 6885202cfbff4ce0310d68bb1676369c3ef64c53
2019-04-15 17:27:53 -07:00
Max Kareta
27abd9e79d dispatch: fixed arguments escaping before invoking hooks
Summary:
This diff adds args escaping using single quote symbol before sending them to hooks.
Before all arguments where joined by space symbol " " which was producing incorrect result when argument itself contains space symbol.

Reviewed By: markbt

Differential Revision: D14799188

fbshipit-source-id: df5a4324d138515a4b881df96f2991de03df7a5b
2019-04-15 06:56:50 -07:00
Durham Goode
c32fd83458 tracing: log manifold perftrace samples
Summary:
We currently send perf traces to the blackbox, but we also want to log
them to our metrics. This configures hg to log the perf trace as a sample. Later
diffs will configure our wrapper to route these samples to manifold.

Reviewed By: mitrandir77

Differential Revision: D14881308

fbshipit-source-id: 07690f9af9fe14279a9ebf5089548c5880cba45d
2019-04-11 10:06:37 -07:00
Jun Wu
31c8ecbdf4 dispatch: print shorter crash header
Summary:
Change the crash header to just a single line without blaming extensions or
Python. This makes the crash log shorter, and easier to read when there are
crashes in run-tests.py diffs.

Remove `ui.supportcontact` since it's no longer used.

Reviewed By: sfilipco

Differential Revision: D14393982

fbshipit-source-id: 3ede8d3d3d8fd5d125944a9a750350d3ce356b14
2019-04-04 23:38:34 -07:00
Mark Thomas
9cf99b9293 sampling: log working directory parents before and after commands
Reviewed By: quark-zju

Differential Revision: D14648522

fbshipit-source-id: 7c67ae3fa0542dd38fd87c5e2a2b421f73e4e12d
2019-04-04 11:29:49 -07:00
Xavier Deguillard
9d7bf6b735 dispatch: SIGPIPE do not exist on Windows
Summary:
On Windows, SIGPIPE isn't present in the signal module. This caused the exit
code to raise an exception when trying to install a handler for it.

Reviewed By: DurhamG, strager

Differential Revision: D14655142

fbshipit-source-id: 68ddfc5250a4b706c5bc6a7ad1add37e1ccbe26e
2019-03-27 19:13:55 -07:00
Jun Wu
077313f1af dispatch: move deferred to atexit handler
Summary:
See D14606986 for context. `repo.close` should be protected by not crashing on
stdout or stderr write errors (SIGPIPE or EPIPE). Move `deferred` to `atexit`
handler to get the protection.

Test changes are caused by ordering changes.

Differential Revision: D14607407

fbshipit-source-id: 5a42aefcec395f48b8ecb67426429ef2e41f5666
2019-03-25 18:33:05 -07:00
Jun Wu
7873db8242 ui: silent stdio write errors during atexit
Summary:
This is the first diff of an alternative fix of D14528603. See also D14603974
for context.

We'd like atexit handlers to not crash with EPIPE or SIGPIPE when writing to
stderr or stdout. Therefore disable SIGPIPE signal handler and patch ui methods
to do so.

Differential Revision: D14607159

fbshipit-source-id: 274c5174813d402a7e0b8b5be7c8fcb0524fcdb3
2019-03-25 18:33:05 -07:00
Durham Goode
ce423933c3 tracing: log perftraces to the blackbox
Summary:
Now that we're recording perftraces, let's log their results to the
blackbox if the command exceeds a configurable threshold.

Reviewed By: sfilipco

Differential Revision: D14426366

fbshipit-source-id: 24f261aaa2b089dbc959d709e51de1c0359d976d
2019-03-25 17:12:42 -07:00
Durham Goode
f2b414c324 tracing: add tracing for command dispatch
Summary:
Adds tracing for the command dispatch.  All other traces will be a
child of this root level trace.

Reviewed By: sfilipco

Differential Revision: D14426369

fbshipit-source-id: 2b996e027a2d6b163162bdceba571a3ee2186f6b
2019-03-25 17:12:42 -07:00
Jun Wu
ea16e76336 metrics: make ui.metrics.gauge log to the sampling extension
Summary:
Make it possible to use `ui.metrics.gauge` to collect metrics for a single
command, via the sampling extension.

Differential Revision: D14515775

fbshipit-source-id: e8a53549b00c1bc7b6509a5990a51d955d767d7e
2019-03-20 22:49:18 -07:00
Jun Wu
9e0a7c41a4 subrepo: remove subrepo support
Summary:
Subrepo is another unloved features that we don't want to support.

Aggressively remove it everywhere, instead of just turning off configs.

I didn't spend much time to split this commit so it's smaller and more friendly
to review. But it seems tests are passing.

Reviewed By: sfilipco

Differential Revision: D14220099

fbshipit-source-id: adc512a047d99cd4bafd0362e3e9b24e71defe13
2019-03-11 10:43:55 -07:00
Mark Thomas
38595d6fe3 dispatch: detect stale virtual checkouts and provide advice
Summary:
If Mercurial detects `ENOTCONN` when trying to open the current directory,
there is a high likelihood this is a disconnected eden virtual checkout.
Provide some advice as to what to do: run `hg fs start`.

Reviewed By: strager

Differential Revision: D13888873

fbshipit-source-id: 7619df0681d15b862d1a6f86d90491aa873bf86b
2019-03-08 06:02:22 -08:00
Mark Thomas
9a19e06fee strip: move extension to core and rename to debugstrip
Summary:
Move the strip extension to core.  Rename the command to `hg debugstrip` as it
is not intended for use by users.  Users should use `hg hide` instead.

Reviewed By: quark-zju

Differential Revision: D14185822

fbshipit-source-id: ef096488cb94b72a7bb79f5bf153c064e0555b34
2019-02-25 03:55:08 -08:00
Jun Wu
2dc2a3d2a2 dispatch: do not show help on CommandError
Summary:
CommandError happens if there is an unknown command flag, or a required
argument is missing. The old behavior is to print an error message to
stderr, then start the pager with the command help printed to stdout.

There are 2 problems with that approach:
1. When using mosh, a long help text might flush the actual error to out of the
   screen. The error message will be missed.
2. When captured in shell scripts, the help text printed to stdout would be
   captured, which is almost always undesirable.

The actual motivation of this change is for 2. Zsh themes like bullet-train [1]
uses `hg id -b 2>/dev/null` and we'd like to remove `id -b` support. After that,
the command should not polluate stdout with help text.

[1]: bd88ade263/bullet-train.zsh-theme (L102)

Differential Revision: D14151200

fbshipit-source-id: edd38e91115f96929438379aa2e40edfba560b41
2019-02-20 18:44:35 -08:00
Jun Wu
fbccd19ed7 patchbomb: remove the extension
Summary:
`test-patchbomb.t` uses named branches and does not look simple to fix.
We don't use email patches internally, and it's not hard to write scripts
around `hg export`. Therefore drop the extension and its tests.

Reviewed By: singhsrb

Differential Revision: D13978577

fbshipit-source-id: 19867ae68c19c996bfce064eb2234705939db9ea
2019-02-12 21:45:10 -08:00
Jun Wu
b74ee0564d chg: make it incompatible with upstream chg server
Summary:
It would be massy if there are 2 chg servers running: one for fb hg, one for
upstream hg, and they share a same socket path.

Change socket path and the commandserver name so fb-hg chg can only talk to
fb-hg chg servers.

Reviewed By: markbt

Differential Revision: D13869319

fbshipit-source-id: f9d42af9bdfc542207f23c536b478fd5ef8d02a0
2019-02-08 16:12:53 -08:00
Jun Wu
c2ef481658 logexchange: delete the experimental component
Summary:
logexchange was a subset of remotenames, added by:

  changeset:   5a62910948d2d4bac5defe305d0ddb22f0fda549  D1547
  user:        Pulkit Goyal <7895pulkit@gmail.com>
  date:        Wed, 04 Oct 2017 10:32:02 -0800
  summary:     remotenames: move function to pull remotenames from the remoterepo to core

Since we use the full remotenames instead, remove logexchange and its test,
which depends on named branch.

Differential Revision: D13954458

fbshipit-source-id: d565c131100ef90f3cf69e9051643ac8e5846f0d
2019-02-07 18:17:18 -08:00
Adam Simpkins
043e2016ac fix some additional edenscm name changes
Summary:
Follow up to D13853115 to fix test failures:
- Update an `__import__` statement in dispatch.py to use the new
  `edenscm.mercurial` package path.
- Make sure the `__version__.py` file is generated at the correct location by
  the buck build files.

Reviewed By: quark-zju

Differential Revision: D13858016

fbshipit-source-id: 54ac4a02274cf921397932e9625f422c5f427623
2019-01-29 12:26:10 -08:00
Jun Wu
c12e300bb8 codemod: move Python packages to edenscm
Summary:
Move top-level Python packages `mercurial`, `hgext` and `hgdemandimport` to
a new top-level package `edenscm`. This allows the Python packages provided by
the upstream Mercurial to be installed side-by-side.

To maintain compatibility, `edenscm/` gets added to `sys.path` in
`mercurial/__init__.py`.

Reviewed By: phillco, ikostia

Differential Revision: D13853115

fbshipit-source-id: b296b0673dc54c61ef6a591ebc687057ff53b22e
2019-01-28 18:35:41 -08:00