Commit Graph

1021 Commits

Author SHA1 Message Date
Jun Wu
ec304e1d1e commands: assign 'd' alias to 'diff'
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
2019-08-19 19:27:29 -07:00
Jun Wu
b79b41cd7f dispatch: remove fancyopts
Summary: Remove the dependency from dispatch.py to fancyopts.

Reviewed By: sfilipco, singhsrb

Differential Revision: D16733267

fbshipit-source-id: 9b64c700d28118740c5485cb2df94b6a380b0efe
2019-08-19 19:27:29 -07:00
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
2f3cf9b23b dispatch: do not show help on UnknownCommand
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
2019-08-19 19:27:28 -07:00
Jun Wu
37b7928dc8 help: resolve aliases using Rust
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
2019-08-19 19:27:28 -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
7b96c8d292 cliparser: support shell alias
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
2019-08-19 19:27:27 -07:00
Jun Wu
399556389a commands: add a way to run shell commands
Summary: This will make shell aliases fit in the normal hg command framework.

Reviewed By: sfilipco

Differential Revision: D16530521

fbshipit-source-id: c1b158bc2895add03fa92099564830e55e02f1b7
2019-08-19 19:27:27 -07:00
Jun Wu
e2a7b872ba demandimport: make sqlite3 non-lazy
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
2019-08-19 12:26:21 -07:00
Marla Azriel
b5cc850992 commands: help text for redo, metaedit
Summary: Updated help text for hg redo and hg metaedit

Reviewed By: markbt

Differential Revision: D16723556

fbshipit-source-id: 9859d921f8e39880a0edc28c87f66d48268069dd
2019-08-19 11:34:26 -07:00
Mark Thomas
43bc04968a commitcloud: backup and sync all non-public commits
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
2019-08-16 10:24:44 -07:00
Mark Thomas
94ff729e43 commitcloud: close connection between cloud sync pulls
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
2019-08-16 10:19:25 -07:00
Aleksei Kulikov
0f11c07409 snapshot: fix windows tests and make hashes deterministic
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
2019-08-16 10:15:05 -07:00
Shu-Ting Tseng
150798aac8 translate from hg to git hash should use the extras
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
2019-08-16 07:09:31 -07:00
Jun Wu
bf056a2962 revset: start deprecating revision number resolution
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
2019-08-15 13:24:56 -07:00
Jun Wu
c1813286a7 bindings: remove underscores from dag
Summary: We follow the Python code-style for APIs exposed to the Python world.

Reviewed By: sfilipco

Differential Revision: D16683786

fbshipit-source-id: 5bc6e76cb621ec93cce6711e794d032857702629
2019-08-15 12:47:35 -07:00
Jun Wu
8b4c670550 changelog: get access to config options
Summary: Pass `uiconfig` to changelog so it can read config options.

Reviewed By: sfilipco

Differential Revision: D16683785

fbshipit-source-id: a64cfbe2cefa6b20ec695d2766bcfe878c764323
2019-08-15 12:47:35 -07:00
Jun Wu
6d7c287ab2 ui: split config handling to a separate class
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
2019-08-15 12:47:35 -07:00
Aleksei Kulikov
ad771fcaec snapshot: minor codestyle fixes
Summary: Minor changes.

Reviewed By: mitrandir77

Differential Revision: D16829944

fbshipit-source-id: 08876408bab9a367b852e85e1d7ca86dc0da08a3
2019-08-15 10:48:42 -07:00
Aleksei Kulikov
97c6c6ddaf snapshot: add debugcheckoutsnapshot command
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
2019-08-15 10:48:41 -07:00
Aleksei Kulikov
b45ba7a551 snapshot: add --force option to manifest checkout
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
2019-08-15 10:48:41 -07:00
Aleksei Kulikov
169465460a snapshot: add debugsnapshot command
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
2019-08-15 10:48:41 -07:00
Jun Wu
37bf3cd1eb dispatch: remove 2 calls to fancyopts
Summary: clidispatch replaces them.

Reviewed By: sfilipco

Differential Revision: D16733263

fbshipit-source-id: 32e6cef0ec289a47969b75c332a3117591862ce0
2019-08-15 10:08:36 -07:00
Mohammad Ayoub
075801c976 sync checkout locations on update
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
2019-08-15 08:37:14 -07:00
Stefan Filip
7904ebcfe0 dirstate: fix special handling of root directory
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
2019-08-14 15:47:25 -07:00
Mateusz Kwapich
e7b71bf029 compute the status manifest only once per amend
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
2019-08-14 05:22:53 -07:00
Jun Wu
ea0bdc4d23 ui: disable pager with --debugger
Summary:
`--debugger` starts an interactive REPL. It's incompatible with pager.
Therefore disable pager automatically.

Reviewed By: singhsrb

Differential Revision: D16786806

fbshipit-source-id: a4a219461385f472943e60ba3c2a3b3fefd09e46
2019-08-13 19:12:17 -07:00
Jun Wu
2dad4c70d1 fastlog: add an option to use fastlog for files
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
2019-08-13 19:12:17 -07:00
Stefan Filip
85d53547a3 remove: fix root path ("") exception handling
Summary:
Remove has special handling for the root path which wasn't updated when we
updated the root path representation from "." to "".

Reviewed By: singhsrb

Differential Revision: D16794418

fbshipit-source-id: bb769ce67128041c01010fa2d256c1db5091c564
2019-08-13 18:53:11 -07:00
Xavier Deguillard
33feafa95a localrepo: properly handle no manifest changes
Summary:
We've had a couple of users reporting Rust panics due to an history entry where
its node is also its own parent. The most recent report shows that during a rebase
the commit context contained a removed file while the file itself isn't present
in either parents.

Several fix for this were considered but abandoned, leaving us with a simple
workaround the issue.

Reviewed By: quark-zju

Differential Revision: D16681230

fbshipit-source-id: d5305477792b4450475137d304fe7b22dc0977af
2019-08-13 13:48:26 -07:00
Xavier Deguillard
3f21c278d4 remotefilelog: Rust repack is the default
Summary:
This option has been on for several months now, let's enable it by default in
the tests too. Since the behavior is slightly different, the tests had to be
adjusted:
  - The packfile hashes are different due to a different repack algorithm,
  - test-fb-hgext-remotefilelog-gcrepack.t removed due to gc not being a thing
    with the Rust repack,
  - test-fb-hgext-remotefilelog-repack-corrupt.t corrupt packs aren't detected
    and removed at repack time, but later,
  - test-fb-hgext-remotefilelog-repack.t we no longer re-delta context in the
    Rust repack

Reviewed By: quark-zju

Differential Revision: D16774858

