Mercurial > hg
annotate rust/hgcli/README.md @ 49491:c6a1beba27e9
bisect: avoid copying ancestor list for non-merge commits
During a bisection, hg needs to compute a list of all ancestors for every
candidate commit. This is accomplished via a bottom-up traversal of the set of
candidates, during which each revision's ancestor list is populated using the
ancestor list of its parent(s). Previously, this involved copying the entire
list, which could be very long in if the bisection range was large.
To help improve this, we can observe that each candidate commit is visited
exactly once, at which point its ancestor list is copied into its children's
lists and then dropped. In the case of non-merge commits, a commit's ancestor
list consists exactly of its parent's list plus itself. This means that we can
trivially reuse the parent's existing list for one of its non-merge children,
which avoids copying entirely if that commit is the parent's only child. This
makes bisections over linear ranges of commits much faster.
During some informal testing in the large publicly-available `mozilla-central`
repository, this noticeably sped up bisections over large ranges of history:
Setup:
$ cd mozilla-central
$ hg bisect --reset
$ hg bisect --good 0
$ hg log -r tip -T '{rev}\n'
628417
Test:
$ time hg bisect --bad tip --noupdate
Before:
real 3m35.927s
user 3m35.553s
sys 0m0.319s
After:
real 1m41.142s
user 1m40.810s
sys 0m0.285s
author | Arun Kulshreshtha <akulshreshtha@janestreet.com> |
---|---|
date | Tue, 30 Aug 2022 15:29:55 -0400 |
parents | 16c3fe46929a |
children | 45ba8416afc4 |
rev | line source |
---|---|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # Oxidized Mercurial |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 This project provides a Rust implementation of the Mercurial (`hg`) |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 version control tool. |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 Under the hood, the project uses |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 [PyOxidizer](https://github.com/indygreg/PyOxidizer) to embed a Python |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 interpreter in a binary built with Rust. At run-time, the Rust `fn main()` |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 is called and Rust code handles initial process startup. An in-process |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 Python interpreter is started (if needed) to provide additional |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 functionality. |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 # Building |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 |
48268
16c3fe46929a
pyoxidizer: update README.md with several small fixes
Kyle Lippincott <spectral@google.com>
parents:
46819
diff
changeset
|
15 First, acquire and build a copy of PyOxidizer; you probably want to do this in |
16c3fe46929a
pyoxidizer: update README.md with several small fixes
Kyle Lippincott <spectral@google.com>
parents:
46819
diff
changeset
|
16 some directory outside of your clone of Mercurial: |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 $ git clone https://github.com/indygreg/PyOxidizer.git |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 $ cd PyOxidizer |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 $ cargo build --release |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 |
48268
16c3fe46929a
pyoxidizer: update README.md with several small fixes
Kyle Lippincott <spectral@google.com>
parents:
46819
diff
changeset
|
22 Then build this Rust project using the built `pyoxidizer` executable: |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
23 |
48268
16c3fe46929a
pyoxidizer: update README.md with several small fixes
Kyle Lippincott <spectral@google.com>
parents:
46819
diff
changeset
|
24 $ /path/to/pyoxidizer/target/release/pyoxidizer build --release |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 If all goes according to plan, there should be an assembled application |
48268
16c3fe46929a
pyoxidizer: update README.md with several small fixes
Kyle Lippincott <spectral@google.com>
parents:
46819
diff
changeset
|
27 under `build/<arch>/release/app/` with an `hg` executable: |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
28 |
48268
16c3fe46929a
pyoxidizer: update README.md with several small fixes
Kyle Lippincott <spectral@google.com>
parents:
46819
diff
changeset
|
29 $ build/x86_64-unknown-linux-gnu/release/app/hg version |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 Mercurial Distributed SCM (version 5.3.1+433-f99cd77d53dc+20200331) |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 (see https://mercurial-scm.org for more information) |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 |
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
44639
diff
changeset
|
33 Copyright (C) 2005-2020 Olivia Mackall and others |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 This is free software; see the source for copying conditions. There is NO |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 # Running Tests |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 To run tests with a built `hg` executable, you can use the `--with-hg` |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 argument to `run-tests.py`. But there's a wrinkle: many tests run custom |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 Python scripts that need to `import` modules provided by Mercurial. Since |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 these modules are embedded in the produced `hg` executable, a regular |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 Python interpreter can't access them! To work around this, set `PYTHONPATH` |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 to the Mercurial source directory. e.g.: |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 $ cd /path/to/hg/src/tests |
48268
16c3fe46929a
pyoxidizer: update README.md with several small fixes
Kyle Lippincott <spectral@google.com>
parents:
46819
diff
changeset
|
47 $ PYTHONPATH=`pwd`/.. python3.9 run-tests.py \ |
16c3fe46929a
pyoxidizer: update README.md with several small fixes
Kyle Lippincott <spectral@google.com>
parents:
46819
diff
changeset
|
48 --with-hg `pwd`/../rust/hgcli/build/x86_64-unknown-linux-gnu/release/app/hg |