rust/hg-core/src/dirstate.rs
author Raphaël Gomès <rgomes@octobus.net>
Tue, 02 Jul 2019 17:15:03 +0200
changeset 42609 326fdce22fb2
parent 42536 rust/hg-core/src/dirstate/mod.rs@2dcee6497b0b
child 42748 7cae6bc29ff9
permissions -rw-r--r--
rust: switch hg-core and hg-cpython to rust 2018 edition Many interesting changes have happened in Rust since the Oxidation Plan was introduced, like the 2018 edition and procedural macros: - Opting in to the 2018 edition is a clear benefit in terms of future proofing, new (nice to have) syntactical sugar notwithstanding. It also has a new non-lexical, non-AST based borrow checker that has fewer bugs(!) and allows us to write correct code that in some cases would have been rejected by the old one. - Procedural macros allow us to use the PyO3 crate which maintainers have expressed the clear goal of compiling on stable, which would help in code maintainability compared to rust-cpython. In this patch are the following changes: - Removing most `extern crate` uses - Updating `use` clauses (`crate` keyword, nested `use`) - Removing `mod.rs` in favor of an aptly named module file Like discussed in the mailing list ( https://www.mercurial-scm.org/pipermail/mercurial-devel/2019-July/132316.html ), until Rust integration in Mercurial is considered to be out of the experimental phase, the maximum version of Rust allowed is whatever the latest version Debian packages. Differential Revision: https://phab.mercurial-scm.org/D6597

pub mod dirs_multiset;
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<u8>, DirstateEntry)>;

#[derive(Debug, PartialEq)]
pub struct CopyVecEntry<'a> {
    pub path: &'a [u8],
    pub copy_path: &'a [u8],
}

pub type CopyVec<'a> = Vec<CopyVecEntry<'a>>;

/// The Python implementation passes either a mapping (dirstate) or a flat
/// iterable (manifest)
pub enum DirsIterable {
    Dirstate(DirstateVec),
    Manifest(Vec<Vec<u8>>),
}