Summary:
This is more conistent with Mercurial style. And make them usable directly in
Rust code.
Reviewed By: sfilipco
Differential Revision: D16796397
fbshipit-source-id: 9016ea2b09fdf96b2b54138f5c8405caf96390f7
Summary:
This makes the "content" of the error stable. It is used in a later diff where
AmbiguousCommand gets handled by Rust directly instead of falling back to
Python dispatch.py.
Reviewed By: sfilipco
Differential Revision: D16796404
fbshipit-source-id: c439db14ec83c76c4762d3c627bfce1ea44bccf4
Summary:
In case there are many CommandDefinitions, we don't need all their flag
definitions until we decided to execute one of the commands.
Reviewed By: sfilipco
Differential Revision: D16796398
fbshipit-source-id: af205f59efd77fd7ff9eb4655d1f9167e2c350da
Summary: Convert global flags to `HgGlobalOpts` struct to make code shorter.
Reviewed By: sfilipco
Differential Revision: D16796407
fbshipit-source-id: b9d4c3dbec68c81908d439da4c353249347ca74a
Summary:
The tests are
- Mostly testing about configurations.
- Mostly depends on private functions.
ConfigSet already has a good test coverage, the tests do not provide much
value (aside from testing config override ordering, which is also covered
by hg tests). I'm going to change / remove the private functions. Remove the
tests to make changes easier.
Reviewed By: sfilipco
Differential Revision: D16796402
fbshipit-source-id: 56a8d55a0d1b0438bd2fcde5d3379d76f51dcd9d
Summary: This makes it possible to simplify the code reading global flags.
Reviewed By: sfilipco
Differential Revision: D16796405
fbshipit-source-id: eb604470d052ef84b748d1e60270cacd410fc5da
Summary:
The `Dispatcher` provides lots of features but its internal state only contains
the command table. Replace it with `CommandTable` and make the methods free
functions.
This makes function dependencies more cleaner, for example things like "locating
a repo", "getting the args" etc. won't require a `Dispatcher`.
A side effect of this change is the non-utf8 command line arguments are no longer
supported. This is already broken since our hg wrapper (accidentally) enforced
utf-8 command line. Therefore related tests are removed.
Reviewed By: sfilipco
Differential Revision: D16796395
fbshipit-source-id: a793ce7b8befe7caf62405c582fc932eb3daa099
Summary:
The dispatch logic couples with too much stuff - repo, parsing, command,
config. The command / registration part can be cleanly seprated.
This diff moves the core logic of CommandTable to command.rs.
Reviewed By: sfilipco
Differential Revision: D16796406
fbshipit-source-id: 5a33d6b6452537f07895bd9944122a3b3149d925
Summary:
At first, that aim was to create a good and consistent test plan of snapshots:
```
# Snapshot test plan:
# 1) Empty snapshot (no changes);
# 2) Snapshot with an empty manifest (changes only in tracked files);
# 3) Snapshot with a manifest (merge state + mixed changes);
# 4) Same as 3 but test the --clean flag on creation;
# 5) Same as 3 but test the --force flag on restore.
```
Then I discovered some bugs while writing the tests.
1) In case of an empty manifest the `snapshotmanifestid` extra should be an empty string, not `None`.
This is because of the extra serialization rules.
2) The initial approach for doing the checkout did some unnecessary operations with dirstate,
which required it to rollback later.
Now the overhead is gone, and the strategy of checking out is as follows:
```
1. Regular hg update to the (1st) parent of the snapshot;
2. Apply all the changes via mergemod.update without pushing it to the dirstate;
3. Register these changes in the dirstate;
4. Tie the second snapshot parent to the working context, if it exists.
Reviewed By: markbt
Differential Revision: D16929417
fbshipit-source-id: 0319ac0e81f80956cdef5b2a696b642cc782f48d
Summary: Snapshots have invisible commits underneath them, so that flag is redundant.
Reviewed By: markbt
Differential Revision: D16916268
fbshipit-source-id: 294f34af5aa7942be0bb2b58f0dc65979d593157
Summary: Due to a bug the missing files from the snapshot manifest were marked as removed after checkout.
Reviewed By: markbt
Differential Revision: D16831796
fbshipit-source-id: 200ccf34b16392a73d38294f1fcb43bfa9a94690
Summary:
D16910636 and D16898856 both add a `hex` call to a `node`. That results
in a 80-char commit id, which breaks 20+ tests. Back out D16910636 to fix
tests.
Reviewed By: simpkins
Differential Revision: D16931869
fbshipit-source-id: 5794cd6a2d1d1eda87c525231ef15b621f2074c5
Summary:
Log the full command-line arguments, and the traceback to a dedicated table if
revision numbers are used to resolve commits.
This should give us clues about why revision numbers get used in some subtle
code paths.
Reviewed By: singhsrb
Differential Revision: D16910639
fbshipit-source-id: 2cc1f6436b6100720fad65ea672dc4bfe2caa245
Summary:
`legacy.revnum:real` is set by `scmutil.rev*` to scope the revision number
detection to user-provided input. We shouldn't log it if the user does not
provide revision numbers.
This diff skips logging if the code runs outside the `scmutil.rev*` context.
This should remove most false positives.
Reviewed By: singhsrb
Differential Revision: D16921155
fbshipit-source-id: cc1402df8806a65f45079ef076bd81e1ed8ce0af
Summary:
A revset optimization pass rewrites revsets like 1+2+3 to use the `_list`
revset function that has a fast path to bypass the `stringset` function.
Change `_list` to detect revision numbers too.
Reviewed By: singhsrb
Differential Revision: D16910791
fbshipit-source-id: 51036b7d6f16b5388bbaf996864946df91a9f093
Summary:
There are some commands like `hg log --limit 50` that show up in the
"revision number used" cases but it's unclear how they acutally use
revision number.
To figure it out, I plan to also log tracebacks to a separate table.
To make the traceback more useful, I plan to do a "best effort"
printing the arguments passed to functions. That will probably help
figuring out what revset expression is passed to some layer.
Reviewed By: singhsrb
Differential Revision: D16910638
fbshipit-source-id: dbc493cd6ae571e3256305487f12842494c92a8a
Summary: This removes a false positive detection of "revision number used".
Reviewed By: singhsrb
Differential Revision: D16910636
fbshipit-source-id: d30d04f1a793598b75eab6adb07d4f9c18cb85a1
Summary:
`scmutil.rev*` should not be used for non-user-provided input. Change them to
`repo.anyrevs` or `repo[]` instead. This should reduce false positives of
revision number usage detection.
Reviewed By: singhsrb
Differential Revision: D16910637
fbshipit-source-id: b53bc9ba4ee52cb37c86f819d70898c14a6c569f
Summary:
Change `root` to normalize the repo path so it strips `\\?\` UNC prefix that
might break some (ex. Python) scripts.
Reviewed By: DurhamG
Differential Revision: D16928880
fbshipit-source-id: 9691b712f1ba0a07815d025e083d0cbd90b7d6a3
Summary: This makes the code reusable.
Reviewed By: DurhamG
Differential Revision: D16928881
fbshipit-source-id: cced0ecd6099e86c4a3f2f843e4dcfa9c6748e27
Summary:
Use of revision number is being deprecated. Change the moverelative commands
(`next`, `previous`, ...) to use nodes internally.
Reviewed By: mitrandir77
Differential Revision: D16898856
fbshipit-source-id: 71f6fc32776e2912795f086d11897d36b942b608
Summary:
We do not want to use censorship/blacklisting, as those names are ambiguous
and redaction has exactly the meaning we need.
Reviewed By: quark-zju
Differential Revision: D16890423
fbshipit-source-id: 1a6dcc61ca3fe77b7a938a37fb1ec9250ae9e15a
Summary:
Using many context managers doesn't format well with Black because of the way
Python `with` syntax works.
Instead, construct all the context managers ahead of the call, making the
`with` statement short enough to fit on a single line.
Reviewed By: quark-zju
Differential Revision: D16831187
fbshipit-source-id: 331a8aea4e039e14a88f268c430c0fd7c793b292
Summary: In hg unshelve, it's still using the rev number. Lets switch it to the node().
Reviewed By: singhsrb
Differential Revision: D16895784
fbshipit-source-id: c4bf765e2cec3e59eeb1a9d0fa1e3cafc57029aa
Summary:
Previously, the command table state in `Dispatcher` is confusing:
command_table: BTreeMap<String, CommandFunc>,
commands: BTreeMap<String, CommandDefinition>,
Question: In what case do these BTreeMaps have different keys?
It does not make much sense. Therefore merge `CommandFunc` into
`CommandDefinition`, and remove the `command_table` field.
This affects the `register` API:
fn register(&mut self, command: CommandDefinition, f: FN)
`f` is part of `CommandFunc`, which duplicates with `CommandDefinition`.
`CommandDefinition` contains 3 things: name, doc, and flags.
In the new `define_flags!` world, `flags` can be inferred from the type
of the function, so only `name` and `doc` are needed. Therefore change
the register function to:
fn register(&mut self, f: FN, name: &str, doc: &str)
Update `hgcommands` to use the newer APIs. Commands can now be registered
without going through `CommandDefinition` explicitly.
Reviewed By: sfilipco
Differential Revision: D16733275
fbshipit-source-id: 68e404a5b271b72aad52f640123b1c083f31d76c
Summary:
The only actual use of the function is to get Python command names (not
functions) so it can do prefix matching.
Just change the prefix matching logic to load the config and drop concepts
about "python" in CommandDefinition.
The Rust command table now only contains Rust commands.
Reviewed By: sfilipco
Differential Revision: D16733265
fbshipit-source-id: 7c680ef77874e9a136befc286cd26663ba82b09f
Summary: The enum owns the function of the command. Rename to make it clear.
Reviewed By: sfilipco
Differential Revision: D16733262
fbshipit-source-id: 6fdc7e999b0863b2a7b35203ac704928f8f92cd2
Summary:
Use `define_flags!` to auto generate conversion from `ParseOutput`.
A side effect is `args` is moved to the struct, and function signature becomes simpler.
Currently, `args` will also include the command name itself. This might be
useful when multiple commands share a similar implementation (ex. `next`, `prev`).
Reviewed By: sfilipco
Differential Revision: D16733269
fbshipit-source-id: fe32e41fe48a97d2d2f5a122522a17fa3c5f5f82
Summary:
This makes it possible to use one structure instead of a structure + another
`args` list.
The current version only supports a `Vec<String>` field and there is no verification
about how many arguments that `Vec<String>` can have. In the future we can add:
- Verification about arguments. Potentially change `From<ParseOutput>` to `TryFrom<ParseOutput>`.
- Individual named arguments as individual fields.
Reviewed By: sfilipco
Differential Revision: D16733272
fbshipit-source-id: 2bb407fff6cd1790cf33e8ce5527bb5e44255215
Summary: This can make code shorter.
Reviewed By: sfilipco
Differential Revision: D16733264
fbshipit-source-id: 27c0299c6e59bc30cfa14aa9ce122e2a542fd9c1
Summary:
Git does not have command name prefix matching. We now use `commands.names`
config options as a hint to avoid going to the Python land for command
prefix matching. It works but is not "correct". If we drop the prefix matching
feature, then the problems are gone - fast paths won't need prefix matching
aka. the command name list, and slow path (ex. wrong command) can afford
loading Python for all command names.
`hg d` is the single most used prefix matching command. Assign an explicit
alias to it to avoid regression if we do drop prefix matching (or, make
that more expensive than resolving commands direcly).
Reviewed By: sfilipco
Differential Revision: D16733274
fbshipit-source-id: 8904288b8a1ddf1fc6e6ec54ffaa36e503ebdb77
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
Summary:
This test is currently broken if lfs-test-server is installed. Disable it
instead of relying on the test system does not have lfs-test-server.
Reviewed By: sfilipco
Differential Revision: D16733271
fbshipit-source-id: de0c9beb8e981e33e32e43435e2d06181cbae70e
Summary:
Similar to D14151200, instead of printing a long help that might flush out
important messages, make the error short but still point the user to `hg help`.
This makes the error message much shorter, and make the test change by the
upcoming diff smaller.
Besides, we no longer check disabled extensions, as we don't expect users to
tweak extension config by themselves.
Reviewed By: sfilipco
Differential Revision: D16733273
fbshipit-source-id: b39bd4b2af6f315273484ec582094609b8e331ae
Summary:
Resolve aliases directly in command help. This removes the dependency of the
Python alias handling.
There are some minor behavior changes. But they look reasonable.
Reviewed By: sfilipco
Differential Revision: D16733276
fbshipit-source-id: ad97def2c60828236bbd8784ffd8202abfdeeb15
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
Summary:
The shell alias tests are hard to read because:
- It uses `cat << EOF`, which will escape the heredoc block.
- It uses `sh -c`, which adds another layer.
Change `EOF` to `'EOF'` to prevent escaping heredoc, and remove `sh -c` to make
the test easier to read. The `escaped3` test now works as expected.
Reviewed By: sfilipco
Differential Revision: D16819451
fbshipit-source-id: 687e9ce78dfed7d76b53cf90e6d871dffd3ab84d
Summary:
Alias starting with `!` are considered shell commands. The entire command
string should be passed roughly as-is to the shell.
The current alias handling uses shlex::split to split the alias into arguments,
then replaces things like `$1` in arguments. The problem is, escaping
shlex::split a complex shell alias, then unesape (shlex::quote) it is not
loseless.
To maintain compatibility for existing complex shell alias configuration,
add a new code path that imitates the Python code behavior.
Reviewed By: sfilipco
Differential Revision: D16814144
fbshipit-source-id: 0e5e95f99bf8b8b16bd8d0cbcadd6760f7f77ebb
Summary: This will make shell aliases fit in the normal hg command framework.
Reviewed By: sfilipco
Differential Revision: D16530521
fbshipit-source-id: c1b158bc2895add03fa92099564830e55e02f1b7
Summary:
The latest update in the documentation references the `hg fold` subcommand
from the "core" mercurial files. This makes the `test-check-help.t` test
want to verify the `help` for `fold`. The problem is that the test does not
enable the `amend` extension that provides the fold command.
Following a previous fix to this test, I am enabling the amend extension for
the test. It makes sense to me given the current setup.
Reviewed By: singhsrb
Differential Revision: D16907781
fbshipit-source-id: b0ba31518b6d4c210eb5b8cc7985a945ab1180e4
Summary:
IPython has fallback code for `import sqlite3`. Make it non-lazy so IPython can
detect missing sqlite3 (on our Windows distribution) and continue working.
Reviewed By: ikostia
Differential Revision: D16897722
fbshipit-source-id: f7d312e10b9806498a03ce0788d436f6d72ddae8
Summary: Updated help text for hg redo and hg metaedit
Reviewed By: markbt
Differential Revision: D16723556
fbshipit-source-id: 9859d921f8e39880a0edc28c87f66d48268069dd
Summary:
Essentially the commit hashes changed and thats fine. See D16836997
for more context.
Reviewed By: quark-zju
Differential Revision: D16860590
fbshipit-source-id: ddd82dfbcdfbea9d5ace68adaedeb05bda6e3d7a
Summary:
Commit cloud and infinitepush currently only back up draft commits, omitting
secret ones. However, commit cloud sync with visibility enabled will try to
sync all visible commits, including the secret ones. This means users with
secret commits won't be able to sync them to their other machines as they won't
have been backed up.
We eventually want to get rid of the secret phase, which means all non-public
commits should be synced. Update commit cloud to backup and sync all
non-public commits, including secret ones.
Currently secret commits become draft when they are received by the other
machine. Since we're planning to get rid of the secret phase, this should be
fine.
Reviewed By: mitrandir77
Differential Revision: D16830832
fbshipit-source-id: 2ce4447ffa750a2edcb194cdf92321c1393ff805
Summary:
Connecting to large workspaces can result in many pulls within a single sync.
This re-uses the connection to the server. We have seen instances where the
server can't serve all of these pulls and crashes with a MemoryError.
Pragmatically close the connection between each pull to prevent this.
Reviewed By: farnz
Differential Revision: D16858728
fbshipit-source-id: 7561c6f01c38df2706bd7fd76f5a7387e9728dc8
Summary:
So far the hashes of manifest/commits may vary, mostly because of
different path separators on different platforms (`/` vs `\\`) and its serialization to string in the snapshot manifest.
Reviewed By: markbt
Differential Revision: D16856130
fbshipit-source-id: a19dff113b9b24f1c7f387b9bc5a5e39e83ef8af
Summary:
Now that we are writing the git hash inside the commit itself, if we are translating
from hg to git hash, we should just use that rather than loading the entire map and
build a dict and look it up.
The performance of this translation will also improve quite a lot.
Some small sample benchmarking:
```
suiting@devvm5006:configerator (659199b|remote/master)$ time ~/fbcode/scm/hg/hg log -r master -T '{node} || {gitnode}\n' --config exte
nsions.fbconduit=! --config extensions.hggit=
659199bf7c7850ea9ffa9e0ad50eb84597977dea || 69f05aeec13f09c44dd00d2a85fe9d461ba6841e
real 0m0.563s
user 0m0.004s
sys 0m0.007s
suiting@devvm5006:configerator (659199b|remote/master)$ time ~/fbcode/scm/hg/hg log -r master -T '{node} || {gitnode}\n'
659199bf7c7850ea9ffa9e0ad50eb84597977dea || 69f05aeec13f09c44dd00d2a85fe9d461ba6841e
real 0m14.706s
user 0m0.006s
sys 0m0.006s
```
Reviewed By: quark-zju
Differential Revision: D16833526
fbshipit-source-id: 7d3096649cf24967d13596e70463bc125081ba4f