fbshipit-source-id: 7b7a3d96598c1ded0f64237047c3d97510050e4a
2019-08-13 10:50:02 -07:00
Kostia Balytskyi
3767b9c61a remotefilelog: remove unneeded len comparison
Reviewed By: HarveyHunt

Differential Revision: D16782324

fbshipit-source-id: 6924763fa423d4fa516052e01e5e13b0262a8779
2019-08-13 03:59:28 -07:00
Xavier Deguillard
97a6bc8e6a remotefilelog: run python repack even if the pack directory doesn't exist
Summary:
When rust repack is default, and the packs directory doesn't exist, we wouldn't
try to run the loosefile repack, even if we had some. Let's move the packs
directory check a bit later to allow the loosefile repack to run.

Reviewed By: quark-zju

Differential Revision: D16774857

fbshipit-source-id: 1d1b67ae93c1b3aa2d07d5d15325e9be16a01196
2019-08-12 20:08:00 -07:00
Xavier Deguillard
d257546639 remotefilelog: simplify options management in repack
Summary:
Let's always make options non-None. This was causing some issues when switching
to the Rust repack by default.

Reviewed By: quark-zju

Differential Revision: D16774856

fbshipit-source-id: 16fcda0b5a38327d389ed03f87c73d8bd00d5877
2019-08-12 20:08:00 -07:00
Stefan Filip
7997c682d8 match: drop unnecessary adding of '' to set of dirs
Summary:
Change originally made by martinvonz in the mercurial repo:
https://phab.mercurial-scm.org/D6406

Reviewed By: quark-zju

Differential Revision: D16716741

fbshipit-source-id: 0f55659856f11889907ba14d7f5042db2e6face6
2019-08-12 14:34:37 -07:00
Stefan Filip
c39b128b5e copies: remove hack for adding root dir to util.dirs object
Summary:
Change originally made by martinvonz in the mercurial repository:
https://phab.mercurial-scm.org/D6404

Reviewed By: quark-zju

Differential Revision: D16716744

fbshipit-source-id: f11cba2365d45d8db6e481ab12f891f2baea67ba
2019-08-12 14:34:36 -07:00
Stefan Filip
07545bd75e util: make util.dirs() and util.finddirs() include root directory (API)
Summary:
Change originally made by martinvonz in the mercurial repository:
https://phab.mercurial-scm.org/D6403

> This changes the behavior of test-origbackup-conflict.t so it no
longer errors out when the backup path points to an existing
file. Instead, it replaces the file by a directory. That seems
reasonable to me.

Reviewed By: quark-zju

Differential Revision: D16716742

fbshipit-source-id: b40ff1637fa75ea0c140cb861999d2cea83197cb
2019-08-12 14:34:36 -07:00
Stefan Filip
e985cb2472 match: use "" instead of "." for root directory (API)
Summary:
Change originally made by martinvonz in the mercurial repository:
Backporting https://phab.mercurial-scm.org/D6401

> I think '' is generally a better value for the root directory than '.'
is. For example, os.path.join('', 'foo') => 'foo', while
os.path.join('.', 'foo') => './foo'.
This patch mostly makes it so we use '' internally in
match.py. However, it also affects the API in visitdir(),
visitchildrenset() and files(). The two former now also accept '' as
input. I've updated the callers of these methods. I've also added a
deprecation warning for passing '.' (for external callers). The only
caller I could find that was affected by files() returning '' instead
of '.' was in dirstate.walk(). I've updated that.
The next few patches show some workarounds we can remove by using ''
instead of '.'.

Reviewed By: quark-zju

Differential Revision: D16716743

fbshipit-source-id: 4cc18b8cdf2f8a9dc44c42729fb46796a16c3244
2019-08-12 14:34:36 -07:00
Stefan Filip
76bca05339 dirstate: move special handling of files==['.'] together
Summary:
Change originally made by martinvonz in the mercurial repository:
https://phab.mercurial-scm.org/D6400

> I think it makes it a little clearer to have the two conditions for
files==['.'] near each other.

Reviewed By: quark-zju

Differential Revision: D16716745

fbshipit-source-id: c0d4eaf7d0fd7064845984b40d8e558264318d70
2019-08-12 14:34:36 -07:00
Kostia Balytskyi
f4042cad44 remotefilelog: add censorship handling at a filelog level
Summary:
Currently, only contents coming from `getfiles` request can replace
`BLACKLISTED_CONTENT` with `BLACKLISTED_MESSAGE`, because this is implemented
in `basestore.py`. Let us add an additional piace of logic to the
`remotefilelog.revision`, which would handle this the same way.

Note: this diff does not remove the old implementation. I think we need to do
this, but I want to focus on solving immediate problem, which is the absense
of support for censored results in `getpackv1`/`getpackv2`, before I fix the
tech debt. Note also that current doubling of the replacement logic does not hurt,
since it can't apply twice.

Reviewed By: xavierd

Differential Revision: D16735899

fbshipit-source-id: f10b72997614c58432476bcf95a3bde774bc278e
2019-08-12 08:04:58 -07:00
Aleksei Kulikov
98ae814cd0 snapshot: add merge/rebase data to snapshot
Summary:
This diff adds handling of mergestate and rebasestate -related data from the `.hg` directory.
That is the whole `.hg/merge` folder (both for merge and rebase state) and the `.hg/rebasestate` file.

We do not store any other information in lfs (e.g. number of parents for merge state).
Snapshot manifest oid will be added as an extra field to a fake snapshot commit, which will contain such data.

Differential Revision: D16708733

fbshipit-source-id: efc9b72b7593d85063307528c713c363e061065b
2019-08-12 03:51:58 -07:00
Jun Wu
98086c8f4d treemanifest: fix a null pointer undefined behavior
Summary:
`path.next(&word, &wordlen)` might choose to do nothing if `path.isfinished()`
is already true. In that case, null pointer `word` would be passed to callback
functions and that breaks UBSAN:

  scm/hg/edenscm/hgext/extlib/ctreemanifest/manifest.cpp:84:23: runtime error: null pointer passed as argument 1, which is declared to never be null
  glibc/include/string.h:140:33: note: nonnull attribute specified here
      #0 0x7f7068badb26 in Manifest::findChild(char const*, unsigned long, FindResultType, bool*) scm/hg/edenscm/hgext/extlib/ctreemanifest/manifest.cpp:84
      #1 0x7f7068bc07cb in get_callback(Manifest*, char const*, unsigned long, FindContext*, ManifestPtr*) scm/hg/edenscm/hgext/extlib/ctreemanifest/treemanifest.cpp:315
      #2 0x7f7068bbdbce in treemanifest::find(ManifestEntry*, PathIterator&, FindMode, FindContext*, FindResult (*)(Manifest*, char const*, unsigned long, FindContext*, ManifestPtr*), ManifestPtr*) scm/hg/edenscm/hgext/extlib/ctreemanifest/treemanifest.cpp:218
      #3 0x7f7068bbfd4b in treemanifest::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const**, FindResultType, ManifestPtr*) scm/hg/edenscm/hgext/extlib/ctreemanifest/treemanifest.cpp:355
      #4 0x7f7068c1e8bb in treemanifest_contains(py_treemanifest*, _object*) scm/hg/edenscm/hgext/extlib/cstore/py-treemanifest.h:1400
      #5 0x7f707746ba7e in PyEval_EvalFrameEx (libpython2.7.so.1.0+0x108a7e)
      ....

