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
Summary: `visited` does not need to be a HashMap to detect circular aliases.
Reviewed By: kulshrax
Differential Revision: D16530517
fbshipit-source-id: a27ee97ab8a80e6232600dbc062b0cac701c92a8
Summary: The code was added by D16497604. It does not seem necessary. Therefore remove it.
Reviewed By: kulshrax
Differential Revision: D16553455
fbshipit-source-id: 2d8a9bc54c975d10a9357360feac86b6ec78f794
Summary:
The code tests if `arg` (aka. command name) starts with `-`. That does not need
special handling because normally a command name does not start with `-`.
Reviewed By: kulshrax
Differential Revision: D16530518
fbshipit-source-id: 0bd2cdc04a27013ad856e86ee9e0e2705bf5bd57
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
Summary:
Implement `hg root` in Rust with the `clidispatch` library as well as adding all current Python commands so that prefix matching still works as expected.
This diff does not remove `hg root` from Python or expose native command documentation to Python, which will be the next diff.
Reviewed By: quark-zju
Differential Revision: D16454053
fbshipit-source-id: 78a9c70aeefb9adbb85c77001b15eab652417b2c
Summary:
When we had a "--no-something" flag registered providing "--something"
did the same thing as providing "--no-something" which is highly undesirable
(see task)
Reviewed By: quark-zju
Differential Revision: D16520376
fbshipit-source-id: 9d407b830067d095abdbd9c0cee674f424ffc0f9
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
Summary: Add errors and map them to python exceptions to emulate the original python error handling behavior.
Reviewed By: quark-zju
Differential Revision: D16136571
fbshipit-source-id: eb999162cad040566e30b460f2b873efb05fc67a
Summary: To support 'static and dynamic lifetimes the FlagDefinition will have a Cow<'a, str> allowing the API to remain the same and still be used with strings passed from python.
Reviewed By: quark-zju
Differential Revision: D16136148
fbshipit-source-id: 670925549919a0965287b264704150f6ab638a18
Summary:
Alias expansion originally occurs in mercurial through a chain of command handlers that point at their alias.
Now, aliases can be fully expanded early on into parsing to only resolve actual commands and not have to follow a chain of executions.
Reviewed By: quark-zju
Differential Revision: D16059122
fbshipit-source-id: cf28fba4a131ab29ceda87bc3e90d7a434e06625
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
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
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
Summary: The global flags currently in Python should be ported to Rust definitions
Reviewed By: quark-zju
Differential Revision: D15782273
fbshipit-source-id: 1cfdb3bbab946d18dc3c899163286e30fa69c2c7
Summary:
Flags should be able to be matched partially by a prefix-match.
If a given prefix returns more than one possible Flag, it is therefore ambiguous and should not choose for the user.
An exact match should always take precedence. A partial match should be tried in the event the argument is not an exact match.
Reviewed By: quark-zju
Differential Revision: D15749936
fbshipit-source-id: 26e699616a1b3fa6871fb50cc6914f916701004c
Summary:
This diff sets two Rust lints to warn in fbcode:
```
[rust]
warn_lints = bare_trait_objects, ellipsis_inclusive_range_patterns
```
and fixes occurrences of those warnings within common/rust, hg, and mononoke.
Both of these lints are set to warn by default starting with rustc 1.37. Enabling them early avoids writing even more new code that needs to be fixed when we pull in 1.37 in six weeks.
Upstream tracking issue: https://github.com/rust-lang/rust/issues/54910
Reviewed By: Imxset21
Differential Revision: D16200291
fbshipit-source-id: aca11a7a944e9fa95f94e226b52f6f053b97ec74
Summary: Parser::parse_args would skip the first argument assuming it was the program name, as well as trimming arguments. This makes it have both inflexible and incorrect behavior, such as a client wanting to parse only some of the arguments, or an end-user wanting spaces to be maintained correctly.
Reviewed By: quark-zju
Differential Revision: D15698765
fbshipit-source-id: 119b7afb25e46332649ab121bef3504e79fa3ee9
Summary:
In order to be more in line with the current Python CLI parser, Parser::Multiplicity and Parser::ValueType is merged into a singular Parser::Value that supports default values, no value, as well as accepting values from the user in a type-safe way.
API / design is still unstable so documentation wasn't added just changed to allow doc tests to pass with the new type.
Reviewed By: quark-zju
Differential Revision: D15583997
fbshipit-source-id: 0c7d9dd4afa3579ca41008c4c427b90f2098100a
Summary: Ported the global constant flags from Python code in scm/hg/edenscm/mercurial/commands/__init__.py to the new Rust definitions
Reviewed By: quark-zju
Differential Revision: D15487764
fbshipit-source-id: fd4a0ec77779055b96741888f80e92d41dd430d5
Summary: Parser is able to take command line arguments and parse them into found flag definitions and their related values ( if specified ). This is the 'first' pass at grabbing all found static flags.
Reviewed By: quark-zju
Differential Revision: D15487686
fbshipit-source-id: 6a40947078eb4bf0683a6f168c21d234a40939ef
Summary: Flag definition is used for parsing flags on the command line, as well as allowing the configuration of flags that may accept values, have short names, long names, etc.
Reviewed By: quark-zju
Differential Revision: D15487487
fbshipit-source-id: 7b41b027ae4770b86c2e19973e57ac41f717cfc8
Summary: Initial commit for the cliparser command line argument parsing library. Can be tested with buck, or cargo.
Reviewed By: quark-zju
Differential Revision: D15487278
fbshipit-source-id: 5f3f65e58a815d2c408e38a3eb9e9981086c6715