Mercurial > public > mercurial-scm > hg-stable
annotate rust/hg-core/src/lib.rs @ 46187:95d6f31e88db
hg-core: add basic config module
The config module exposes a `Config` struct, unused for now.
It only reads the config file local to the repository, but handles all valid
patterns and includes/unsets.
It is structured in layers instead of erasing by reverse order of precedence,
allowing us to transparently know more about the config for debugging purposes,
and potentially other things I haven't thought about yet.
This change also introduces `format_bytes!` to `hg-core`.
Differential Revision: https://phab.mercurial-scm.org/D9408
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Tue, 29 Dec 2020 10:53:45 +0100 |
parents | 8a4914397d02 |
children | cabc5e9366c5 |
rev | line source |
---|---|
44006
cb2e2b095dc9
rust-core: updated copyright notice
Georges Racinet <georges.racinet@octobus.net>
parents:
43922
diff
changeset
|
1 // Copyright 2018-2020 Georges Racinet <georges.racinet@octobus.net> |
cb2e2b095dc9
rust-core: updated copyright notice
Georges Racinet <georges.racinet@octobus.net>
parents:
43922
diff
changeset
|
2 // and Mercurial contributors |
40271
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
3 // |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
4 // This software may be used and distributed according to the terms of the |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
5 // GNU General Public License version 2 or any later version. |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
6 mod ancestors; |
41242
47881d2a9d99
rust: dagop.headrevs() Rust counterparts
Georges Racinet on ishtar.racinet.fr <georges@racinet.fr>
parents:
41241
diff
changeset
|
7 pub mod dagops; |
41057
ef54bd33b476
rust: core implementation for lazyancestors
Georges Racinet <gracinet@anybox.fr>
parents:
40972
diff
changeset
|
8 pub use ancestors::{AncestorsIterator, LazyAncestors, MissingAncestors}; |
42330
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42329
diff
changeset
|
9 mod dirstate; |
42216
10b465d61556
rust-discovery: starting core implementation
Georges Racinet <georges.racinet@octobus.net>
parents:
41728
diff
changeset
|
10 pub mod discovery; |
45939
a2eda1ff22aa
requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents:
45384
diff
changeset
|
11 pub mod requirements; |
42330
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42329
diff
changeset
|
12 pub mod testing; // unconditionally built, for use from integration tests |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42329
diff
changeset
|
13 pub use dirstate::{ |
42891
a03a29462c0a
rust-dirstate: specify concrete return type of DirsMultiset::iter()
Yuya Nishihara <yuya@tcha.org>
parents:
42818
diff
changeset
|
14 dirs_multiset::{DirsMultiset, DirsMultisetIter}, |
42769
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42765
diff
changeset
|
15 dirstate_map::DirstateMap, |
42764
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42610
diff
changeset
|
16 parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE}, |
44538
c8891bca40fb
rust-status: add bare `hg status` support in hg-core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44535
diff
changeset
|
17 status::{ |
c8891bca40fb
rust-status: add bare `hg status` support in hg-core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44535
diff
changeset
|
18 status, BadMatch, BadType, DirstateStatus, StatusError, StatusOptions, |
c8891bca40fb
rust-status: add bare `hg status` support in hg-core
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44535
diff
changeset
|
19 }, |
42892
7083ac37314f
rust-dirstate: provide CopyMapIter and StateMapIter types
Yuya Nishihara <yuya@tcha.org>
parents:
42891
diff
changeset
|
20 CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState, |
7083ac37314f
rust-dirstate: provide CopyMapIter and StateMapIter types
Yuya Nishihara <yuya@tcha.org>
parents:
42891
diff
changeset
|
21 StateMap, StateMapIter, |
42330
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42329
diff
changeset
|
22 }; |
45959
595979dc924e
copies: introduce a basic Rust function for `combine_changeset_copies`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45939
diff
changeset
|
23 pub mod copy_tracing; |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
24 mod filepatterns; |
43490
a77d4fe347a4
rust-matchers: add `Matcher` trait and implement `AlwaysMatcher`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43271
diff
changeset
|
25 pub mod matchers; |
46167
8a4914397d02
rust: introduce Repo and Vfs types for filesystem abstraction
Simon Sapin <simon.sapin@octobus.net>
parents:
45959
diff
changeset
|
26 pub mod repo; |
44008
6b332c1fc7fe
rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
44006
diff
changeset
|
27 pub mod revlog; |
6b332c1fc7fe
rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
44006
diff
changeset
|
28 pub use revlog::*; |
46187
95d6f31e88db
hg-core: add basic config module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
46167
diff
changeset
|
29 pub mod config; |
44999
a46e36b82461
hg-core: add Operation interface for high-level hg operations
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44929
diff
changeset
|
30 pub mod operations; |
42610
5672bb73f61e
rust-utils: add docstrings and doctests for utils.rs
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42609
diff
changeset
|
31 pub mod utils; |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
32 |
44208
df5dfee8cfb4
hg-core: add a compilation error if trying to compile outside of Linux
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
33 // Remove this to see (potential) non-artificial compile failures. MacOS |
df5dfee8cfb4
hg-core: add a compilation error if trying to compile outside of Linux
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
34 // *should* compile, but fail to compile tests for example as of 2020-03-06 |
df5dfee8cfb4
hg-core: add a compilation error if trying to compile outside of Linux
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
35 #[cfg(not(target_os = "linux"))] |
df5dfee8cfb4
hg-core: add a compilation error if trying to compile outside of Linux
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
36 compile_error!( |
df5dfee8cfb4
hg-core: add a compilation error if trying to compile outside of Linux
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
37 "`hg-core` has only been tested on Linux and will most \ |
df5dfee8cfb4
hg-core: add a compilation error if trying to compile outside of Linux
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
38 likely not behave correctly on other platforms." |
df5dfee8cfb4
hg-core: add a compilation error if trying to compile outside of Linux
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
39 ); |
df5dfee8cfb4
hg-core: add a compilation error if trying to compile outside of Linux
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
40 |
44329
934a79697c36
rust-dirs-multiset: improve temporary error message
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
41 use crate::utils::hg_path::{HgPathBuf, HgPathError}; |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
42 pub use filepatterns::{ |
44346
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
43 parse_pattern_syntax, read_pattern_file, IgnorePattern, |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
44 PatternFileWarning, PatternSyntax, |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
45 }; |
43844
5ac243a92e37
rust-performance: introduce FastHashMap type alias for HashMap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43808
diff
changeset
|
46 use std::collections::HashMap; |
5ac243a92e37
rust-performance: introduce FastHashMap type alias for HashMap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43808
diff
changeset
|
47 use twox_hash::RandomXxHashBuilder64; |
40271
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
48 |
44551
d880805d5442
hg-core: add function timing information
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44538
diff
changeset
|
49 /// This is a contract between the `micro-timer` crate and us, to expose |
d880805d5442
hg-core: add function timing information
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44538
diff
changeset
|
50 /// the `log` crate as `crate::log`. |
d880805d5442
hg-core: add function timing information
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44538
diff
changeset
|
51 use log; |
d880805d5442
hg-core: add function timing information
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44538
diff
changeset
|
52 |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
53 pub type LineNumber = usize; |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
54 |
43844
5ac243a92e37
rust-performance: introduce FastHashMap type alias for HashMap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43808
diff
changeset
|
55 /// Rust's default hasher is too slow because it tries to prevent collision |
5ac243a92e37
rust-performance: introduce FastHashMap type alias for HashMap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43808
diff
changeset
|
56 /// attacks. We are not concerned about those: if an ill-minded person has |
5ac243a92e37
rust-performance: introduce FastHashMap type alias for HashMap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43808
diff
changeset
|
57 /// write access to your repository, you have other issues. |
5ac243a92e37
rust-performance: introduce FastHashMap type alias for HashMap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43808
diff
changeset
|
58 pub type FastHashMap<K, V> = HashMap<K, V, RandomXxHashBuilder64>; |
5ac243a92e37
rust-performance: introduce FastHashMap type alias for HashMap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43808
diff
changeset
|
59 |
40271
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
60 #[derive(Clone, Debug, PartialEq)] |
42329
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
61 pub enum DirstateParseError { |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
62 TooLittleData, |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
63 Overflow, |
45384
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44999
diff
changeset
|
64 // TODO refactor to use bytes instead of String |
42329
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
65 CorruptedEntry(String), |
42764
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42610
diff
changeset
|
66 Damaged, |
42329
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
67 } |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
68 |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
69 impl From<std::io::Error> for DirstateParseError { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
70 fn from(e: std::io::Error) -> Self { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
71 DirstateParseError::CorruptedEntry(e.to_string()) |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
72 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
73 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
74 |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
75 impl ToString for DirstateParseError { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
76 fn to_string(&self) -> String { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
77 use crate::DirstateParseError::*; |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
78 match self { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
79 TooLittleData => "Too little data for dirstate.".to_string(), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
80 Overflow => "Overflow in dirstate.".to_string(), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
81 CorruptedEntry(e) => format!("Corrupted entry: {:?}.", e), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
82 Damaged => "Dirstate appears to be damaged.".to_string(), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
83 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
84 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
85 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
86 |
42329
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
87 #[derive(Debug, PartialEq)] |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
88 pub enum DirstatePackError { |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
89 CorruptedEntry(String), |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
90 CorruptedParent, |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
91 BadSize(usize, usize), |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
92 } |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
93 |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
94 impl From<std::io::Error> for DirstatePackError { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
95 fn from(e: std::io::Error) -> Self { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
96 DirstatePackError::CorruptedEntry(e.to_string()) |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
97 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
98 } |
42543
2dcee6497b0b
rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42453
diff
changeset
|
99 #[derive(Debug, PartialEq)] |
2dcee6497b0b
rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42453
diff
changeset
|
100 pub enum DirstateMapError { |
42960
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42892
diff
changeset
|
101 PathNotFound(HgPathBuf), |
42543
2dcee6497b0b
rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42453
diff
changeset
|
102 EmptyPath, |
44329
934a79697c36
rust-dirs-multiset: improve temporary error message
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
103 InvalidPath(HgPathError), |
43808
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43490
diff
changeset
|
104 } |
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43490
diff
changeset
|
105 |
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43490
diff
changeset
|
106 impl ToString for DirstateMapError { |
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43490
diff
changeset
|
107 fn to_string(&self) -> String { |
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43490
diff
changeset
|
108 match self { |
44329
934a79697c36
rust-dirs-multiset: improve temporary error message
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
109 DirstateMapError::PathNotFound(_) => { |
934a79697c36
rust-dirs-multiset: improve temporary error message
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
110 "expected a value, found none".to_string() |
43808
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43490
diff
changeset
|
111 } |
44329
934a79697c36
rust-dirs-multiset: improve temporary error message
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
112 DirstateMapError::EmptyPath => "Overflow in dirstate.".to_string(), |
934a79697c36
rust-dirs-multiset: improve temporary error message
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44008
diff
changeset
|
113 DirstateMapError::InvalidPath(e) => e.to_string(), |
43808
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43490
diff
changeset
|
114 } |
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43490
diff
changeset
|
115 } |
42543
2dcee6497b0b
rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42453
diff
changeset
|
116 } |
2dcee6497b0b
rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42453
diff
changeset
|
117 |
44571
ece43c79333e
rust-core: add missing `Debug` traits
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44551
diff
changeset
|
118 #[derive(Debug)] |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
119 pub enum DirstateError { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
120 Parse(DirstateParseError), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
121 Pack(DirstatePackError), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
122 Map(DirstateMapError), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
123 IO(std::io::Error), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
124 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
125 |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
126 impl From<DirstateParseError> for DirstateError { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
127 fn from(e: DirstateParseError) -> Self { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
128 DirstateError::Parse(e) |
42329
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
129 } |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
130 } |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
131 |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
132 impl From<DirstatePackError> for DirstateError { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
133 fn from(e: DirstatePackError) -> Self { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
134 DirstateError::Pack(e) |
42329
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
135 } |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
136 } |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
137 |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
138 #[derive(Debug)] |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
139 pub enum PatternError { |
44346
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
140 Path(HgPathError), |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
141 UnsupportedSyntax(String), |
44346
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
142 UnsupportedSyntaxInFile(String, String, usize), |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
143 TooLong(usize), |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
144 IO(std::io::Error), |
44347
2fe89bec8011
rust-filepatterns: add support for `include` and `subinclude` patterns
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44346
diff
changeset
|
145 /// Needed a pattern that can be turned into a regex but got one that |
2fe89bec8011
rust-filepatterns: add support for `include` and `subinclude` patterns
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44346
diff
changeset
|
146 /// can't. This should only happen through programmer error. |
2fe89bec8011
rust-filepatterns: add support for `include` and `subinclude` patterns
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44346
diff
changeset
|
147 NonRegexPattern(IgnorePattern), |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
148 } |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
149 |
44346
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
150 impl ToString for PatternError { |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
151 fn to_string(&self) -> String { |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
152 match self { |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
153 PatternError::UnsupportedSyntax(syntax) => { |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
154 format!("Unsupported syntax {}", syntax) |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
155 } |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
156 PatternError::UnsupportedSyntaxInFile(syntax, file_path, line) => { |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
157 format!( |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
158 "{}:{}: unsupported syntax {}", |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
159 file_path, line, syntax |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
160 ) |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
161 } |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
162 PatternError::TooLong(size) => { |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
163 format!("matcher pattern is too long ({} bytes)", size) |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
164 } |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
165 PatternError::IO(e) => e.to_string(), |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
166 PatternError::Path(e) => e.to_string(), |
44347
2fe89bec8011
rust-filepatterns: add support for `include` and `subinclude` patterns
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44346
diff
changeset
|
167 PatternError::NonRegexPattern(pattern) => { |
2fe89bec8011
rust-filepatterns: add support for `include` and `subinclude` patterns
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44346
diff
changeset
|
168 format!("'{:?}' cannot be turned into a regex", pattern) |
2fe89bec8011
rust-filepatterns: add support for `include` and `subinclude` patterns
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44346
diff
changeset
|
169 } |
44346
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
170 } |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
171 } |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
172 } |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
173 |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
174 impl From<DirstateMapError> for DirstateError { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
175 fn from(e: DirstateMapError) -> Self { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
176 DirstateError::Map(e) |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
177 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
178 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
179 |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
180 impl From<std::io::Error> for DirstateError { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
181 fn from(e: std::io::Error) -> Self { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
182 DirstateError::IO(e) |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
183 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
184 } |
44346
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
185 |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
186 impl From<std::io::Error> for PatternError { |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
187 fn from(e: std::io::Error) -> Self { |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
188 PatternError::IO(e) |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
189 } |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
190 } |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
191 |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
192 impl From<HgPathError> for PatternError { |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
193 fn from(e: HgPathError) -> Self { |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
194 PatternError::Path(e) |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
195 } |
d42eea9a0494
rust-filepatterns: improve API and robustness for pattern files parsing
Rapha?l Gom?s <rgomes@octobus.net>
parents:
44329
diff
changeset
|
196 } |