This unblocks D16716742.

Reviewed By: singhsrb

Differential Revision: D16750880

fbshipit-source-id: f0afe19f98b97660698b2cb90f24a0243f1e728f
2019-08-09 20:59:52 -07:00
Arun Kulshreshtha
73e1fc5143 remotefilelog: return after HTTP file fetch
Summary: We were accidentally double-fetching data over both HTTP and SSH due to a missing return statement in the HTTP path. Fix it so that we only fetch data once. (The return was originally there, but was accidentally removed as part of a refactor.)

Reviewed By: xavierd

Differential Revision: D16745110

fbshipit-source-id: e06f129d39dec3801a32f90257367266006bb1cc
2019-08-09 16:37:12 -07:00
Jun Wu
0cced641f0 statichttprepo: remove statichttprepo
Summary:
We don't use statichttprepo. Remove it so future changelog changes won't need
to take it into consideration.

Reviewed By: markbt

Differential Revision: D16683789

fbshipit-source-id: de4f486e8eb6d372acfab5053769f7ad91c12db8
2019-08-09 16:17:54 -07:00
Jun Wu
168402664c unionrepo: remove unionrepo
Summary:
We don't use unionrepo. Remove it so future changelog changes won't need to
take it into consideration.

Reviewed By: markbt

Differential Revision: D16683788

fbshipit-source-id: bfc474d51d957959a6266e9c8eceda3c11d3cf0d
2019-08-09 16:17:54 -07:00
Jun Wu
152ad871d6 bindings: expose more methods from the dag crate
Summary:
The only way to operate on millions of commits as input, is to use ids instead
of nodes. Therefore all APIs are changed to take ids / spans, APIs taking
nodes are removed. They can be built easily from the Python world using the
`id2node`, `node2id` translation API.

Reviewed By: sfilipco

Differential Revision: D16675902

fbshipit-source-id: 461e75114c922cb5f6cb344ee2fd1cd5a966da78
2019-08-09 16:17:54 -07:00
Jun Wu
f7b6df74f9 bindings: add a wrapper type of SpanSet
Summary:
This exposes the raw `SpanSet` struct to the Python land, and provides glues to
use them in Rust code.

Reviewed By: sfilipco

Differential Revision: D16675904

fbshipit-source-id: e4147cbe20344f7ced65d556a8def6ea354714d2
2019-08-09 16:17:53 -07:00
Jun Wu
217c236090 dag: make ancestor APIs take a set
Summary:
Previously, `ancestors` only takes a single id, `gca_one` and `gca_all` only
take 2 ids. Extend them to accept a set. This is more consistent with the rest
of the APIs, ex. `heads` and `parents`.

Reviewed By: markbt, sfilipco

Differential Revision: D16672417

fbshipit-source-id: 98297486cb01215479e0e16f2189cf3053d60a1d
2019-08-09 16:17:53 -07:00
Jun Wu
0099d73ea1 dag: add more ancestor-related operations
Summary:
The existing hg APIs support things like getting all the gcas, and testing
"isancestor" without calcuating the gca. Implement them in the dag crate to
match those features.

I picked `gca` to make names shorter. Here is a list of how those features
get named in two codebases:

  Name in hg codebase  | Name in this crate
  -----------------------------------------
  ancestor             | gca_one
  commonancestorsheads | gca_all
  isancestor           | is_ancestor
  ancestors            | ancestors

Reviewed By: markbt, sfilipco

Differential Revision: D16672420

fbshipit-source-id: d205d7970623e992e656ae300218239cddbd26c8
2019-08-09 16:17:51 -07:00
Jun Wu
330516f923 dagparser: add a binary dag serialization format
Summary:
The binary format allows us to checkin a large repo's dag and use it for
testing. The format is designed to be compat and easy for machine parsing.

`hg debugbindag` was added to generate such format from an existing repo,
and `hg debugpreviewbindag` was added to preview such binary format.

Size of serialized DAGs:

  repo     | method      | size (KB) | size (KB), zstd -19
  --------------------------------------------------------
  mozilla  | debugbindag |    101    |    66
           | debugdag    |    193    |    72
           | changelog.i | 213925    | 80118
  --------------------------------------------------------
  fbsource | debugbindag |   1400    |   700
           | debugdag    |    n/a *  |   n/a
  --------------------------------------------------------
  www      | debugbindag |    5.6    |   3.2
           | debugdag    |    n/a    |   n/a

Note:
`hg debugdag` and `hg debugbuilddag` exist, and they compress
relatively well. However, they have some (critical) issues:

- crashes on fbsource and www (*)
- complex syntax
- does not support selecting a subset of revs (ex. "::master")

Therefore I decided to invent something new.

Reviewed By: sfilipco

Differential Revision: D16294467

fbshipit-source-id: 754ab8942359ef73f5f53c427c7d38d94641fa75
2019-08-09 16:17:49 -07:00
Saurabh Singh
437c059dc6 phabricator: handle AttributeError while parsing graphql query
Summary:
We have can have situations where the parsing is broken because we are
parsing an attribute that does not exist. See T48658402 for an example.

Reviewed By: kulshrax

Differential Revision: D16745842

fbshipit-source-id: f693bc5aca29923b074a789b952e24b5ce72cdfd
2019-08-09 15:31:17 -07:00
Xavier Deguillard
1976706de3 bindings: remove PythonMutableHistoryPack
Summary:
This was used as a way to transition towards Rust only mutable history store.
Now that the transition is over, let's remove the wrapper.

Reviewed By: quark-zju

Differential Revision: D16726163

fbshipit-source-id: d745cc1c04279b8603b072c36fa406d27f014628
2019-08-09 10:19:20 -07:00
Xavier Deguillard
e4edebe5a6 bindings: remove PythonMutableDataPack
Summary:
This was used as a way to migrate away from a Python based mutable datapack.
Now that every write is done in Rust, we can get rid of this.

Reviewed By: quark-zju

Differential Revision: D16726161

fbshipit-source-id: d13277979eb575aee6dcaac09c0a05c22ca1b1a1
2019-08-09 10:19:20 -07:00
Xavier Deguillard
405ca2d5e8 bindings: remove datastore
Summary:
This class can be used to use a Python store in Python but going through Rust.
We don't need this use case, so let's get rid of it.

