annotate rust/hg-core/src/lib.rs @ 41435:e2e815e3c4ae

revlog: document cext oddities in terms of object/caches This clarify why we just call clearcaches on a single object.
author Boris Feld <boris.feld@octobus.net>
date Fri, 25 Jan 2019 18:22:02 -0500
parents ee943a920606
children ee7b7bd432a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40271
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
1 // Copyright 2018 Georges Racinet <gracinet@anybox.fr>
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
2 //
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
3 // This software may be used and distributed according to the terms of the
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
4 // GNU General Public License version 2 or any later version.
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
5 mod ancestors;
41242
47881d2a9d99 rust: dagop.headrevs() Rust counterparts
Georges Racinet on ishtar.racinet.fr <georges@racinet.fr>
parents: 41241
diff changeset
6 pub mod dagops;
41054
ef54bd33b476 rust: core implementation for lazyancestors
Georges Racinet <gracinet@anybox.fr>
parents: 40959
diff changeset
7 pub use ancestors::{AncestorsIterator, LazyAncestors, MissingAncestors};
41241
168041fa6d5f rust: factorized testing Graphs
Georges Racinet <georges.racinet@octobus.net>
parents: 41054
diff changeset
8 #[cfg(test)]
168041fa6d5f rust: factorized testing Graphs
Georges Racinet <georges.racinet@octobus.net>
parents: 41054
diff changeset
9 pub mod testing;
40271
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
10
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
11 /// Mercurial revision numbers
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
12 ///
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
13 /// As noted in revlog.c, revision numbers are actually encoded in
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
14 /// 4 bytes, and are liberally converted to ints, whence the i32
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
15 pub type Revision = i32;
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
16
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
17 pub const NULL_REVISION: Revision = -1;
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
18
41348
2f54f31c41aa rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents: 41242
diff changeset
19 /// Same as `mercurial.node.wdirrev`
2f54f31c41aa rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents: 41242
diff changeset
20 ///
2f54f31c41aa rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents: 41242
diff changeset
21 /// This is also equal to `i32::max_value()`, but it's better to spell
2f54f31c41aa rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents: 41242
diff changeset
22 /// it out explicitely, same as in `mercurial.node`
2f54f31c41aa rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents: 41242
diff changeset
23 pub const WORKING_DIRECTORY_REVISION: Revision = 0x7fffffff;
2f54f31c41aa rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents: 41242
diff changeset
24
40271
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
25 /// The simplest expression of what we need of Mercurial DAGs.
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
26 pub trait Graph {
40959
d097dd0afc19 rust: translation of missingancestors
Georges Racinet <gracinet@anybox.fr>
parents: 40933
diff changeset
27 /// Return the two parents of the given `Revision`.
d097dd0afc19 rust: translation of missingancestors
Georges Racinet <gracinet@anybox.fr>
parents: 40933
diff changeset
28 ///
d097dd0afc19 rust: translation of missingancestors
Georges Racinet <gracinet@anybox.fr>
parents: 40933
diff changeset
29 /// Each of the parents can be independently `NULL_REVISION`
40933
18513d6ef7d4 rust: changed Graph.parents to return [Revision; 2]
Georges Racinet <gracinet@anybox.fr>
parents: 40271
diff changeset
30 fn parents(&self, Revision) -> Result<[Revision; 2], GraphError>;
40271
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
31 }
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
32
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
33 #[derive(Clone, Debug, PartialEq)]
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
34 pub enum GraphError {
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
35 ParentOutOfRange(Revision),
41349
ee943a920606 rust: error for WdirUnsupported with cpython conversion as exception
Georges Racinet <georges.racinet@octobus.net>
parents: 41348
diff changeset
36 WorkingDirectoryUnsupported,
40271
dbc28c91f7ff rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
37 }