rust/hg-core/src/lib.rs
changeset 44005 6b332c1fc7fe
parent 44003 cb2e2b095dc9
child 44283 934a79697c36
child 44476 df5dfee8cfb4
equal deleted inserted replaced
44004:9c1fd975e9ac 44005:6b332c1fc7fe
    17     CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState,
    17     CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState,
    18     StateMap, StateMapIter,
    18     StateMap, StateMapIter,
    19 };
    19 };
    20 mod filepatterns;
    20 mod filepatterns;
    21 pub mod matchers;
    21 pub mod matchers;
       
    22 pub mod revlog;
       
    23 pub use revlog::*;
    22 pub mod utils;
    24 pub mod utils;
    23 
    25 
    24 use crate::utils::hg_path::HgPathBuf;
    26 use crate::utils::hg_path::HgPathBuf;
    25 pub use filepatterns::{
    27 pub use filepatterns::{
    26     build_single_regex, read_pattern_file, PatternSyntax, PatternTuple,
    28     build_single_regex, read_pattern_file, PatternSyntax, PatternTuple,
    27 };
    29 };
    28 use std::collections::HashMap;
    30 use std::collections::HashMap;
    29 use twox_hash::RandomXxHashBuilder64;
    31 use twox_hash::RandomXxHashBuilder64;
    30 
    32 
    31 /// Mercurial revision numbers
       
    32 ///
       
    33 /// As noted in revlog.c, revision numbers are actually encoded in
       
    34 /// 4 bytes, and are liberally converted to ints, whence the i32
       
    35 pub type Revision = i32;
       
    36 
       
    37 /// Marker expressing the absence of a parent
       
    38 ///
       
    39 /// Independently of the actual representation, `NULL_REVISION` is guaranteed
       
    40 /// to be smaller that all existing revisions.
       
    41 pub const NULL_REVISION: Revision = -1;
       
    42 
       
    43 /// Same as `mercurial.node.wdirrev`
       
    44 ///
       
    45 /// This is also equal to `i32::max_value()`, but it's better to spell
       
    46 /// it out explicitely, same as in `mercurial.node`
       
    47 pub const WORKING_DIRECTORY_REVISION: Revision = 0x7fffffff;
       
    48 
       
    49 /// The simplest expression of what we need of Mercurial DAGs.
       
    50 pub trait Graph {
       
    51     /// Return the two parents of the given `Revision`.
       
    52     ///
       
    53     /// Each of the parents can be independently `NULL_REVISION`
       
    54     fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError>;
       
    55 }
       
    56 
       
    57 pub type LineNumber = usize;
    33 pub type LineNumber = usize;
    58 
    34 
    59 /// Rust's default hasher is too slow because it tries to prevent collision
    35 /// Rust's default hasher is too slow because it tries to prevent collision
    60 /// attacks. We are not concerned about those: if an ill-minded person has
    36 /// attacks. We are not concerned about those: if an ill-minded person has
    61 /// write access to your repository, you have other issues.
    37 /// write access to your repository, you have other issues.
    62 pub type FastHashMap<K, V> = HashMap<K, V, RandomXxHashBuilder64>;
    38 pub type FastHashMap<K, V> = HashMap<K, V, RandomXxHashBuilder64>;
    63 
       
    64 #[derive(Clone, Debug, PartialEq)]
       
    65 pub enum GraphError {
       
    66     ParentOutOfRange(Revision),
       
    67     WorkingDirectoryUnsupported,
       
    68 }
       
    69 
    39 
    70 #[derive(Clone, Debug, PartialEq)]
    40 #[derive(Clone, Debug, PartialEq)]
    71 pub enum DirstateParseError {
    41 pub enum DirstateParseError {
    72     TooLittleData,
    42     TooLittleData,
    73     Overflow,
    43     Overflow,