Reviewed By: quark-zju

Differential Revision: D16726162

fbshipit-source-id: a0121bf61b178447ad958e2907185e97962046ee
2019-08-09 10:19:19 -07:00
Jun Wu
645d40b4a0 cliparser: move flags state from Parser to ParseOptions
Summary:
This makes `ParseOptions` own all information to do a parse so parsing can be
done without creating a `Parser` struct:

    ParseOptions::new().flags(flags).parse_args(args)

`Parser::with_parsing_options` is removed since that will overwrite `flags`.
Some `unwrap()`s in the bindings are replaced with proper error handling.

In the future it might make sense to make `Parser` or `Parser::new` private.

Reviewed By: farnz

Differential Revision: D16703009

fbshipit-source-id: 6119c29d934ae4410b31d906397a902c03e27fe2
2019-08-08 22:54:06 -07:00
Jun Wu
bd5b7790ad bindings: remove FlagDefinition use
Summary: Use `Flag::from` or `tuple::into` to build `Flag`s directly.

Reviewed By: farnz

Differential Revision: D16700309

fbshipit-source-id: 83f10a365197809af2881711bd1df8a663c2afe4
2019-08-08 22:54:05 -07:00
Jun Wu
95bdf77f67 cliparser: move hgflags to clidispatch
Summary:
The "global flags" concept is more coupled with the "hg dispatch" logic.
The "cliparser" crate can stay pure from application-specific flags.

As we're here, update the global flags definition to use `Into::into`,
and return `Vec<Flag>` directly, instead of `Vec<FlagDefinition>`.
That removes one usecase of `FlagDefinition`.

Reviewed By: farnz

Differential Revision: D16700307

fbshipit-source-id: 2688cb06272a249454d92d7d7d5a0b1100805dbd
2019-08-08 22:54:04 -07:00
Jun Wu
57da9728ba cliparser: make Parser::new consume Vec<Flag>
Summary:
This helps removing references. The internal structure of `Parser` is changed a
bit to avoid storing `Flag` copies.

Reviewed By: farnz

Differential Revision: D16700316

fbshipit-source-id: 01d66feb8bd5cc2fa9394b3635f97e098143597d
2019-08-08 22:54:03 -07:00
Jun Wu
f8fdd156a2 cliparser: rename OpenOptions to ParseOptions
Summary: The options decides how the parser works. It is not opening anything.

Reviewed By: farnz

Differential Revision: D16700310

fbshipit-source-id: c0ab69f9d8c50664dc157ef0eb0f12ee1533e81d
2019-08-08 22:54:01 -07:00
Shu-Ting Tseng
f26bbc7e98 fix hg svn info
Summary:
The logic is currently a bit broken in a weird combination:

The current configurations are
- usefirstpublicancestorinsvninfo=False
- useglobalrevinsvninfo=True

This means hg will have to traverse back to the last hg commit with svnrev. It will get
[slower and slower](https://fburl.com/scuba/skfj8p7u) to find those commits as we are having more commits without snvrev.

Ideally we can turn `usefirstpublicancestorinsvninfo` to True and that will then only traverse back to the last public ancestor. However it will trigger another bug because this public ancestor won't be in the old svn revmap and therefore hg will just bail with "Not a child of an svn revision".

Therefore the fix is to fix that bug by moving the `if pn not in hashes:` into the else part of the config and also get the subdir value from config rather than from the `extras['convert_info']`.

The next step is to set
- usefirstpublicancestorinsvninfo=True
- useglobalrevinsvninfo=True
- usereposubdirinsvninfo=True
once this diff is deployed to stable.

Reviewed By: DurhamG

Differential Revision: D16717554

fbshipit-source-id: c05b9882aa9ddeeeefd9315b478ba085fbc9bae7
2019-08-08 14:19:03 -07:00
Aleksei Kulikov
1bb26d4ad2 snapshot: refactor extension code
Summary:
Created some classes and refactored the code.
Now it looks better. :)

Reviewed By: markbt

Differential Revision: D16690240

fbshipit-source-id: f26127d55c5cace7b88e225c85ec13cc278150c8
2019-08-08 04:13:39 -07:00
Aleksei Kulikov
6b7127c966 snapshot: add debug command to checkout on snapshot manifest
Summary:
It would really help to be able to checkout the manifests, restoring all the data from them.
Deleting the missing files, creating the unknown files, adding mergestate info to svfs (not available yet :) ).

Reviewed By: mitrandir77

Differential Revision: D16668312

fbshipit-source-id: 62af8a1fb11541c162f7b5ceb8d6d058cad9a319
2019-08-08 04:13:38 -07:00
Mark Thomas
6a6c0fea7a commitcloud: add automigrate to automatically connect to commitcloud
Summary:
Add automigrate to commitcloud, which will automatically connect the user's
repo to commit cloud on pull.

Reviewed By: mitrandir77

Differential Revision: D16666810

fbshipit-source-id: a1d0857164d2ce6bf1db5784360681f04d35ed90
2019-08-08 03:09:24 -07:00
Mark Thomas
2e3cda1ade commitcloud: cloud leave should always clear the workspace name
Summary:
Running `hg cloud leave` on a repo that was never connected should mark the
repo as explicitly disconnected so that automatic joining will not try to
connect the repo later on.

Reviewed By: quark-zju

Differential Revision: D16687470

fbshipit-source-id: 0552ffa42a1dac40874bba30eeb93509a2227aeb
2019-08-08 03:09:24 -07:00
Mark Thomas
0c6db94ffb commitcloud: simplify subscription manager
Summary:
The `SubscriptionManager` is never a long-lived object, and cannot be
constructed if the user is not connected to a workspace.  Simplify this to
function calls, which are safe to call at all times.

Reviewed By: quark-zju

Differential Revision: D16687467

fbshipit-source-id: c7f81290a3e8012f7b154af3398771ac9254387f
2019-08-08 03:09:24 -07:00
Mark Thomas
be096ab1c6 commitcloud: make cloud rejoin always join if possible
Summary:
`hg cloud rejoin` limits joining to when the user has an authentication token
and the workspace already exists.  If the user uses a different authentication
method, or if the workspace is brand new, the rejoin does nothing.

Change this to always attempting to join, and only printing a message if the
join failed because of an authentication error, prompting the user to authenticate.

Reviewed By: mitrandir77

Differential Revision: D16666365

fbshipit-source-id: 3ea4542125a1b5266711fab2c31d9455ab764cef
2019-08-08 03:09:23 -07:00
Mark Thomas
80819cbf5b debugexistingcasecollisions: add command to check for existing case collisions
Summary:
Add a new command `hg debugexistingcasecollisions` which checks if any
directories contains two or more entries which may have the same filename on
case-insensitive filesystem.

