Commit Graph

46464 Commits

Author SHA1 Message Date
Shu-Ting Tseng
01394c9202 hg debugcrdump should also use globalrev
Summary:
This command uses svnrev directly. However once we migrate to www-hg, this fields will
go and we can only use globalrev instead.

Let's add that and put it behind a config.

More context: https://fb.workplace.com/groups/248282915800791/permalink/372855146676900/

Differential Revision: D16560447

fbshipit-source-id: de3100ed1e6cc39eaaeff2fe11af04d2f1e2c41a
2019-07-31 09:16:23 -07:00
Mateusz Kwapich
bfc5ee0878 fix O(workingcopy) hg amend <file> behaviour
Summary:
context: Mercurial is slow for peoople that can't use watchman and eden https://fb.workplace.com/groups/scm/permalink/2133433800039562/

Please let me know if this approach (hacking the wctx) is acceptable in your
opinion

Reviewed By: quark-zju

Differential Revision: D15668362

fbshipit-source-id: a94f39be2d845e751a8bb69ca8ca000ef46d9d2d
2019-07-31 08:48:20 -07:00
Jun Wu
35b2eed156 lib: remove argparse
Summary:
`cliparser` and `clidispatch` are more complete / compatible implemention for
related feature.

Reviewed By: xavierd

Differential Revision: D16575262

fbshipit-source-id: e78047a826896e1cd8529e14133d2821bc0955d3
2019-07-31 03:24:27 -07:00
Xavier Deguillard
e30a0b41f3 indexedlog: recover from partially created LogRotate
Summary:
In some rare cases, it's possible that the "latest" file is created, but the
matching indexedlog isn't. Let's nicely recover from this by creating the
indexedlog in this case.

Reviewed By: kulshrax

Differential Revision: D16554090

fbshipit-source-id: 6b68d7806662b511917655a71c3a3c15ad6e1f64
2019-07-30 10:17:10 -07:00
Jun Wu
bd75a8e099 cliparser: fix regression on error message
Summary:
Fix the regression caused by D16557266 on error message. The fix is not the
most efficient, though. But it should restore the behavior.

Reviewed By: singhsrb

Differential Revision: D16557654

fbshipit-source-id: 2eb6956f99c931f94201b875c8bebb2219a794f0
2019-07-30 08:43:39 -07:00
Mateusz Kwapich
6b7f8fe167 autoformat all of fbcode/scm with black
Summary: blackpylogo

Reviewed By: krallin

Differential Revision: D16543521

fbshipit-source-id: 75977d00329e1068a92a344c99e0ad0392601c54
2019-07-30 08:21:05 -07:00
Jun Wu
bf5047760d test-alias: update test showing a regression
Summary:
The last diff D16557266 caused a regression on the error message. Update the
test to show that.

Reviewed By: singhsrb

Differential Revision: D16557653

fbshipit-source-id: ce4a039f4c91a7bd61ea8e570de960880abae937
2019-07-30 01:10:33 -07:00
Jun Wu
5c24ff642e cliparser: special handle debug commands
Summary:
When doing command name prefix match, if there are a unique match for non-debug
commands, use it. This solves `hg d` regression.

Note: we cannot simply use `starts_with("debug")` to test debug commands. That
is because debug commands can have aliases (ex. `debug|dbsh` as the command
name definition, and `dbsh` is also a debug command that does not starts with
`debug`). Therefore it gets a bit complex.

Reviewed By: kulshrax

Differential Revision: D16557266

fbshipit-source-id: 42d814940c9217d9e554bd0fe2769a53e0ee467f
2019-07-29 19:35:32 -07:00
Jun Wu
28a78e89a5 tests: add a test showing "hg d" regression
Summary: `hg d` should not match debug commands.

Reviewed By: kulshrax

Differential Revision: D16557267

fbshipit-source-id: d7936ab530fce4e302b7e410f8abbe619898e941
2019-07-29 19:35:32 -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
8a043e1f34 cliparser: add more test cases about alias handling
Summary: This just makes the code slightly more confident.

Reviewed By: kulshrax

Differential Revision: D16556871

fbshipit-source-id: 5304c3e60c80242974d35a53aace84f829418bb8
2019-07-29 19:35:31 -07:00
Jun Wu
52a45a0632 cliparser: record the index of first positional argument in parse output
Summary: This will be used to accurately replace the command line arguments.

