lib.rs
132 lines
| 3.9 KiB
| application/rls-services+xml
|
RustLexer
|
r44455 | // Copyright 2018-2020 Georges Racinet <georges.racinet@octobus.net> | ||
// and Mercurial contributors | ||||
|
r40307 | // | ||
// This software may be used and distributed according to the terms of the | ||||
// GNU General Public License version 2 or any later version. | ||||
|
r47172 | |||
|
r40307 | mod ancestors; | ||
|
r41278 | pub mod dagops; | ||
|
r47167 | pub mod errors; | ||
|
r49351 | pub use ancestors::{AncestorsIterator, MissingAncestors}; | ||
|
r47871 | pub mod dirstate; | ||
|
r47863 | pub mod dirstate_tree; | ||
|
r42355 | pub mod discovery; | ||
|
r48199 | pub mod exit_codes; | ||
|
r46536 | pub mod requirements; | ||
|
r42489 | pub mod testing; // unconditionally built, for use from integration tests | ||
pub use dirstate::{ | ||||
|
r43155 | dirs_multiset::{DirsMultiset, DirsMultisetIter}, | ||
|
r45015 | status::{ | ||
|
r48882 | BadMatch, BadType, DirstateStatus, HgPathCow, StatusError, | ||
|
r47555 | StatusOptions, | ||
|
r45015 | }, | ||
|
r48882 | DirstateEntry, DirstateParents, EntryState, | ||
|
r42489 | }; | ||
r46556 | pub mod copy_tracing; | |||
|
r42514 | mod filepatterns; | ||
|
r43742 | pub mod matchers; | ||
|
r46782 | pub mod repo; | ||
|
r44457 | pub mod revlog; | ||
pub use revlog::*; | ||||
|
r46803 | pub mod config; | ||
|
r49245 | pub mod lock; | ||
|
r47341 | pub mod logging; | ||
|
r45501 | pub mod operations; | ||
|
r47162 | pub mod revset; | ||
|
r42829 | pub mod utils; | ||
|
r48764 | pub mod vfs; | ||
|
r42514 | |||
|
r44765 | use crate::utils::hg_path::{HgPathBuf, HgPathError}; | ||
|
r42514 | pub use filepatterns::{ | ||
|
r44784 | parse_pattern_syntax, read_pattern_file, IgnorePattern, | ||
PatternFileWarning, PatternSyntax, | ||||
|
r42514 | }; | ||
|
r44278 | use std::collections::HashMap; | ||
|
r47173 | use std::fmt; | ||
|
r44278 | use twox_hash::RandomXxHashBuilder64; | ||
|
r40307 | |||
|
r45028 | /// This is a contract between the `micro-timer` crate and us, to expose | ||
/// the `log` crate as `crate::log`. | ||||
use log; | ||||
|
r42514 | pub type LineNumber = usize; | ||
|
r44278 | /// Rust's default hasher is too slow because it tries to prevent collision | ||
/// attacks. We are not concerned about those: if an ill-minded person has | ||||
/// write access to your repository, you have other issues. | ||||
pub type FastHashMap<K, V> = HashMap<K, V, RandomXxHashBuilder64>; | ||||
|
r42488 | #[derive(Debug, PartialEq)] | ||
|
r42736 | pub enum DirstateMapError { | ||
|
r43227 | PathNotFound(HgPathBuf), | ||
|
r42736 | EmptyPath, | ||
|
r44765 | InvalidPath(HgPathError), | ||
|
r44227 | } | ||
|
r47173 | impl fmt::Display for DirstateMapError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||
|
r44227 | match self { | ||
|
r44765 | DirstateMapError::PathNotFound(_) => { | ||
|
r47173 | f.write_str("expected a value, found none") | ||
|
r44227 | } | ||
|
r47173 | DirstateMapError::EmptyPath => { | ||
f.write_str("Overflow in dirstate.") | ||||
} | ||||
DirstateMapError::InvalidPath(path_error) => path_error.fmt(f), | ||||
|
r44227 | } | ||
} | ||||
|
r42736 | } | ||
|
r47164 | #[derive(Debug, derive_more::From)] | ||
|
r42994 | pub enum DirstateError { | ||
Map(DirstateMapError), | ||||
|
r47168 | Common(errors::HgError), | ||
|
r42994 | } | ||
|
r48126 | impl fmt::Display for DirstateError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||
match self { | ||||
DirstateError::Map(error) => error.fmt(f), | ||||
DirstateError::Common(error) => error.fmt(f), | ||||
} | ||||
} | ||||
} | ||||
|
r47164 | #[derive(Debug, derive_more::From)] | ||
|
r42514 | pub enum PatternError { | ||
|
r47164 | #[from] | ||
|
r44784 | Path(HgPathError), | ||
|
r42514 | UnsupportedSyntax(String), | ||
|
r44784 | UnsupportedSyntaxInFile(String, String, usize), | ||
TooLong(usize), | ||||
|
r47164 | #[from] | ||
|
r44784 | IO(std::io::Error), | ||
|
r44785 | /// Needed a pattern that can be turned into a regex but got one that | ||
/// can't. This should only happen through programmer error. | ||||
NonRegexPattern(IgnorePattern), | ||||
|
r42514 | } | ||
|
r47173 | impl fmt::Display for PatternError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||
|
r44784 | match self { | ||
PatternError::UnsupportedSyntax(syntax) => { | ||||
|
r47173 | write!(f, "Unsupported syntax {}", syntax) | ||
|
r44784 | } | ||
PatternError::UnsupportedSyntaxInFile(syntax, file_path, line) => { | ||||
|
r47173 | write!( | ||
f, | ||||
|
r44784 | "{}:{}: unsupported syntax {}", | ||
file_path, line, syntax | ||||
) | ||||
} | ||||
PatternError::TooLong(size) => { | ||||
|
r47173 | write!(f, "matcher pattern is too long ({} bytes)", size) | ||
|
r44784 | } | ||
|
r47173 | PatternError::IO(error) => error.fmt(f), | ||
PatternError::Path(error) => error.fmt(f), | ||||
|
r44785 | PatternError::NonRegexPattern(pattern) => { | ||
|
r47173 | write!(f, "'{:?}' cannot be turned into a regex", pattern) | ||
|
r44785 | } | ||
|
r44784 | } | ||
|
r42514 | } | ||
} | ||||