Reviewed By: suitingtseng

Differential Revision: D16687557

fbshipit-source-id: cb032467e9b8a73fc1f6bf107387bc54c223c2ba
2019-08-08 03:01:44 -07:00
Arun Kulshreshtha
18d9581d7e treemanifest: add single-node lazy HTTP tree fetching
Summary:
When `treemanifest.usehttp` is enabled, make `remotetreestore` fetch tree nodes over HTTP rather than SSH.

Note that unlike the SSH prefetch operation, this downloads only a single tree node, which will change the I/O behavior of Mercurial to fetch manifest nodes on demand. In general, this will result in excessive round trips, but for certain commands (such as `hg cat`), this works reasonably well.

Future diffs will expand upon this functionality to make the HTTP behavior more performant. For now, this won't affect anyone unless they specifically enable the aforementioned config option.

Reviewed By: xavierd

Differential Revision: D16663197

fbshipit-source-id: 4117e057996ed30f0bfd186238264e31484c2620
2019-08-07 19:09:46 -07:00
Aleksei Kulikov
cf0570d74a snapshot: add a command to upload snapshot manifest to remote lfs
Summary:
Add the `debuguploadsnapshotmanifest oid` command.

It checks that the local lfs has `oid`, then uploads it and all the related blobs to remote lfs.

Differential Revision: D16667158

fbshipit-source-id: 2978a6c0e7c58c3710f8253cf7b9ab36b24886ce
2019-08-07 05:57:45 -07:00
Arun Kulshreshtha
7302c42b77 remotefilelog: start HTTP file fetching progress bars at 0
Summary:
Previously, we would use `None` as the start value for HTTP data fetching progress bars so that the bar would be rendered as a spinner until we received a response (which would contain a content size header, allowing us to set the progress bar total).

This would result in incorrect behavior if the server took a long time to return a response, because by default if no start value is provided the progress bar framework will display the number of seconds that have elapsed. Given that we've specified a byte count format function for the progress value, the progress bar would end up displaying the number of seconds elapsed as a byte count, which was very confusing.

Reviewed By: quark-zju

Differential Revision: D16663124

fbshipit-source-id: 0e224b3b670abc803356214cd12205a6f4259cd9
2019-08-06 17:14:58 -07:00
Stefan Filip
5bc614c767 bindings: add finalize implementation for tree manifests
Summary: Matching more of the existing API.

Reviewed By: quark-zju

Differential Revision: D16607233

fbshipit-source-id: 7a71f22089067ecfccbfcb2ad072fbf21e360439
2019-08-06 14:24:31 -07:00
Arun Kulshreshtha
8ba2df04d9 treemanifest: remove bulky HTTP prefetch
Summary:
The initial attempt at supporting tree fetching over HTTP involved reimplementing the existing Mercurial prefetch functionality (corresponding to the gettreepack wireproto command) in the API server. Unfortunately, while this worked from a functionality perspective, it was far too slow to be usable in practice.

Rather than maintaining this unused code path, let's remove it and repurpose the config flag for a more sensible version of HTTP tree fetching.

Reviewed By: farnz

Differential Revision: D16663198

fbshipit-source-id: a489d5ca177b788f93383b8a9f758316e889ca5b
2019-08-06 11:40:05 -07:00
Stefan Filip
b420018e1d bindings: update treemanifest.find to throw KeyError on missing path
Summary:
Interesting enough find is expected to throw on missing path.
The funny part is that the documentation in the C++ code says that the find
method will return a tuple of (None, None) in this case. The code then goes
to throw an exception for not found.

Reviewed By: xavierd

Differential Revision: D16610709

fbshipit-source-id: a22fa6e69361bf6f501f7171e492ba7a6515a2ea
2019-08-06 10:43:02 -07:00
Stefan Filip
3b10ae5743 bindings: add support for del manifest[file]
Summary: Supporting deletions using the `del` python syntax.

Reviewed By: quark-zju

Differential Revision: D16610502

fbshipit-source-id: 7069f71a0f2e6cfdc3c6cd8f5b7b4f4946e4a764
2019-08-06 10:43:02 -07:00
Stefan Filip
4b8e8cc843 bindings: add treemanifest::hasdir
Summary: This function verifies if the manifest contains a specific directory.

Reviewed By: quark-zju

Differential Revision: D16610338

fbshipit-source-id: 7d81b3471d6098ae2baa89f626f20a955c912252
2019-08-06 10:43:01 -07:00
Stefan Filip
2cb92f487b manifest: update manifest::get to return optional enum
Summary:
This allows us to say that the queried path was a directory and simplifies
the API a little bit.

The Python/C++ Manifest API provide inspection of directories through several
functions. We want the Rust manifest to provide the same functionality.
This approach looks to have more consistency as the API evolves.

`FsNode` is a structure that is forward looking. We will want to add an API
that lists a directory and an interator of FsNode fits that well.
I also felt the need for it over the development of the manifest code.

Reviewed By: quark-zju

Differential Revision: D16609253

fbshipit-source-id: f826d7b21e3001f4bef43a35b9d1a9bc5a59eda9
2019-08-06 10:43:01 -07:00
Xavier Deguillard
9937459abe remotefilelog: remove old files in the hgcache that aren't packfiles
Summary:
The hgcache packs directory is being written to in several places, most of the
files being created there are temporary ones and renamed once ready to be
visible. In some cases, when hg crashes midway, or when the packfile is mmap'ed
on windows, temporary files are left around.

While we were trying to remove these files before, the solution taken involved
removing files we knew were safe to be removed. Unfortunately, that meant we
missed some of the temporary files. Let's instead switch to removing everything
but packfiles and the repacklock.

Reviewed By: kulshrax

Differential Revision: D16657105

fbshipit-source-id: f4dd45aa71c02acba52a745b9bec3019d20e03c4
2019-08-06 10:34:27 -07:00
Mark Thomas
bafa640cde unhide: improve performance of unhide revset
Summary:
Add `not public()` to the unhide revset to improve its performance.  We can't
unhide public commits anyway, as they can't be hidden.

Reviewed By: mitrandir77

Differential Revision: D16645983

fbshipit-source-id: f9f23e7e31050e652f1389489734416fe3278219
2019-08-06 09:52:02 -07:00
Aleksei Kulikov
cbf11e8ca8 snapshot: add command debugcreatesnapshotmanifest
Summary:
Add a self-descriptive command `debugcreatesnapshotmanifest`.
For now it supports only deleted and unknown files.