Reviewed By: kulshrax

Differential Revision: D16556870

fbshipit-source-id: efb77a0da17c436e0123354746ba85201813992a
2019-07-29 19:35:31 -07:00
Jun Wu
12968fc5b5 test-alias: add a test showing incorrect behavior
Summary:
Patterns like `--globalopt name name` could confuse the current logic. Add test
cases for it.

Reviewed By: kulshrax

Differential Revision: D16553454

fbshipit-source-id: dac5fd1a9f98093d13dbd85794e3b455c17dcf64
2019-07-29 19:35:30 -07:00
Jun Wu
b434779e81 cliparser: support expanding $1 in aliases
Summary: Expand `$1`, `$2` etc. in aliases. There are users depending on this behavior.

Reviewed By: kulshrax

Differential Revision: D16531016

fbshipit-source-id: fed735339adc82c4f52b74c4c4d62818bc047809
2019-07-29 19:35:30 -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
94073b6891 cliparser: make expand_aliases take a lookup function
Summary:
This avoids calculating the full alias map, and provides more flexibility (ex.
the function can take care of `defaults` handling).

Reviewed By: kulshrax

Differential Revision: D16530514

fbshipit-source-id: 63558da5c9af36b2f8bc7689174fed71593a8186
2019-07-29 19:35:29 -07:00
Jun Wu
cb23d0a3b2 cliparser: move strict handling out of expand_aliases
Summary:
Make `expand_prefix` a public API to expand a command prefix to a full command
name.

Make Python binding handle the `strict` flag so `cliparser` does not have to.

This avoids calculation of `command_map` if strict is True.

Reviewed By: kulshrax

Differential Revision: D16530520

fbshipit-source-id: 5bf9c9f74ae074eac5e350a4db0ebc43f286cebf
2019-07-29 19:35:29 -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
72e3fc1d9a cliparser: simplify expand_aliases a bit
Summary:
The loop body can be changed to reduce some identation.

This changes the behavior a bit - an alias expanding to an emtpy string is now
an error. That's consistent with the original behavior.

Reviewed By: kulshrax

Differential Revision: D16530516

fbshipit-source-id: 3f5c2ebe9d8d1727cac706e4ff11f2678567c525
2019-07-29 19:35:28 -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
Jun Wu
e2dc067ee0 cliparser: change "visited" in "expand_aliases" to HashSet
Summary: `visited` does not need to be a HashMap to detect circular aliases.

Reviewed By: kulshrax

Differential Revision: D16530517

fbshipit-source-id: a27ee97ab8a80e6232600dbc062b0cac701c92a8
2019-07-29 19:35:28 -07:00
Jun Wu
ba96820bef cliparser: remove another unnecessary condition
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
2019-07-29 19:35:27 -07:00
Jun Wu
b443b60df1 cliparser: remove an unnecessary condition
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
2019-07-29 19:35:27 -07:00
Jun Wu
67cd8c9b81 demandimport: blacklist IPython dependencies
Summary: This makes IPython work without disabling demandimport.

Reviewed By: xavierd

Differential Revision: D16509106

fbshipit-source-id: d4443d8b58c90a0fd7a34c620756e88f4f788337
2019-07-29 13:45:44 -07:00
Saurabh Singh
459d04df3f hgsubversion: allow disabling the svnrev template keyword
Reviewed By: quark-zju

Differential Revision: D16546466

fbshipit-source-id: d3d3005b250856d2e93fbd52f178e9cd8bdf6ef2
2019-07-29 13:29:39 -07:00
Mohammad Ayoub
880e757390 add skip 1 day buttons to interactive history
Summary: Added shortcuts a, d that allow you to skip 1 day forward or back in the historical smartlogs interactive view

Reviewed By: mitrandir77

Differential Revision: D16438722

fbshipit-source-id: e61a126ed7390b5ee77ee71694d8b23f3351854a
2019-07-29 08:52:13 -07:00
Mohammad Ayoub
a9fdfb3049 quick fix to add limit to hg cloud sl --history command
Summary: The interactive view doesn't support the pager, so it is problematic for longer smartlogs. As a quick fix the interactive view only contains two weeks of commits. The full version is accessible through hg cloud sl --version_number

