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
Summary: New degbugstore command prints contents of blob in store give filenname and hash.
Reviewed By: xavierd
Differential Revision: D16791780
fbshipit-source-id: d4529f3f368677b4f65a5772f82a1655552fefa5
Summary:
The indexes are lagging by design to reduce space overhead. For immutable Logs
(esp. used by RotateLog), the indexes no longer need to be lagging.
Make it so to reduce overhead opening RotateLog.
As we're here, also fix an issue where `rotate_assume_locked` was not really
protected by a lock.
Reviewed By: sfilipco
Differential Revision: D16587181
fbshipit-source-id: 3cf81864e90c875ee661dbd994bcd3ebc4b55322
Summary:
Since D16681230, a commit made with no file changes will re-use it's parent
manifest. This can trigger the commit hash to be different, which broke some
subversion tests. Since hgsubversion will be going away soon, I took the
approach of using run-tests.py -i and in test-hgsubversion-custom-layout.py to
not run the test that fails.
Reviewed By: sfilipco
Differential Revision: D16836997
fbshipit-source-id: 58e50a9147c8c263fca74158af120ec8ec5d8c52
Summary:
The upcoming changelog change will *have to* use a different set of numbers.
Some of the numbers might be generated on demand, which has difficulity
resolving a number to a commit hash.
There are a lot of internal (especially, tests) usecases of revision numbers.
The deprecation message is only shown for user-provided inputs (ex. things
that go through `scmutil.revrange`).
This does not affect the use of `{rev}` template yet.
Reviewed By: sfilipco
Differential Revision: D16795522
fbshipit-source-id: 7a5578ecc0afdcc86830238471ff95203c96dc3f
Summary: We follow the Python code-style for APIs exposed to the Python world.
Reviewed By: sfilipco
Differential Revision: D16683786
fbshipit-source-id: 5bc6e76cb621ec93cce6711e794d032857702629
Summary: Pass `uiconfig` to changelog so it can read config options.
Reviewed By: sfilipco
Differential Revision: D16683785
fbshipit-source-id: a64cfbe2cefa6b20ec695d2766bcfe878c764323
Summary:
A large portion of `ui` is config handling. Split it to a separate class so we
can pass that separate class to places that need pure configuration.
Some `develwarn`s are skipped since the new class does not have access to fout
or ferr.
Reviewed By: DurhamG
Differential Revision: D16683787
fbshipit-source-id: d823b9e5fc6f8ed08fff3401ab3502ad3c434f00
Summary:
Allow the user to check out on the snapshot by its revision id.
Snapshot == "a commit with extra containing a key `snapshotmanifestid`".
This corresponding value can be `None`, that would mean that snapshot does not contain untracked/missing/merge files.
Reviewed By: mitrandir77
Differential Revision: D16788479
fbshipit-source-id: bf4a9508acc940290b18123d3dd7b7fefae83782
Summary:
Now `hg debugcheckoutsnapshotmanifest` overwrites files if given the `--force` flag.
It also gives a more detailed output on the changes it makes.
Reviewed By: mitrandir77
Differential Revision: D16786334
fbshipit-source-id: b41d6241ffb478bd6c30a01c154b095d1ea92d78
Summary:
Add the `debugsnapshot` command, which will be renamed to `snapshot` later.
It creates a snapshot manifest that features information about
* untracked files,
* missing files,
* merge state artifacts from `.hg/merge` and `.hg/rebasestate`.
The snapshot manifest is stored in local lfs.
Then it creates the actual snapshot -- a fake commit, which has the snapshot oid in extra data.
It does not handle unresolved merge conflicts and other difficult states on this stage.
~~Finally, it restores the working copy and dirstate to status quo.~~
It doesn't need to be done, now we create only the commitctx, which does not wreck the dirstate.
Reviewed By: mitrandir77
Differential Revision: D16716359
fbshipit-source-id: 743f7427ce89c3fca6f844487bac1c456338e613
Summary: `--no-foo` should only work if `foo` is a boolean flag.
Reviewed By: farnz
Differential Revision: D16715454
fbshipit-source-id: 9a8183586aa50fb55f30e19276bd60ebcc23a5fb
Summary: The helper function is no longer necessary.
Reviewed By: sfilipco
Differential Revision: D16715455
fbshipit-source-id: 3bf528d3c9f18418724793edebf298425a3bba87
Summary:
Whenever a checkout is done, the new commit is sent to commitcloud.
This currently works with the hook on update, but the hooks on commit are not working
Reviewed By: mitrandir77
Differential Revision: D16687423
fbshipit-source-id: a0b861d301c84764f31787454cdec594b0519fa3
Summary:
Previously, `get` returns an `Option<T>`. Almost all callers use `unwrap`
immediately, since they know what flag names are available. Let's just
move the `unwrap` inside the function. `get` in the Rust (and Python)
eco-system is considered nullable and panic-free. Rename it to `pick`
to make the difference more obvious.
I considered using the `Index` trait, but it has to return a reference,
which does not fit into this use-case.
Reviewed By: sfilipco
Differential Revision: D16715453
fbshipit-source-id: f754d208c4a1b0adeddaee82c7db82c790d6436c
Summary:
The default value of a flag is already provided with the flag. Therefore
`get_or_default` requiring another `default` does not make much sense.
Remove it.
Reviewed By: farnz
Differential Revision: D16713531
fbshipit-source-id: 95a55289077b7308083b6685f013d1058419a675
Summary:
This simplifies a lot of code. For example:
- let config_path: Vec<String> = result.get("config").unwrap().clone().try_into().unwrap();
+ let config_path: Vec<String> = result.get("config").unwrap();
Also, the use of `TryInto` does not make sense - the code only implements
`Into`, and `TryInto` will panic. Therefore remove `TryInto`.
Reviewed By: farnz
Differential Revision: D16713534
fbshipit-source-id: 29dc71881dd844fa87e086543fb0a3bb5d8837a1
Summary:
Replace `_` in field names to `-` as long flag name. That is consistent with
the current hg behavior.
Reviewed By: sfilipco, farnz
Differential Revision: D16713530
fbshipit-source-id: ce36caebc6b3131cb418d86ca0fdc507d2d8f17f
Summary:
Change the macro to have state so we can parse fields one by one with different
syntax.
Reviewed By: sfilipco
Differential Revision: D16713536
fbshipit-source-id: 7f8cb63cfa0ea000c2c2a431454c2d88d49b9187
Summary:
This macro provides `Vec<Flag>` and implements `From<ParseOutput>` for a
struct intended to be used as command options.
The core macro is just 21 lines. Both structopt-derive and gumdrop_derive have
1000+ lines.
Of course, it lacks of features. Some of those features are:
- No way to provide a "short flag".
- Default values have to be explicitly written.
- No way to compose structs (ex. reuse DiffOpts)
- Should "args" be part of the structure?
- Should "command help" be part of the structure?
Reviewed By: sfilipco
Differential Revision: D16713535
fbshipit-source-id: e8137e5f110ebb280fc40f84dace7b1d3a346c82
Summary:
D16716743 breaks the Windows build. One of the breakages is that `hg status`
stops working and crashes with `RuntimeError: invalid encoding`. This is
because dirstate has special treatment for root directories. Changing the
representation of the root directory stopped the special treatment.
Reviewed By: quark-zju
Differential Revision: D16812743
fbshipit-source-id: 49f96c87f471876993aec332e032ffcd619d268b
Summary:
This updates Mononoke to support LFS metadata when serving data over getpackv2.
However, in doing so, I've also refactored the various ways in which we currently access file data to serve it to clients or to process client uploads (when we need to compute deltas). The motivation to do that is that we've had several issues recently where some protocols knew about some functionality, and others didn't. Notably, redaction and LFS were supported in getfiles, but neither of them were supported in getpack or eden_get_data.
This patch refactors all those callsites away from blobrepo and instead through repo_client/remotefilelog, which provides an internal common method to fetch a filenode and return its metadata and bytes (prepare_blob), and separate protocol specific implementations for getpackv1 (includes metadata + file content -- this is basically the existing fetch_raw_filenode_bytes function), getpackv2 (includes metadata + file contents + getpackv2 metadata), getfiles (includes just file content, and ties file history into its response) and eden_get_data (which uses getpackv1).
Here are a few notable changes here that are worth noting as you review this:
- The getfiles method used to get its filenode from get_maybe_draft_filenode, but all it needed was the copy info. However, the updated method gets its filenode from the envelope (which also has this data). This should be equivalent.
- I haven't been able to remove fetch_raw_filenode_bytes yet because there's a callsite that still uses it and it's not entirely clear to me whether this is used and why. I'll look into it, but for now I left it unchanged.
- I've used the Mercurial implementation of getpack metadata here. This feels like the better approach so we can reuse some of the code, but historically I don't think we've depended on many Mercurial crates. Let me know if there's a reason not to do that.
Finally, there are a couple things to be aware of as you review:
- I removed some more `Arc<BlobRepo>` in places where it made it more difficult to call the new remotefilelog methods.
- I updated the implementation to get copy metadata out of a file envelope to not require copying the metadata into a mercurial::file::File only to immediately discard it.
- I cleaned up an LFS integration test a little bit. There are few functional changes there, but it makes tests a little easier to work with.
Reviewed By: farnz
Differential Revision: D16784413
fbshipit-source-id: 5c045d001472fb338a009044ede1e22ccd34dc55
Summary:
D15668362 fixed the O(working copy size) behaviour of amend but accidentally
introduced one that's proportional to number of files changed. This fixes the
problem
Reviewed By: markbt
Differential Revision: D16803076
fbshipit-source-id: ad8983c8dfbd28b1958220f8786b8071f50cd0fb
Summary:
The fastlog code says it cannot handle file renames, which is not true as far
as I know. Therefore, try use it for files. This affects the `follow()` revset.
I picked a random file, and fastlog is faster than the alternative code path
even with warm cache:
With fastlog:
% ./hg log edenscm/mercurial/smartset.py --time --pager=off -T '.' --debug --config fastlog.files=1
found common parent at a320f95a23716d0d106d922fa07ffcf0f838d3ff
starting fastlog at a320f95a23716d0d106d922fa07ffcf0f838d3ff
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
time: real 2.060 secs (user 1.870+0.000 sys 0.290+0.000)
Without fastlog, cold cache:
% sudo rm /var/cache/hgcache/fbsource/packs/*.hist*; ./hg log edenscm/mercurial/smartset.py --time --pager=off -T '.' --debug --config fastlog.files=0
fastlog: not used because fbcode/scm/hg/edenscm/mercurial/smartset.py is not a directory
.fetching content for 1 file over HTTPS
35.56 kB downloaded in 147 ms over 1 request (0.24 MB/s; latency: 147 ms)
fetching history for 1 file over HTTPS
445 B downloaded in 56 ms over 1 request (0.01 MB/s; latency: 56 ms)
running ssh -oControlMaster=no hg.vip.facebook.com 'hg -R '\''/data/scm/fbsource?stage1_read'\'' serve --stdio'
sending hello command
sending between command
remote: 713
remote: capabilities: unbundlehash gettreepack pushkey getfile getflogheads listkeyspatterns knownnodes getbundle lookup treeonly stream_option remotefilelog known unbundle=HG10GZ,HG10BZ,HG10UN clienttelemetry branchmap changegroupsubset unbundlereplay batch bundle2=HG20%0Ab2x%253Ainfinitepush%0Ab2x%253Ainfinitepushmutation%0Ab2x%253Ainfinitepushscratchbookmarks%0Ab2x%253Arebase%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps%0Atreemanifest%3DTrue%0Atreemanifestserver%3DTrue%0Atreeonly%3DTrue streamreqs=generaldelta,lz4revlog,revlogv1 getannotate stream-preferred
remote: 1
sending clienttelemetry command
connected to hg020.prn2.facebook.com
sending getpackv2 command
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
876 files fetched over 876 fetches - (1 misses, 99.89% hit ratio) over 5.98s
(running background incremental repack)
time: real 11.920 secs (user 5.050+0.000 sys 0.470+0.000)
Without fastlog, warm cache:
quark@devvm33994 ~/fbcode/scm/hg % ./hg log edenscm/mercurial/smartset.py --time --pager=off -T '.' --debug --config fastlog.files=0
fastlog: not used because fbcode/scm/hg/edenscm/mercurial/smartset.py is not a directory
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
time: real 2.530 secs (user 2.050+0.000 sys 0.070+0.000)
This is one step forward getting rid of the legacy filenode / ancestormap
logic. It regresses on offline experience, but we can build simple caches
around the `follow()` revset later.
Reviewed By: markbt
Differential Revision: D16365331
fbshipit-source-id: 16ffd6c3ec2daa5530fed94fb9c41fe75efd6182