1) Uploads all the untracked files to the local lfs storage.
2) Creates a json-like snapshot with the following structure:
```
{
  "deleted": {
    "path/to/file": None, # this is done for consistency
    "path/to/another/file": None
  },
  "unknown": {
    "added": {
        "oid": "oid in local blobstore",
        "size": 42
    }
    "another/added": {
        "oid": "another oid in local blobstore",
        "size": 24
    }
  }
}
```
...and stores it in the local blobstore.

Reviewed By: markbt

Differential Revision: D16621864

fbshipit-source-id: 6c497d1bb756561b3c3368483b838a2307b0b5f9
2019-08-05 11:10:17 -07:00
Jorge Lopez Silva
a1fd50cc9b Upgrade smc/hg to cpython/python-sys 0.3
Summary: Bump cpython and python27-sys to 0.3.

Reviewed By: quark-zju

Differential Revision: D16634957

fbshipit-source-id: 9f6b45baf8098399109ad03bf440da42f4483fcb
2019-08-05 09:56:45 -07:00
Shu-Ting Tseng
bbc6d19715 use manifest lookup to speed up operations
Summary:
The original code path is extremely slow because it has to iterate all files in manifest.
The new path instead only has to lookup the entries in keptdirs and therefore is O(change).

Reviewed By: mitrandir77

Differential Revision: D16646075

fbshipit-source-id: cb2c152d236ffa6f01349c223c9470205c540379
2019-08-05 05:22:40 -07:00
Johan Schuijt-Li
77f0d3fd04 lfs: rewind fp on retries
Summary:
To avoid the scenario where we are incorrectly uploading the data that we're
supposed to upload, we need to reset the file pointer to read from the
beginning so that for each retry of uploading we get the correct data.

Previously before this patch, Mercurial would have nothing to upload on a retry
and the connection would 'hang' waiting for the data to be send to the server.

Reviewed By: krallin

Differential Revision: D16620072

fbshipit-source-id: 2238b99ff612e06dc0640717bc42fe345c35037d
2019-08-02 05:15:57 -07:00
Johan Schuijt-Li
c350d6536d lfs/http keepalive: fix broken uploads on retry
Summary:
The KeepAlive HTTP implementation is bugged in it’s retry logic, it supports reading from a file pointer, but doesn’t support rewinding of the seek cursor when it performa a retry. So it can happen that an upload fails for whatever reason and will then ‘hang’ on the retry event.

The sequence of events that get triggered are:
 - Upload file A, goes OK. Keep-Alive caches connection.
 - Upload file B, fails due to (for example) failing Keep-Alive, but LFS file pointer has
   been consumed for the upload and fd has been closed.
 - Retry for file B starts, sets the Content-Length properly to the expected file size, but since file pointer has been consumed no data will be uploaded, causing the server to wait for the uploaded data until either client or server reaches a timeout, making it seem as our mercurial process hangs.

This is just a stop-gap measure to prevent this behavior from blocking Mercurial (LFS has retry logic). A proper solutions need to be build on top of this stop-gap measure: for upload from file pointers, we should support fseek() on the interface,
Since we expect to consume the whole file always anyways, this should bafe. This way we can seek back to the beginning on a retry.

Reviewed By: quark-zju

Differential Revision: D16604844

fbshipit-source-id: 9a0d418f00520bda499272b864ff24c99e888aa2
2019-08-02 02:41:02 -07:00
Jun Wu
30dfd6217b bindings: add bindings to stackdesc
Summary:
This exposes the stackdesc feature to Python. The API is polished to use Python
decorators.

Reviewed By: sfilipco

Differential Revision: D16023307

fbshipit-source-id: edcee59e77e7fe55cdb52d031a4fa3e483909ea0
2019-08-01 19:53:56 -07:00
Arun Kulshreshtha
0f9f07b6a1 remotefilelog: make HTTP retries configurable
Summary: Make the number of retries for HTTP operations configurable. Previously, they were hardcoded to 3, which may not be ideal in situations where the retries are caused by server side timeouts. (If a single timeout takes 30 seconds it would take 90 seconds to fall back to SSH.)

Reviewed By: quark-zju

Differential Revision: D16592862

fbshipit-source-id: a9ba5273a1271532ff9814bcc47cb32e60ee87b7
2019-08-01 12:54:35 -07:00
Stefan Filip
71bff70aea manifest: rename filesnotin argument from match to matcher
Summary:
Similar to diff, the `match` argument can't be easily expressed using CPython
crate bindings. This argument is not used a lot so we can rename it.

Reviewed By: quark-zju

Differential Revision: D16571840

fbshipit-source-id: 19c7dea82924b7ec4c0b66d1675b9ad4569f8b62
2019-08-01 10:35:53 -07:00
Stefan Filip
962e921589 manifest: bindings for iter, contains, setter, getter, flags, text
Summary:
Various bindings methods.
I started running:
```
./run-tests.py --extra-config-opt="treemanifest.rustmanifest=True"
```
I would see tests complaining about various methods and then I
implemented them and reran the tests. The majority of failures
now are about finalize not being implemented.

Reviewed By: quark-zju

Differential Revision: D16571837

fbshipit-source-id: 58db35d58522dd7d2b5208e0614293ae55a83bf8
2019-08-01 10:35:52 -07:00
Stefan Filip
a585faf2db manifest: update get to return FileMetadata copy
Summary:
There is no good reason to return a reference for FileMetadata. It is a relatively
small object that implements the `Copy` trait so returning a copy is
approapriate.

Reviewed By: quark-zju

Differential Revision: D16571838

fbshipit-source-id: 0c315c9f405e425832d39da5c67809dd15b4ab5e
2019-08-01 10:35:51 -07:00
Stefan Filip
427ad4416e bindings: add diff implementation for rust tree manifest
Summary:
I wasn't sure how to test this. I implemented `diff` then got it to work
with `hg show` by adding the missing methods.

Reviewed By: quark-zju

Differential Revision: D16497354

fbshipit-source-id: 727979ad8ce4a4615e85ea96c3fe6413aa20b267
2019-08-01 10:35:51 -07:00
Jun Wu
d8cb5d12f9 encoding: respect system encoding
Summary:
D16452925 accidentally made HGENCODING the single source of truth of encoding
and always fallback to `ascii` if `HGENCODING` is not set. The correct behavior
is to fallback to system locale setting if `HGENCODING` is not set.

Reviewed By: HarveyHunt

Differential Revision: D16600586

fbshipit-source-id: 83c3518f7a0ca6367191ebc4cd8ba5d8b300800d
2019-08-01 08:43:03 -07:00
Mohammad Ayoub
c3bb7153e0 change cloud sl --version_number to --workspace-version
Summary: Change --version_number flag to --workspace-version

Reviewed By: quark-zju

Differential Revision: D16561670