Reviewed By: mitrandir77

Differential Revision: D16496065

fbshipit-source-id: 7224258b426724872bf796af618ef70cbf4c9d0b
2019-07-29 07:28:21 -07:00
David Tolnay
f22e8f68d2 tp2/rust: Update socket2, net2, async-trait
Reviewed By: Imxset21

Differential Revision: D16533209

fbshipit-source-id: 41cae09f6924a6d5810fcdd170d52cf39e83bda6
2019-07-27 19:54:26 -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
6bf5f920ee hgmain: implement native hg root command with new dispatch library
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
2019-07-26 20:38:50 -07:00
Jared Bosco
8a80bd6859 clidispatch: implement command registration and dispatch
Summary:
Implementing the main dispatch logic including:
* registering command handlers
* dispatching to command handlers
* error handling
* alias expansion
* configuration loading
* repository loading ( path && sharedpath )

This dispatching is very closely mirrored to Mercurial's `dispatch.py` logic to not have surprising behavior, and is designed that during any error that occurs execution could fallback to the original Python code.

This diff does not actually change any behavior in hgmain.  The next diff will implement `hg root` using this dispatch foundation.

Reviewed By: quark-zju

Differential Revision: D16452454

fbshipit-source-id: b32953d43c4fa0a2d9bf9978028a299efe203546
2019-07-26 20:38:50 -07:00
Mateusz Kwapich
5ce2387e15 fix the problem with flags starting from --no
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
2019-07-26 14:13:11 -07:00
Mateusz Kwapich
073fcf2078 show the problem with handling args prefixed with 'no-'
Summary: context: T47908435

Reviewed By: quark-zju

Differential Revision: D16519889

fbshipit-source-id: 952df74f381af2c527cecabe0cd804e7a51bed10
2019-07-26 14:13:11 -07:00
Shu-Ting Tseng
8419106c36 fix flaky tests from hgsubversion
Summary:
The shenanigan was introduced in D16337012 where I tried to reuse pushrevisionwithconfigs.

I am breaking the chain now as it's tooooo hard to reuse and we've spent 4-5 diffs on this now.

Reviewed By: xavierd

Differential Revision: D16520271

fbshipit-source-id: 94cf8580cf3b852ecf7897861893bb51ce03d564
2019-07-26 13:30:12 -07:00
Jun Wu
fcf2eb16cb bindings: add a wrapper to use Rust Read / Write traits on Python objects
Summary:
Add a method to wrap a Python `io` object (with `read` or `write` methods, ex.
`sys.stdin`, `ui.fout`, or `util.stringio()`) in a native Rust object so it can
be used in Rust code expecting Read / Write traits.

This will be used to expose the Rust "dispatch" logic to Python.

Reviewed By: sfilipco

Differential Revision: D16511017

fbshipit-source-id: cb1f5c20e392311cd648abe0528b971ab0266845
2019-07-26 11:09:57 -07:00
Xavier Deguillard
efad0cf903 cstore: remove py-cdatapack
Summary:
With fastdatapack gone, the cdatapack bindings are no longer necessary and can
be removed.

Reviewed By: singhsrb

Differential Revision: D16476584

fbshipit-source-id: 130a9c5aed4e4f005876c420961f09d398f6e6aa
2019-07-26 10:35:46 -07:00
Xavier Deguillard
f36d8a8fe1 remotefilelog: remove basepack
Summary: This is no longer used anywhere, we can remove it.

Reviewed By: singhsrb

Differential Revision: D16476582

fbshipit-source-id: fe6a8f33cbc3c37fb1d8fb33226352e41bcbaa2a
2019-07-26 10:35:46 -07:00
Xavier Deguillard
28d7ef620b remotefilelog: remove fastdatapack
Summary: This code isn't used anywhere, let's get rid of it.

Reviewed By: singhsrb

Differential Revision: D16476583

fbshipit-source-id: d42376dbb2cf631a170ade3e2764d1f70922d882
2019-07-26 10:35:45 -07:00
Xavier Deguillard
6cdcb360ed remotefilelog: remove mutablebasepack
Summary: This code is no longer used anywhere.

Reviewed By: singhsrb

