Commit Graph

3 Commits

Author SHA1 Message Date
Jun Wu
d0cf5aacfa dispatch: remove Python alias handling
Summary:
This removes Python alias handling so the alias handling is done entirely in
Rust.

There are some subtle changes - alias using prefix mathcing to ambiguous
commands will not show other aliases. Hopefully that won't be a big issue.
Users can always avoid prefix matching in alias to solve the issue.

Reviewed By: sfilipco

Differential Revision: D16733270

fbshipit-source-id: 54a4915d49c2b2f6e8664a225a9c0f25e1c38d17
2019-08-19 19:27:29 -07:00
Jun Wu
38a0a8ff95 dispatch: translate shell aliases to hg commands
Summary:
Translate alias like `echo = !echo foo` to `echo = debugrunshell '--cmd=echo
foo'`.  This enables the Rust shell alias handling code path. The Python
shell alias handling was removed.

The majority part of `test-alias.t` still passes. That includes some "weird"
shell alias features.

This has some test changes, through:

- `$HG_ARGS` is no longer supported. And tests depending on it are changed.
  `$@` will be the alternative for most cases.
  Practically, our `$HG_ARGS` users seem to come from
  https://stackoverflow.com/a/833387, which does not seem to use `$HG_ARGS`
  correctly (since `$HG_ARGS` includes the command name).
- Early-parse commands (ex. `hg log -b '--config=alias.log=!echo
  howdy'`) no longer works.
- The warning `--repository ignored` now shows up, since `debugrunshell`
  is a "no-repo" command.
- Global flags can no longer be used after shell aliases. Supporting them
  is a head-ache.
- `circular alias` error message changed because it's now reported by the Rust
  code, which does not report all alias names right now.

Reviewed By: sfilipco

Differential Revision: D16733266

fbshipit-source-id: b06bc7f8fc2f1c2701a17407d6a1656e17e4ba55
2019-08-19 19:27:28 -07:00
Jun Wu
25eb53f3e7 alias: make resolution unaffected by definition order
Summary:
Previously, the alias resolution is affected by the alias definition order. So
things like:

  [alias]
  myglog = log -G
  myvlog = myglog -v

works. But

  [alias]
  myvlog = myglog -v
  myglog = log -G

doesn't. D8767902 changed ordering semantics and broke some people's aliases,
because if both `myvlog` and `myglog` are defined in system hgrc, their order
cannot be changed from a user hgrc.

Instead of having subtle behavior here depending on the order. Let's just do
not rely on the order. This diff makes it so, by resolving aliases using latest
(alias-if-possible) definitions, with only one special case: "foo = foo ..."
uses the original non-alias "foo" command.

The "alias ... shadows command ..." debug message was removed as it's
no longer accurate.

Reviewed By: simpkins

Differential Revision: D9417710

fbshipit-source-id: f4228eba3c8c728163a54bcf053c379fa86bd123
2018-08-21 12:06:18 -07:00