# HG changeset patch # User Raphaël Gomès # Date 2019-05-16 14:22:20 # Node ID d3b5cbe311d9fdc8b5aacf3736c41a6a97f984ed # Parent 0ae593e791fbfa8b08148be3d8033c1eec3b7dd4 rust-dirstate: create dirstate submodule This change is here to facilitate a future patch that is written in a different file. I expect this module to grow a few different files. Differential Revision: https://phab.mercurial-scm.org/D6389 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;