fbshipit-source-id: 797a7b2fee2c3e260263ae3029d793452def3033
2019-08-01 02:18:05 -07:00
Stefan Filip
71ab0b4b3d manifest: rename match to matcher in diff argument list
Summary:
`match` is a keyword in Rust. This is causing troubles in adding Rust bindings
for functions that use that as a keyword argument. Renaming the argument to
something else seems to be the easiest path forward.

Reviewed By: quark-zju

Differential Revision: D16496134

fbshipit-source-id: c923f49577564527a99d43dda3d3d9da43122b3e
2019-07-31 10:06:48 -07:00
Stefan Filip
5d1f390ca0 manifest: remove the clean argument from diff
Summary:
The diff algorithm takes the `clean` flag. When `clean` is used all the files
that are not changed between the two manifests are returned. In short the set
of files is equal to |files(M1) U files(M2)|.

This functionality would have to be implemented in the Rust manifest. I don't
feel that a flag on the diff algorithm should be used in this case. First, I
don't like how it interacts with the core diff algorithm, it changes it to the
point where it feel like it should be a different function. Second is that this
behavior can be achieved by getting all the files in the manifest and removing
the items in the diff. Third is that this operation is done quite rarely, being
so expensive.

The downside is that the places where this flag is used get a bit more
expensive.

Reviewed By: quark-zju

Differential Revision: D16496136

fbshipit-source-id: 205dcc23517b896de5c14634683bcbd5f2aa6666
2019-07-31 10:06:47 -07:00
Stefan Filip
54c9313950 bindings: add copy function for treemanifest
Summary:
Function returns a new instance of a treemanifest that contains the same data
that the base manifest does.

Reviewed By: quark-zju

Differential Revision: D16496135

fbshipit-source-id: 04f8260278ce6c14bb018a05831ff25f81ab3231
2019-07-31 10:06:47 -07:00
Shu-Ting Tseng
97f4a710b9 don't use revmap to look for ancester in hg svn info
Reviewed By: singhsrb

Differential Revision: D16561866

fbshipit-source-id: 156477a4ecc7bf205158c13e57960a0cf1dc368e
2019-07-31 09:16:23 -07:00
Shu-Ting Tseng
acec61a376 hg svn info should print globalrev
Summary:
This is used by Jellyfish and sent to Phabricator. In the future, we won't have svnrev
and therefore we should use globalrev instead.

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

Reviewed By: singhsrb

Differential Revision: D16561651

fbshipit-source-id: 284ad26b1bf77f222086bb7e2104b1c2dbf65449
2019-07-31 09:16:23 -07:00
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
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
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
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
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
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
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
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
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
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
Jared Bosco
d2b564dcac dispatch: add friendly prefix matching on ambiguous commands
Summary:
Add support for color prefix highlighting when Mercurial encounters an ambiguous command name.  Currently ambiguous commands will print a list of possibilities such as:

```$ hg i
hg: command 'i' is ambiguous:
    id or identify
    import
    in or incoming
    init
    isbackedup
```

Now the prefix, in this case `i` will be highlighted in all possibilities.  This works no matter how long `prefix` is so in the case of `$ hg debug` it will highlight `debug` in all the possible choices.

Reviewed By: quark-zju

Differential Revision: D16451342

fbshipit-source-id: 87f58dd6bd77c2a609e5f423f7c769d444abc66d
2019-07-25 16:17:23 -07:00
George-Catalin Tintareanu
f91262be22 Enum creator
Summary:
Util method to generate Enum, since some machines don't have the
python library installed.

Reviewed By: suitingtseng

Differential Revision: D16491020

fbshipit-source-id: e06470a609605c482f591418583b516918c49d93
2019-07-25 07:24:36 -07:00
Jun Wu
6cd7d1799c encoding: add a way to change HGENCODING at runtime
Summary:
Make it possible to change the internal state of HGENCODING so we can run hg
logic within a single process without shelling out in the new dott test
framework.

Update testutil/dott to use it.

Reviewed By: xavierd

Differential Revision: D16452925

fbshipit-source-id: d21329854eeee171cc5d02d4f42f11dd273f2150
2019-07-24 14:32:23 -07:00
Xavier Deguillard
9b21206b39 remotefilelog: remove python mutablehistorypack
Summary: There no users left, let's get rid of it.

Reviewed By: kulshrax

Differential Revision: D16423137

fbshipit-source-id: 6898e681f800ab677010d7b6cdd36d377e3ef644
2019-07-24 10:34:32 -07:00
Xavier Deguillard
10a59c9b75 remotefilelog: remove python mutablehistorypack from mutablestore
Summary: The Rust code is the default.

Reviewed By: kulshrax

Differential Revision: D16423134

fbshipit-source-id: 30baf041a5e7c786a28b31cfe5025e893b34594c
2019-07-24 10:34:32 -07:00
Xavier Deguillard
e86e388661 remotefilelog: remove python mutabledatapack code
Summary: Goodbye.

Reviewed By: kulshrax

Differential Revision: D16392290

fbshipit-source-id: 541b945e274f097b722b5e79ca03e104c4cfd6a0
2019-07-24 10:34:31 -07:00
Xavier Deguillard
bd88a79858 remotefilelog: remove python mutabledatapack reference from mutablestores
Summary:
The Rust code is now always taken, let's start removing all the references to
the python mutabledatapack code.

Reviewed By: kulshrax

Differential Revision: D16392287

fbshipit-source-id: dfccd4f4ec052a46975b6f9144106b51c3282988
2019-07-24 10:34:30 -07:00
Xavier Deguillard
334e0c0c2e remotefilelog: the rust mutable stores are the default
Summary: This is now enabled for the entire fleet, let's hardcode this in the code now.

Reviewed By: kulshrax

Differential Revision: D16392289

fbshipit-source-id: 462152ded12d00cf8218526d51a911d6fe5975ca
2019-07-24 10:34:30 -07:00
George-Catalin Tintareanu
15f36ceede hg client handler for blacklisted files
Summary: Checks if the retrieved content of a file is equal to a `magic string` representing a blacklisted file. If so, then the content is replaced by a readable text which suggests a `rebase` or `update` to a newer commit.

Reviewed By: ikostia

Differential Revision: D16260011

fbshipit-source-id: ac1d40132b9c947927271d8e6efda98b19dce984
2019-07-24 03:41:20 -07:00
Arun Kulshreshtha
a491bb06ea remotefilelog: only print debug messages during interactive usage
Summary: The debug messages from Eden API provide Source Control team members with useful diagnostic information about HTTP data fetching, but they have the potential to be spammy when written to log files. To prevent log spam, let's only print these messages during interactive usage.

Reviewed By: quark-zju

Differential Revision: D16445346