Differential Revision: D16462343

fbshipit-source-id: 3e11994575a6de75562cb1ebd8839f7058abc075
2019-07-26 10:35:45 -07:00
Aleksei Kulikov
59bb951024 amend: make next prefer draft commits
Summary: Add an option `update.nextpreferdraft` that makes `hg next` prefer single draft child commits.

Reviewed By: markbt

Differential Revision: D16500162

fbshipit-source-id: 3a20bb487d35b7acf92792e9a7b7424c9b163b64
2019-07-26 10:00:07 -07:00
Shu-Ting Tseng
86bdaeb464 make pushes faster in our reverse sync case
Summary:
Our reverse sync job is too slow when pushing to svn. It seems like the slowness comes
keep doing push-pull-rebase which doesn't seem necessary in our case.

From my understanding, we need to do push-pull-rebase because we have multiple writers.
In our sync job, we only have one writer and therefore can we skip the pulls and rebases?

Reviewed By: DurhamG

Differential Revision: D16442559

fbshipit-source-id: 926d1c516e8e6d59298d310fc67927ace37f72c9
2019-07-26 07:21:37 -07:00
Shu-Ting Tseng
83b1186e2a fix flaky tests and re-add it
Summary:
This was removed in D16381346. The problem is in the ui which is always new. Lets keep a
reference to it when adding configs.

Reviewed By: xavierd

Differential Revision: D16494854

fbshipit-source-id: d206b6211c004e0fec57a2aeef6549b2f96cec17
2019-07-26 07:21:37 -07:00
Arun Kulshreshtha
ee69300428 url-ext: move url-ext to common/rust
Summary: This crate is no longer used by Mercurial, but may still be generally useful to others working with Rust HTTP libraries (such as Hyper, which Mercurial no longer uses but motivated the creation of this crate). Rather than just deleting this crate, let's move it to `common/rust`.

Reviewed By: quark-zju

Differential Revision: D16477315

fbshipit-source-id: 385a17751b289d5186dbd9771891c6679c6192ed
2019-07-25 23:01:15 -07:00
David Tolnay
aee8989832 Apply rustfmt to all files
Reviewed By: Imxset21

Differential Revision: D16511369

fbshipit-source-id: aeead9899a6bd50caaa6fe69fdb21160b0befda6
2019-07-25 21:20:12 -07:00
Jun Wu
ddb31755dc test-revset: fix compatibility with Windows
Summary: Set timezone to UTC to produce the same commit hashes.

Reviewed By: sfilipco

Differential Revision: D16501046

fbshipit-source-id: 4d36da07c08a4337ff6b8cb4135eaea22404ad39
2019-07-25 17:43:42 -07:00
Jun Wu
5b543c3f59 test-command-template: fix compatibility on Windows
Summary: Fix various Windows compatibility issues in the test.

Reviewed By: sfilipco

Differential Revision: D16501049

fbshipit-source-id: 72de26fc80a5f9e023e4b30cc2111810c7ff4626
2019-07-25 17:43:42 -07:00
Jun Wu
11522e065c testutil/dott: normalize Windows path after decoding "(esc)"
Summary:
The old code replaces `\foo (esc)` to `/foo (esc)`, and break the `(esc)`
decoding. Change the order so we decode `(esc)` first before normalizing
the path.

Reviewed By: sfilipco

Differential Revision: D16501047

fbshipit-source-id: ac49fa89fe0123436a994548b045edc0cef0a982
2019-07-25 17:43:41 -07:00
Jun Wu
eaabc7f3c6 edenscm: move sys.path handling to top-level edenscm
Summary:
Make `import edenscm` take care of `sys.path` so as long as `import edenscm`
works, 3rd party pure Python dependencies and edenscmnative should be
importable.

This reduces adhoc sys.path handling in testutil.dott, and fixes an issue where
testing on Windows where `testuitl.dott` fails to run hg commands due to
missing 3rd party dependencies (because `edenscm.mercurial.entrypoint.run` is
not called, and edenscmdeps.zip is not in sys.path).

Reviewed By: sfilipco

Differential Revision: D16499458

fbshipit-source-id: 17e6e5754614dfcf352127d471c649ded4189e1a
2019-07-25 17:43:41 -07:00