Mercurial > hg
annotate rust/hg-core/src/exit_codes.rs @ 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 | 7c93e38a0bbd |
children |
rev | line source |
---|---|
47407
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
1 pub type ExitCode = i32; |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
2 |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
3 /// Successful exit |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
4 pub const OK: ExitCode = 0; |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
5 |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
6 /// Generic abort |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
7 pub const ABORT: ExitCode = 255; |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
8 |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
9 // Abort when there is a config related error |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
10 pub const CONFIG_ERROR_ABORT: ExitCode = 30; |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
11 |
49489
7c93e38a0bbd
rhg-status: add support for narrow clones
Raphaël Gomès <rgomes@octobus.net>
parents:
49149
diff
changeset
|
12 /// Indicates that the operation might work if retried in a different state. |
7c93e38a0bbd
rhg-status: add support for narrow clones
Raphaël Gomès <rgomes@octobus.net>
parents:
49149
diff
changeset
|
13 /// Examples: Unresolved merge conflicts, unfinished operations |
7c93e38a0bbd
rhg-status: add support for narrow clones
Raphaël Gomès <rgomes@octobus.net>
parents:
49149
diff
changeset
|
14 pub const STATE_ERROR: ExitCode = 20; |
7c93e38a0bbd
rhg-status: add support for narrow clones
Raphaël Gomès <rgomes@octobus.net>
parents:
49149
diff
changeset
|
15 |
47407
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
16 // Abort when there is an error while parsing config |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
17 pub const CONFIG_PARSE_ERROR_ABORT: ExitCode = 10; |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
18 |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
19 /// Generic something completed but did not succeed |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
20 pub const UNSUCCESSFUL: ExitCode = 1; |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
21 |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
22 /// Command or feature not implemented by rhg |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
23 pub const UNIMPLEMENTED: ExitCode = 252; |
49149
006688e36e12
rhg: use `Command::exec` instead of `Command::status`
Raphaël Gomès <rgomes@octobus.net>
parents:
47407
diff
changeset
|
24 |
006688e36e12
rhg: use `Command::exec` instead of `Command::status`
Raphaël Gomès <rgomes@octobus.net>
parents:
47407
diff
changeset
|
25 /// The fallback path is not valid |
006688e36e12
rhg: use `Command::exec` instead of `Command::status`
Raphaël Gomès <rgomes@octobus.net>
parents:
47407
diff
changeset
|
26 pub const INVALID_FALLBACK: ExitCode = 253; |