D7782: rust-core: extracted a revlog submodule
gracinet (Georges Racinet)
phabricator at mercurial-scm.org
Wed Jan 8 11:50:53 EST 2020
Closed by commit rHG9aee291b608a: rust-core: extracted a revlog submodule (authored by gracinet).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D7782?vs=19030&id=19068
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D7782/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D7782
AFFECTED FILES
rust/hg-core/src/lib.rs
rust/hg-core/src/revlog.rs
CHANGE DETAILS
diff --git a/rust/hg-core/src/revlog.rs b/rust/hg-core/src/revlog.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-core/src/revlog.rs
@@ -0,0 +1,38 @@
+// Copyright 2018-2020 Georges Racinet <georges.racinet at octobus.net>
+// and Mercurial contributors
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+//! Mercurial concepts for handling revision history
+
+/// 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>;
+}
+
+#[derive(Clone, Debug, PartialEq)]
+pub enum GraphError {
+ ParentOutOfRange(Revision),
+ WorkingDirectoryUnsupported,
+}
diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -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,
To: gracinet, #hg-reviewers, Alphare
Cc: Alphare, durin42, kevincox, mercurial-devel
More information about the Mercurial-devel
mailing list