Mercurial > public > mercurial-scm > hg-stable
annotate rust/hg-core/src/lib.rs @ 43490:a77d4fe347a4
rust-matchers: add `Matcher` trait and implement `AlwaysMatcher`
In our quest of a faster Mercurial, we have arrived at the point where we need
to implement the matchers in Rust.
This RFC mainly for the `Matcher` trait to see if the changes proposed feel
fine to people with more experience on the matter. While the `AlwaysMatcher`
implementation is here as a trivial example, it should be the first step
towards matchers use in Rust as it is currently the only supported one.
Notable changes:
- `exact` is renamed to `exact_match`
- enums for `visit*` methods with `Recursive` instead of `'all'`, etc.
- a new `roots`, separate from `file_set`
- no `bad`, `explicitdir` or `traversedir` functions as they can be passed
to the high functions instead of the matchers
Thanks to Martin for suggesting the last two (most important) changes and for
reaching out to help a few weeks ago.
Differential Revision: https://phab.mercurial-scm.org/D7178
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Tue, 29 Oct 2019 17:16:28 +0100 |
parents | 99394e6c5d12 |
children | 1fe2e574616e |
rev | line source |
---|---|
40271
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
1 // Copyright 2018 Georges Racinet <gracinet@anybox.fr> |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
2 // |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
3 // 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
|
4 // GNU General Public License version 2 or any later version. |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
5 mod ancestors; |
41242
47881d2a9d99
rust: dagop.headrevs() Rust counterparts
Georges Racinet on ishtar.racinet.fr <georges@racinet.fr>
parents:
41241
diff
changeset
|
6 pub mod dagops; |
41057
ef54bd33b476
rust: core implementation for lazyancestors
Georges Racinet <gracinet@anybox.fr>
parents:
40972
diff
changeset
|
7 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
|
8 mod dirstate; |
42216
10b465d61556
rust-discovery: starting core implementation
Georges Racinet <georges.racinet@octobus.net>
parents:
41728
diff
changeset
|
9 pub mod discovery; |
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
|
10 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
|
11 pub use dirstate::{ |
42891
a03a29462c0a
rust-dirstate: specify concrete return type of DirsMultiset::iter()
Yuya Nishihara <yuya@tcha.org>
parents:
42818
diff
changeset
|
12 dirs_multiset::{DirsMultiset, DirsMultisetIter}, |
42769
fce6dc93a510
rust-dirstate: rust implementation of dirstatemap
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42765
diff
changeset
|
13 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
|
14 parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE}, |
43271
99394e6c5d12
rust-dirstate-status: add first Rust implementation of `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42960
diff
changeset
|
15 status::status, |
42892
7083ac37314f
rust-dirstate: provide CopyMapIter and StateMapIter types
Yuya Nishihara <yuya@tcha.org>
parents:
42891
diff
changeset
|
16 CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState, |
7083ac37314f
rust-dirstate: provide CopyMapIter and StateMapIter types
Yuya Nishihara <yuya@tcha.org>
parents:
42891
diff
changeset
|
17 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
|
18 }; |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
19 mod filepatterns; |
43490
a77d4fe347a4
rust-matchers: add `Matcher` trait and implement `AlwaysMatcher`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
43271
diff
changeset
|
20 pub mod matchers; |
42610
5672bb73f61e
rust-utils: add docstrings and doctests for utils.rs
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42609
diff
changeset
|
21 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
|
22 |
42960
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42892
diff
changeset
|
23 use crate::utils::hg_path::HgPathBuf; |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
24 pub use filepatterns::{ |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
25 build_single_regex, read_pattern_file, PatternSyntax, PatternTuple, |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
26 }; |
40271
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
27 |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
28 /// Mercurial revision numbers |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
29 /// |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
30 /// As noted in revlog.c, revision numbers are actually encoded in |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
31 /// 4 bytes, and are liberally converted to ints, whence the i32 |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
32 pub type Revision = i32; |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
33 |
41728
9060af281be7
rust: itering less on MissingAncestors.bases for max()
Georges Racinet <georges.racinet@octobus.net>
parents:
41703
diff
changeset
|
34 /// Marker expressing the absence of a parent |
9060af281be7
rust: itering less on MissingAncestors.bases for max()
Georges Racinet <georges.racinet@octobus.net>
parents:
41703
diff
changeset
|
35 /// |
9060af281be7
rust: itering less on MissingAncestors.bases for max()
Georges Racinet <georges.racinet@octobus.net>
parents:
41703
diff
changeset
|
36 /// Independently of the actual representation, `NULL_REVISION` is guaranteed |
9060af281be7
rust: itering less on MissingAncestors.bases for max()
Georges Racinet <georges.racinet@octobus.net>
parents:
41703
diff
changeset
|
37 /// to be smaller that all existing revisions. |
40271
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
38 pub const NULL_REVISION: Revision = -1; |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
39 |
41308
2f54f31c41aa
rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents:
41242
diff
changeset
|
40 /// Same as `mercurial.node.wdirrev` |
2f54f31c41aa
rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents:
41242
diff
changeset
|
41 /// |
2f54f31c41aa
rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents:
41242
diff
changeset
|
42 /// This is also equal to `i32::max_value()`, but it's better to spell |
2f54f31c41aa
rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents:
41242
diff
changeset
|
43 /// it out explicitely, same as in `mercurial.node` |
2f54f31c41aa
rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents:
41242
diff
changeset
|
44 pub const WORKING_DIRECTORY_REVISION: Revision = 0x7fffffff; |
2f54f31c41aa
rust: working directory revision number constant
Georges Racinet <georges.racinet@octobus.net>
parents:
41242
diff
changeset
|
45 |
40271
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
46 /// The simplest expression of what we need of Mercurial DAGs. |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
47 pub trait Graph { |
40972
d097dd0afc19
rust: translation of missingancestors
Georges Racinet <gracinet@anybox.fr>
parents:
40950
diff
changeset
|
48 /// Return the two parents of the given `Revision`. |
d097dd0afc19
rust: translation of missingancestors
Georges Racinet <gracinet@anybox.fr>
parents:
40950
diff
changeset
|
49 /// |
d097dd0afc19
rust: translation of missingancestors
Georges Racinet <gracinet@anybox.fr>
parents:
40950
diff
changeset
|
50 /// Each of the parents can be independently `NULL_REVISION` |
42609
326fdce22fb2
rust: switch hg-core and hg-cpython to rust 2018 edition
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42543
diff
changeset
|
51 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError>; |
40271
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
52 } |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
53 |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
54 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
|
55 |
40271
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
56 #[derive(Clone, Debug, PartialEq)] |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
57 pub enum GraphError { |
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
58 ParentOutOfRange(Revision), |
41309
ee943a920606
rust: error for WdirUnsupported with cpython conversion as exception
Georges Racinet <georges.racinet@octobus.net>
parents:
41308
diff
changeset
|
59 WorkingDirectoryUnsupported, |
40271
dbc28c91f7ff
rust: pure Rust lazyancestors iterator
Georges Racinet <gracinet@anybox.fr>
parents:
diff
changeset
|
60 } |
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 |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
62 #[derive(Clone, 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
|
63 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
|
64 TooLittleData, |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
65 Overflow, |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
66 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
|
67 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
|
68 } |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
69 |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
70 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
|
71 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
|
72 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
|
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 |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
76 impl ToString for DirstateParseError { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
77 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
|
78 use crate::DirstateParseError::*; |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
79 match self { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
80 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
|
81 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
|
82 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
|
83 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
|
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 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
87 |
42329
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
88 #[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
|
89 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
|
90 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
|
91 CorruptedParent, |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
92 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
|
93 } |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
94 |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
95 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
|
96 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
|
97 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
|
98 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
99 } |
42543
2dcee6497b0b
rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42453
diff
changeset
|
100 #[derive(Debug, PartialEq)] |
2dcee6497b0b
rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42453
diff
changeset
|
101 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
|
102 PathNotFound(HgPathBuf), |
42543
2dcee6497b0b
rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42453
diff
changeset
|
103 EmptyPath, |
2dcee6497b0b
rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42453
diff
changeset
|
104 } |
2dcee6497b0b
rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42453
diff
changeset
|
105 |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
106 pub enum DirstateError { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
107 Parse(DirstateParseError), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
108 Pack(DirstatePackError), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
109 Map(DirstateMapError), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
110 IO(std::io::Error), |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
111 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
112 |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
113 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
|
114 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
|
115 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
|
116 } |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
117 } |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
118 |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 } |
d1786c1d34fa
rust-dirstate: add rust implementation of `parse_dirstate` and `pack_dirstate`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42216
diff
changeset
|
123 } |
42349
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
124 |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
125 #[derive(Debug)] |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
126 pub enum PatternError { |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
127 UnsupportedSyntax(String), |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
128 } |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
129 |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
130 #[derive(Debug)] |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
131 pub enum PatternFileError { |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
132 IO(std::io::Error), |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
133 Pattern(PatternError, LineNumber), |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
134 } |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
135 |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
136 impl From<std::io::Error> for PatternFileError { |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
137 fn from(e: std::io::Error) -> Self { |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
138 PatternFileError::IO(e) |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
139 } |
e8f3740cc067
rust-filepatterns: add a Rust implementation of pattern-related utils
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42330
diff
changeset
|
140 } |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
141 |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
142 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
|
143 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
|
144 DirstateError::Map(e) |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
145 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
146 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
147 |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
148 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
|
149 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
|
150 DirstateError::IO(e) |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
151 } |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents:
42764
diff
changeset
|
152 } |