rust/hg-core/src/lib.rs
changeset 42327 e8f3740cc067
parent 42303 e240bec26626
child 42424 d3b5cbe311d9
equal deleted inserted replaced
42326:5d4ec64a6fcb 42327:e8f3740cc067
     2 //
     2 //
     3 // This software may be used and distributed according to the terms of the
     3 // This software may be used and distributed according to the terms of the
     4 // GNU General Public License version 2 or any later version.
     4 // GNU General Public License version 2 or any later version.
     5 extern crate byteorder;
     5 extern crate byteorder;
     6 extern crate memchr;
     6 extern crate memchr;
       
     7 #[macro_use]
       
     8 extern crate lazy_static;
       
     9 extern crate regex;
     7 
    10 
     8 mod ancestors;
    11 mod ancestors;
     9 pub mod dagops;
    12 pub mod dagops;
    10 pub use ancestors::{AncestorsIterator, LazyAncestors, MissingAncestors};
    13 pub use ancestors::{AncestorsIterator, LazyAncestors, MissingAncestors};
    11 mod dirstate;
    14 mod dirstate;
    12 pub mod discovery;
    15 pub mod discovery;
    13 pub mod testing; // unconditionally built, for use from integration tests
    16 pub mod testing; // unconditionally built, for use from integration tests
    14 pub use dirstate::{
    17 pub use dirstate::{
    15     pack_dirstate, parse_dirstate, CopyVec, CopyVecEntry, DirstateEntry,
    18     pack_dirstate, parse_dirstate, CopyVec, CopyVecEntry, DirstateEntry,
    16     DirstateParents, DirstateVec,
    19     DirstateParents, DirstateVec,
       
    20 };
       
    21 mod filepatterns;
       
    22 
       
    23 pub use filepatterns::{
       
    24     build_single_regex, read_pattern_file, PatternSyntax, PatternTuple,
    17 };
    25 };
    18 
    26 
    19 /// Mercurial revision numbers
    27 /// Mercurial revision numbers
    20 ///
    28 ///
    21 /// As noted in revlog.c, revision numbers are actually encoded in
    29 /// As noted in revlog.c, revision numbers are actually encoded in
    39     /// Return the two parents of the given `Revision`.
    47     /// Return the two parents of the given `Revision`.
    40     ///
    48     ///
    41     /// Each of the parents can be independently `NULL_REVISION`
    49     /// Each of the parents can be independently `NULL_REVISION`
    42     fn parents(&self, Revision) -> Result<[Revision; 2], GraphError>;
    50     fn parents(&self, Revision) -> Result<[Revision; 2], GraphError>;
    43 }
    51 }
       
    52 
       
    53 pub type LineNumber = usize;
    44 
    54 
    45 #[derive(Clone, Debug, PartialEq)]
    55 #[derive(Clone, Debug, PartialEq)]
    46 pub enum GraphError {
    56 pub enum GraphError {
    47     ParentOutOfRange(Revision),
    57     ParentOutOfRange(Revision),
    48     WorkingDirectoryUnsupported,
    58     WorkingDirectoryUnsupported,
    71 impl From<std::io::Error> for DirstateParseError {
    81 impl From<std::io::Error> for DirstateParseError {
    72     fn from(e: std::io::Error) -> Self {
    82     fn from(e: std::io::Error) -> Self {
    73         DirstateParseError::CorruptedEntry(e.to_string())
    83         DirstateParseError::CorruptedEntry(e.to_string())
    74     }
    84     }
    75 }
    85 }
       
    86 
       
    87 #[derive(Debug)]
       
    88 pub enum PatternError {
       
    89     UnsupportedSyntax(String),
       
    90 }
       
    91 
       
    92 #[derive(Debug)]
       
    93 pub enum PatternFileError {
       
    94     IO(std::io::Error),
       
    95     Pattern(PatternError, LineNumber),
       
    96 }
       
    97 
       
    98 impl From<std::io::Error> for PatternFileError {
       
    99     fn from(e: std::io::Error) -> Self {
       
   100         PatternFileError::IO(e)
       
   101     }
       
   102 }