Show More
@@ -1,84 +1,84 b'' | |||
|
1 | 1 | =================== |
|
2 | 2 | Mercurial Rust Code |
|
3 | 3 | =================== |
|
4 | 4 | |
|
5 | 5 | This directory contains various Rust code for the Mercurial project. |
|
6 | 6 | Rust is not required to use (or build) Mercurial, but using it |
|
7 | 7 | improves performance in some areas. |
|
8 | 8 | |
|
9 | 9 | There are currently three independent rust projects: |
|
10 | 10 | - chg. An implementation of chg, in rust instead of C. |
|
11 | - hgcli. A experiment for starting hg in rust rather than in python, | |
|
12 | by linking with the python runtime. Probably meant to be replaced by | |
|
13 | PyOxidizer at some point. | |
|
11 | - hgcli. A project that provide a (mostly) self-contained "hg" binary, | |
|
12 | for ease of deployment and a bit of speed, using PyOxidizer. See | |
|
13 | hgcli/README.md. | |
|
14 | 14 | - hg-core (and hg-cpython): implementation of some |
|
15 | 15 | functionality of mercurial in rust, e.g. ancestry computations in |
|
16 | 16 | revision graphs, status or pull discovery. The top-level ``Cargo.toml`` file |
|
17 | 17 | defines a workspace containing these crates. |
|
18 | 18 | |
|
19 | 19 | Using Rust code |
|
20 | 20 | =============== |
|
21 | 21 | |
|
22 | 22 | Local use (you need to clean previous build artifacts if you have |
|
23 | 23 | built without rust previously):: |
|
24 | 24 | |
|
25 | 25 | $ make PURE=--rust local # to use ./hg |
|
26 | 26 | $ ./tests/run-tests.py --rust # to run all tests |
|
27 | 27 | $ ./hg debuginstall | grep -i rust # to validate rust is in use |
|
28 | 28 | checking Rust extensions (installed) |
|
29 | 29 | checking module policy (rust+c-allow) |
|
30 | 30 | |
|
31 | 31 | If the environment variable ``HGWITHRUSTEXT=cpython`` is set, the Rust |
|
32 | 32 | extension will be used by default unless ``--no-rust``. |
|
33 | 33 | |
|
34 | 34 | One day we may use this environment variable to switch to new experimental |
|
35 | 35 | binding crates like a hypothetical ``HGWITHRUSTEXT=hpy``. |
|
36 | 36 | |
|
37 | 37 | Developing Rust |
|
38 | 38 | =============== |
|
39 | 39 | |
|
40 | 40 | The current version of Rust in use is ``1.34.2``, because it's what Debian |
|
41 | 41 | stable has. You can use ``rustup override set 1.34.2`` at the root of the repo |
|
42 | 42 | to make it easier on you. |
|
43 | 43 | |
|
44 | 44 | Go to the ``hg-cpython`` folder:: |
|
45 | 45 | |
|
46 | 46 | $ cd rust/hg-cpython |
|
47 | 47 | |
|
48 | 48 | Or, only the ``hg-core`` folder. Be careful not to break compatibility:: |
|
49 | 49 | |
|
50 | 50 | $ cd rust/hg-core |
|
51 | 51 | |
|
52 | 52 | Simply run:: |
|
53 | 53 | |
|
54 | 54 | $ cargo build --release |
|
55 | 55 | |
|
56 | 56 | It is possible to build without ``--release``, but it is not |
|
57 | 57 | recommended if performance is of any interest: there can be an order |
|
58 | 58 | of magnitude of degradation when removing ``--release``. |
|
59 | 59 | |
|
60 | 60 | For faster builds, you may want to skip code generation:: |
|
61 | 61 | |
|
62 | 62 | $ cargo check |
|
63 | 63 | |
|
64 | 64 | For even faster typing:: |
|
65 | 65 | |
|
66 | 66 | $ cargo c |
|
67 | 67 | |
|
68 | 68 | You can run only the rust-specific tests (as opposed to tests of |
|
69 | 69 | mercurial as a whole) with:: |
|
70 | 70 | |
|
71 | 71 | $ cargo test --all |
|
72 | 72 | |
|
73 | 73 | Formatting the code |
|
74 | 74 | ------------------- |
|
75 | 75 | |
|
76 | 76 | We use ``rustfmt`` to keep the code formatted at all times. For now, we are |
|
77 | 77 | using the nightly version because it has been stable enough and provides |
|
78 | 78 | comment folding. |
|
79 | 79 | |
|
80 | 80 | To format the entire Rust workspace:: |
|
81 | 81 | |
|
82 | 82 | $ cargo +nightly fmt |
|
83 | 83 | |
|
84 | 84 | This requires you to have the nightly toolchain installed. |
General Comments 0
You need to be logged in to leave comments.
Login now