##// END OF EJS Templates
rust-filepatterns: improve API and robustness for pattern files parsing...
rust-filepatterns: improve API and robustness for pattern files parsing Within the next few patches we will be using this new API. Differential Revision: https://phab.mercurial-scm.org/D7908

File last commit:

r44784:d42eea9a default
r44784:d42eea9a default
Show More
lib.rs
169 lines | 4.6 KiB | application/rls-services+xml | RustLexer
Georges Racinet
rust-core: updated copyright notice...
r44455 // Copyright 2018-2020 Georges Racinet <georges.racinet@octobus.net>
// and Mercurial contributors
Georges Racinet
rust: pure Rust lazyancestors iterator...
r40307 //
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
mod ancestors;
Georges Racinet on ishtar.racinet.fr
rust: dagop.headrevs() Rust counterparts...
r41278 pub mod dagops;
Georges Racinet
rust: core implementation for lazyancestors...
r41084 pub use ancestors::{AncestorsIterator, LazyAncestors, MissingAncestors};
Raphaël Gomès
rust-dirstate: add rust-cpython bindings to the new parse/pack functions...
r42489 mod dirstate;
Georges Racinet
rust-discovery: starting core implementation...
r42355 pub mod discovery;
Raphaël Gomès
rust-dirstate: add rust-cpython bindings to the new parse/pack functions...
r42489 pub mod testing; // unconditionally built, for use from integration tests
pub use dirstate::{
Yuya Nishihara
rust-dirstate: specify concrete return type of DirsMultiset::iter()...
r43155 dirs_multiset::{DirsMultiset, DirsMultisetIter},
Raphaël Gomès
rust-dirstate: rust implementation of dirstatemap...
r42998 dirstate_map::DirstateMap,
Raphaël Gomès
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop...
r42993 parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE},
Raphaël Gomès
rust-dirstate-status: update bridge for new rust version of `dirstate.status`...
r44368 status::{status, StatusResult},
Yuya Nishihara
rust-dirstate: provide CopyMapIter and StateMapIter types...
r43156 CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState,
StateMap, StateMapIter,
Raphaël Gomès
rust-dirstate: add rust-cpython bindings to the new parse/pack functions...
r42489 };
Raphaël Gomès
rust-filepatterns: add a Rust implementation of pattern-related utils...
r42514 mod filepatterns;
Raphaël Gomès
rust-matchers: add `Matcher` trait and implement `AlwaysMatcher`...
r43742 pub mod matchers;
Georges Racinet
rust-core: extracted a revlog submodule...
r44457 pub mod revlog;
pub use revlog::*;
Raphaël Gomès
rust-utils: add docstrings and doctests for utils.rs...
r42829 pub mod utils;
Raphaël Gomès
rust-filepatterns: add a Rust implementation of pattern-related utils...
r42514
Raphaël Gomès
rust-dirs-multiset: improve temporary error message...
r44765 use crate::utils::hg_path::{HgPathBuf, HgPathError};
Raphaël Gomès
rust-filepatterns: add a Rust implementation of pattern-related utils...
r42514 pub use filepatterns::{
Raphaël Gomès
rust-filepatterns: improve API and robustness for pattern files parsing...
r44784 parse_pattern_syntax, read_pattern_file, IgnorePattern,
PatternFileWarning, PatternSyntax,
Raphaël Gomès
rust-filepatterns: add a Rust implementation of pattern-related utils...
r42514 };
Raphaël Gomès
rust-performance: introduce FastHashMap type alias for HashMap...
r44278 use std::collections::HashMap;
use twox_hash::RandomXxHashBuilder64;
Georges Racinet
rust: pure Rust lazyancestors iterator...
r40307
Raphaël Gomès
rust-filepatterns: add a Rust implementation of pattern-related utils...
r42514 pub type LineNumber = usize;
Raphaël Gomès
rust-performance: introduce FastHashMap type alias for HashMap...
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>;
Georges Racinet
rust: pure Rust lazyancestors iterator...
r40307 #[derive(Clone, Debug, PartialEq)]
Raphaël Gomès
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`...
r42488 pub enum DirstateParseError {
TooLittleData,
Overflow,
CorruptedEntry(String),
Raphaël Gomès
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop...
r42993 Damaged,
Raphaël Gomès
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`...
r42488 }
Raphaël Gomès
rust-dirstate: use EntryState enum instead of literals...
r42994 impl From<std::io::Error> for DirstateParseError {
fn from(e: std::io::Error) -> Self {
DirstateParseError::CorruptedEntry(e.to_string())
}
}
impl ToString for DirstateParseError {
fn to_string(&self) -> String {
use crate::DirstateParseError::*;
match self {
TooLittleData => "Too little data for dirstate.".to_string(),
Overflow => "Overflow in dirstate.".to_string(),
CorruptedEntry(e) => format!("Corrupted entry: {:?}.", e),
Damaged => "Dirstate appears to be damaged.".to_string(),
}
}
}
Raphaël Gomès
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`...
r42488 #[derive(Debug, PartialEq)]
pub enum DirstatePackError {
CorruptedEntry(String),
CorruptedParent,
BadSize(usize, usize),
}
Raphaël Gomès
rust-dirstate: use EntryState enum instead of literals...
r42994 impl From<std::io::Error> for DirstatePackError {
fn from(e: std::io::Error) -> Self {
DirstatePackError::CorruptedEntry(e.to_string())
}
}
Raphaël Gomès
rust-dirstate: add "dirs" Rust implementation...
r42736 #[derive(Debug, PartialEq)]
pub enum DirstateMapError {
Raphaël Gomès
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf...
r43227 PathNotFound(HgPathBuf),
Raphaël Gomès
rust-dirstate: add "dirs" Rust implementation...
r42736 EmptyPath,
Raphaël Gomès
rust-dirs-multiset: improve temporary error message...
r44765 InvalidPath(HgPathError),
Raphaël Gomès
rust-dirs: address failing tests for `dirs` impl with a temporary fix...
r44227 }
impl ToString for DirstateMapError {
fn to_string(&self) -> String {
match self {
Raphaël Gomès
rust-dirs-multiset: improve temporary error message...
r44765 DirstateMapError::PathNotFound(_) => {
"expected a value, found none".to_string()
Raphaël Gomès
rust-dirs: address failing tests for `dirs` impl with a temporary fix...
r44227 }
Raphaël Gomès
rust-dirs-multiset: improve temporary error message...
r44765 DirstateMapError::EmptyPath => "Overflow in dirstate.".to_string(),
DirstateMapError::InvalidPath(e) => e.to_string(),
Raphaël Gomès
rust-dirs: address failing tests for `dirs` impl with a temporary fix...
r44227 }
}
Raphaël Gomès
rust-dirstate: add "dirs" Rust implementation...
r42736 }
Raphaël Gomès
rust-dirstate: use EntryState enum instead of literals...
r42994 pub enum DirstateError {
Parse(DirstateParseError),
Pack(DirstatePackError),
Map(DirstateMapError),
IO(std::io::Error),
}
impl From<DirstateParseError> for DirstateError {
fn from(e: DirstateParseError) -> Self {
DirstateError::Parse(e)
Raphaël Gomès
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`...
r42488 }
}
Raphaël Gomès
rust-dirstate: use EntryState enum instead of literals...
r42994 impl From<DirstatePackError> for DirstateError {
fn from(e: DirstatePackError) -> Self {
DirstateError::Pack(e)
Raphaël Gomès
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`...
r42488 }
}
Raphaël Gomès
rust-filepatterns: add a Rust implementation of pattern-related utils...
r42514
#[derive(Debug)]
pub enum PatternError {
Raphaël Gomès
rust-filepatterns: improve API and robustness for pattern files parsing...
r44784 Path(HgPathError),
Raphaël Gomès
rust-filepatterns: add a Rust implementation of pattern-related utils...
r42514 UnsupportedSyntax(String),
Raphaël Gomès
rust-filepatterns: improve API and robustness for pattern files parsing...
r44784 UnsupportedSyntaxInFile(String, String, usize),
TooLong(usize),
IO(std::io::Error),
Raphaël Gomès
rust-filepatterns: add a Rust implementation of pattern-related utils...
r42514 }
Raphaël Gomès
rust-filepatterns: improve API and robustness for pattern files parsing...
r44784 impl ToString for PatternError {
fn to_string(&self) -> String {
match self {
PatternError::UnsupportedSyntax(syntax) => {
format!("Unsupported syntax {}", syntax)
}
PatternError::UnsupportedSyntaxInFile(syntax, file_path, line) => {
format!(
"{}:{}: unsupported syntax {}",
file_path, line, syntax
)
}
PatternError::TooLong(size) => {
format!("matcher pattern is too long ({} bytes)", size)
}
PatternError::IO(e) => e.to_string(),
PatternError::Path(e) => e.to_string(),
}
Raphaël Gomès
rust-filepatterns: add a Rust implementation of pattern-related utils...
r42514 }
}
Raphaël Gomès
rust-dirstate: use EntryState enum instead of literals...
r42994
impl From<DirstateMapError> for DirstateError {
fn from(e: DirstateMapError) -> Self {
DirstateError::Map(e)
}
}
impl From<std::io::Error> for DirstateError {
fn from(e: std::io::Error) -> Self {
DirstateError::IO(e)
}
}
Raphaël Gomès
rust-filepatterns: improve API and robustness for pattern files parsing...
r44784
impl From<std::io::Error> for PatternError {
fn from(e: std::io::Error) -> Self {
PatternError::IO(e)
}
}
impl From<HgPathError> for PatternError {
fn from(e: HgPathError) -> Self {
PatternError::Path(e)
}
}