| 1 |
# Oxidized Mercurial |
| 2 |
|
| 3 |
This project provides a Rust implementation of the Mercurial (`hg`) |
| 4 |
version control tool. |
| 5 |
|
| 6 |
Under the hood, the project uses |
| 7 |
[PyOxidizer](https://github.com/indygreg/PyOxidizer) to embed a Python |
| 8 |
interpreter in a binary built with Rust. At run-time, the Rust `fn main()` |
| 9 |
is called and Rust code handles initial process startup. An in-process |
| 10 |
Python interpreter is started (if needed) to provide additional |
| 11 |
functionality. |
| 12 |
|
| 13 |
# Building |
| 14 |
|
| 15 |
First, acquire and build a copy of PyOxidizer; you probably want to do this in |
| 16 |
some directory outside of your clone of Mercurial: |
| 17 |
|
| 18 |
$ git clone https://github.com/indygreg/PyOxidizer.git |
| 19 |
$ cd PyOxidizer |
| 20 |
$ cargo build --release |
| 21 |
|
| 22 |
Then build this Rust project using the built `pyoxidizer` executable: |
| 23 |
|
| 24 |
$ /path/to/pyoxidizer/target/release/pyoxidizer build --release |
| 25 |
|
| 26 |
If all goes according to plan, there should be an assembled application |
| 27 |
under `build/<arch>/release/app/` with an `hg` executable: |
| 28 |
|
| 29 |
$ build/x86_64-unknown-linux-gnu/release/app/hg version |
| 30 |
Mercurial Distributed SCM (version 5.3.1+433-f99cd77d53dc+20200331) |
| 31 |
(see https://mercurial-scm.org for more information) |
| 32 |
|
| 33 |
Copyright (C) 2005-2026 Olivia Mackall and others |
| 34 |
This is free software; see the source for copying conditions. There is NO |
| 35 |
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 36 |
|
| 37 |
# Running Tests |
| 38 |
|
| 39 |
To run tests with a built `hg` executable, you can use the `--with-hg` |
| 40 |
argument to `run-tests.py`. But there's a wrinkle: many tests run custom |
| 41 |
Python scripts that need to `import` modules provided by Mercurial. Since |
| 42 |
these modules are embedded in the produced `hg` executable, a regular |
| 43 |
Python interpreter can't access them! To work around this, set `PYTHONPATH` |
| 44 |
to the Mercurial source directory. e.g.: |
| 45 |
|
| 46 |
$ cd /path/to/hg/src/tests |
| 47 |
$ PYTHONPATH=`pwd`/.. python3.9 run-tests.py \ |
| 48 |
--with-hg `pwd`/../rust/hgcli/build/x86_64-unknown-linux-gnu/release/app/hg |