Mercurial > hg
diff rust/hg-core/src/lib.rs @ 44005:6b332c1fc7fe
rust-core: extracted a revlog submodule
This moves fundamental definitions from the top of the crate
to the newly created `revlog` submodule and reexports them for
easy compatibility.
As we are about to add new features to this crate, we felt it
will improve clarity, and moreso if `ancestors` and `dagops`
would become submodules of `revlog`.
Differential Revision: https://phab.mercurial-scm.org/D7782
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Wed, 25 Dec 2019 15:17:55 +0100 |
parents | cb2e2b095dc9 |
children | 934a79697c36 df5dfee8cfb4 |
line wrap: on
line diff
--- a/rust/hg-core/src/lib.rs Thu Dec 19 00:32:42 2019 -0800 +++ b/rust/hg-core/src/lib.rs Wed Dec 25 15:17:55 2019 +0100 @@ -19,6 +19,8 @@ }; mod filepatterns; pub mod matchers; +pub mod revlog; +pub use revlog::*; pub mod utils; use crate::utils::hg_path::HgPathBuf; @@ -28,32 +30,6 @@ use std::collections::HashMap; use twox_hash::RandomXxHashBuilder64; -/// Mercurial revision numbers -/// -/// As noted in revlog.c, revision numbers are actually encoded in -/// 4 bytes, and are liberally converted to ints, whence the i32 -pub type Revision = i32; - -/// Marker expressing the absence of a parent -/// -/// Independently of the actual representation, `NULL_REVISION` is guaranteed -/// to be smaller that all existing revisions. -pub const NULL_REVISION: Revision = -1; - -/// Same as `mercurial.node.wdirrev` -/// -/// This is also equal to `i32::max_value()`, but it's better to spell -/// it out explicitely, same as in `mercurial.node` -pub const WORKING_DIRECTORY_REVISION: Revision = 0x7fffffff; - -/// The simplest expression of what we need of Mercurial DAGs. -pub trait Graph { - /// Return the two parents of the given `Revision`. - /// - /// Each of the parents can be independently `NULL_REVISION` - fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError>; -} - pub type LineNumber = usize; /// Rust's default hasher is too slow because it tries to prevent collision @@ -62,12 +38,6 @@ pub type FastHashMap<K, V> = HashMap<K, V, RandomXxHashBuilder64>; #[derive(Clone, Debug, PartialEq)] -pub enum GraphError { - ParentOutOfRange(Revision), - WorkingDirectoryUnsupported, -} - -#[derive(Clone, Debug, PartialEq)] pub enum DirstateParseError { TooLittleData, Overflow,