diff --git a/rust/hg-core/src/dirstate/mod.rs b/rust/hg-core/src/dirstate/mod.rs new file mode 100644 --- /dev/null +++ b/rust/hg-core/src/dirstate/mod.rs @@ -0,0 +1,28 @@ +pub mod parsers; + +#[derive(Debug, PartialEq, Copy, Clone)] +pub struct DirstateParents<'a> { + pub p1: &'a [u8], + pub p2: &'a [u8], +} + +/// The C implementation uses all signed types. This will be an issue +/// either when 4GB+ source files are commonplace or in 2038, whichever +/// comes first. +#[derive(Debug, PartialEq)] +pub struct DirstateEntry { + pub state: i8, + pub mode: i32, + pub mtime: i32, + pub size: i32, +} + +pub type DirstateVec = Vec<(Vec, DirstateEntry)>; + +#[derive(Debug, PartialEq)] +pub struct CopyVecEntry<'a> { + pub path: &'a [u8], + pub copy_path: &'a [u8], +} + +pub type CopyVec<'a> = Vec>; diff --git a/rust/hg-core/src/dirstate.rs b/rust/hg-core/src/dirstate/parsers.rs rename from rust/hg-core/src/dirstate.rs rename to rust/hg-core/src/dirstate/parsers.rs --- a/rust/hg-core/src/dirstate.rs +++ b/rust/hg-core/src/dirstate/parsers.rs @@ -6,31 +6,10 @@ use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use std::collections::HashMap; use std::io::Cursor; -use {DirstatePackError, DirstateParseError}; - -#[derive(Debug, PartialEq, Copy, Clone)] -pub struct DirstateParents<'a> { - pub p1: &'a [u8], - pub p2: &'a [u8], -} -/// The C implementation uses all signed types. This will be an issue -/// either when 4GB+ source files are commonplace or in 2038, whichever -/// comes first. -#[derive(Debug, PartialEq)] -pub struct DirstateEntry { - pub state: i8, - pub mode: i32, - pub mtime: i32, - pub size: i32, -} -pub type DirstateVec = Vec<(Vec, DirstateEntry)>; - -#[derive(Debug, PartialEq)] -pub struct CopyVecEntry<'a> { - pub path: &'a [u8], - pub copy_path: &'a [u8], -} -pub type CopyVec<'a> = Vec>; +use { + CopyVec, CopyVecEntry, DirstateEntry, DirstatePackError, DirstateParents, + DirstateParseError, DirstateVec, +}; /// Parents are stored in the dirstate as byte hashes. const PARENT_SIZE: usize = 20; 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 @@ -15,8 +15,8 @@ mod dirstate; pub mod discovery; pub mod testing; // unconditionally built, for use from integration tests pub use dirstate::{ - pack_dirstate, parse_dirstate, CopyVec, CopyVecEntry, DirstateEntry, - DirstateParents, DirstateVec, + parsers::{pack_dirstate, parse_dirstate}, + CopyVec, CopyVecEntry, DirstateEntry, DirstateParents, DirstateVec, }; mod filepatterns;