fbshipit-source-id: 001dc75e440eaf797f4f953648453086421f624e
2019-07-23 15:13:59 -07:00
Zeyi (Rice) Fan
a62bf843cf Back out "RFC: hg: make zsh completion to return list of draft commits"
Summary:
Original commit changeset: 3493895a12ae

This is breaking `arc pull` in fbsource S183062

 #commitClose

Reviewed By: mitrandir77, singhsrb, xavierd

Differential Revision: D16441944

fbshipit-source-id: fd3f5c7027be1468bd8194e6b24dd136b9b767d2
2019-07-23 13:07:14 -07:00
Xavier Deguillard
7478874389 remotefilelog: remove maintenance repack memcache fetch
Summary:
When using fetchpacks, memcache will write to an indexedlog, which can't be
repacked. I'm also suspecting that there is a race between this repack, and
hg_memcache_client opening the newly created packfiles which can cause the
misses to not be sent to memcache.

Reviewed By: kulshrax

Differential Revision: D16432538

fbshipit-source-id: 62362682474883bcd58249791c02b9fed5cb8fea
2019-07-22 22:31:38 -07:00
Shu-Ting Tseng
5c49bedd8b add a trailing newline when committing to svn
Summary:
By adding a newline, we can ensure the meta message is always on its own line.

This is to address the comment in D16340374.

link to comment: https://our.intern.facebook.com/intern/diff/D16340374/?transaction_id=732272950561759&src_number=86745022

Reviewed By: quark-zju

Differential Revision: D16417344

fbshipit-source-id: caaae1748018bbe5ddbb587adacd45b8709da8cc
2019-07-22 14:06:12 -07:00
Stefan Filip
7c511ba610 manifest: add matcher filtering to the files iterator
Summary:
Most operations do not work on iterate on all the files of the repository.
Most operations filter the data set in some way. In many cases this filtering
is to a set of files and in some cases using patterns or subdirectories.

The Python code uses `match.py` to represent this filtering. The parallel
data structure in the rust code is `pathmatcher::Matcher`.

This diff adds `files` integration with `pathmatcher::Matcher`.

Reviewed By: quark-zju

Differential Revision: D16352527

fbshipit-source-id: 8b61ac7399f581773bf61ff648634cbc6e1a27b6
2019-07-22 13:03:02 -07:00
Stefan Filip
3bb2fa1efb bindings: add Macher implementation for PyObj
Summary:
This allows us to use python matcher objects in rust. Particularly we are
looking at using these in the manifest implementation for filtering the
file set that is returned.

Reviewed By: quark-zju

Differential Revision: D16352533

fbshipit-source-id: fd6bde6d9223203c69593d5e8830946170363243
2019-07-22 13:03:01 -07:00
Stefan Filip
cb57f5d7ac bindings: add manifest python classes
Summary: Bindings so that the rust manifest code can be used in Python.

Reviewed By: quark-zju

Differential Revision: D16352532

fbshipit-source-id: 34d4522f5e084f531f31bcd21770950f15f2fe13
2019-07-22 13:03:00 -07:00
Stefan Filip
69b604e3ec pyrevisionstore: remove unsafe impl Send for PythonDataStore
Summary:
https://doc.rust-lang.org/nomicon/send-and-sync.html
http://dgrunwald.github.io/rust-cpython/doc/cpython/struct.PyObject.html

PyObject implements Send. Because Send is automatically derived when composed
of structures that are Send, PythonDataStore is Send. Similarly
PythonMutableDataPack is Send without the explicit marker.

Reviewed By: xavierd

Differential Revision: D16352526

fbshipit-source-id: cbf9305fcc369716cafcc8adfdf35fd0a9e1fddc
2019-07-22 13:02:59 -07:00
Stefan Filip
a1a75d5d73 tremanifest: rename tree holding variable to _tree
Summary: Minor rename

Reviewed By: quark-zju

Differential Revision: D16352529

fbshipit-source-id: 658f9843041d858e1471c07554b5715db011d17c
2019-07-22 13:02:58 -07:00
Jared Bosco
089e77642a dispatch: replace final fancyopts call with native rust
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
2019-07-20 01:06:35 -07:00
Jared Bosco
f56b7f2a62 cliparser: add more robust error handling for parsing failure cases
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
2019-07-20 01:06:35 -07:00
Jared Bosco
93949f4629 dispatch: replace alias expansion and fancyopts parsing call with native rust
Summary:
Replace the second to last fancyopts call with pure rust code parsing and error handling.

Make slightly nicer help messages for ambiguous commands instead of just saying every possible command possible.

Reviewed By: quark-zju

Differential Revision: D16063049

fbshipit-source-id: bfd9e58649b1de2d3485069ce8d5646927bc77f4
2019-07-20 01:06:34 -07:00
Jared Bosco
252931cc73 bindings: expose native alias expansion to the python world
Summary: Expose the alias expansion native rust code to the Python code to be able to utilize the earlier alias expansion as well as custom Rust errors.

Reviewed By: quark-zju

Differential Revision: D16063040

fbshipit-source-id: 58cd8c9f16e07687545ebf19332b32fce8db278d
2019-07-20 01:06:34 -07:00
Jared Bosco
5f02e5cd5c dispatch: replace _parse's call to fancyopts with native code
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
2019-07-20 01:06:33 -07:00
Jared Bosco
3c30d27350 copytrace: remove copytrace flag from mutating global options table
Summary:
Copytrace modified the global definitions table which was making it very difficult to keep track of side-effects as the code was executed, as well as making it harder to replace the fancyopts calls with native Rust.

Since the copytrace behavior can be achieved through a configuration, it now will no longer modify the global definitions table, and will display the correct flag for a user to use in order to get this same behavior.

Reviewed By: quark-zju

Differential Revision: D15902449

fbshipit-source-id: 1c254162d56823e65085b7047bb37513f187b487
2019-07-20 01:06:33 -07:00
Jared Bosco
40ca990aac dispatch: replace a fancyopts call with native code
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
2019-07-20 01:06:33 -07:00
Jared Bosco
ee1fcc3d2d bindings: create cliparser native binding to replace fancyopts early parsing
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
2019-07-20 01:06:32 -07:00
Jared Bosco
95b0be5bdc dispatch: remove strictflags and related tests
Reviewed By: quark-zju

Differential Revision: D15833690

fbshipit-source-id: 3469d8def660b116c0f82c674a19f06b18f29211
2019-07-20 01:06:32 -07:00
Xavier Deguillard
8f47102275 fixcorrupt: fix debugfixcorrupt on treeonly repos
Summary:
Treeonly repos doesn't use revlogs, and thus debugfixcorrupt shouldn't try to
fix them.

Reviewed By: quark-zju

Differential Revision: D16373142

fbshipit-source-id: 6517b9516358223bfb6c646fd22aaa99c26b0372
2019-07-19 20:15:36 -07:00