Show More
@@ -199,6 +199,16 b' dependencies = [' | |||||
199 | ] |
|
199 | ] | |
200 |
|
200 | |||
201 | [[package]] |
|
201 | [[package]] | |
|
202 | name = "derive_more" | |||
|
203 | version = "0.99.11" | |||
|
204 | source = "registry+https://github.com/rust-lang/crates.io-index" | |||
|
205 | dependencies = [ | |||
|
206 | "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", | |||
|
207 | "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", | |||
|
208 | "syn 1.0.54 (registry+https://github.com/rust-lang/crates.io-index)", | |||
|
209 | ] | |||
|
210 | ||||
|
211 | [[package]] | |||
202 | name = "difference" |
|
212 | name = "difference" | |
203 | version = "2.0.0" |
|
213 | version = "2.0.0" | |
204 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
214 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
@@ -293,6 +303,7 b' dependencies = [' | |||||
293 | "bytes-cast 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
|
303 | "bytes-cast 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | |
294 | "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", |
|
304 | "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", | |
295 | "crossbeam-channel 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", |
|
305 | "crossbeam-channel 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", | |
|
306 | "derive_more 0.99.11 (registry+https://github.com/rust-lang/crates.io-index)", | |||
296 | "flate2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", |
|
307 | "flate2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", | |
297 | "format-bytes 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", |
|
308 | "format-bytes 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | |
298 | "im-rc 15.0.0 (registry+https://github.com/rust-lang/crates.io-index)", |
|
309 | "im-rc 15.0.0 (registry+https://github.com/rust-lang/crates.io-index)", | |
@@ -696,6 +707,7 b' name = "rhg"' | |||||
696 | version = "0.1.0" |
|
707 | version = "0.1.0" | |
697 | dependencies = [ |
|
708 | dependencies = [ | |
698 | "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", |
|
709 | "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", | |
|
710 | "derive_more 0.99.11 (registry+https://github.com/rust-lang/crates.io-index)", | |||
699 | "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", |
|
711 | "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", | |
700 | "format-bytes 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", |
|
712 | "format-bytes 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | |
701 | "hg-core 0.1.0", |
|
713 | "hg-core 0.1.0", | |
@@ -939,6 +951,7 b' dependencies = [' | |||||
939 | "checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" |
|
951 | "checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" | |
940 | "checksum crossbeam-utils 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" |
|
952 | "checksum crossbeam-utils 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" | |
941 | "checksum ctor 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "7fbaabec2c953050352311293be5c6aba8e141ba19d6811862b232d6fd020484" |
|
953 | "checksum ctor 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "7fbaabec2c953050352311293be5c6aba8e141ba19d6811862b232d6fd020484" | |
|
954 | "checksum derive_more 0.99.11 (registry+https://github.com/rust-lang/crates.io-index)" = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" | |||
942 | "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" |
|
955 | "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" | |
943 | "checksum either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" |
|
956 | "checksum either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" | |
944 | "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" |
|
957 | "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" |
@@ -11,6 +11,7 b' name = "hg"' | |||||
11 | [dependencies] |
|
11 | [dependencies] | |
12 | bytes-cast = "0.1" |
|
12 | bytes-cast = "0.1" | |
13 | byteorder = "1.3.4" |
|
13 | byteorder = "1.3.4" | |
|
14 | derive_more = "0.99" | |||
14 | im-rc = "15.0.*" |
|
15 | im-rc = "15.0.*" | |
15 | lazy_static = "1.4.0" |
|
16 | lazy_static = "1.4.0" | |
16 | memchr = "2.3.3" |
|
17 | memchr = "2.3.3" |
@@ -226,7 +226,7 b' impl ConfigOrigin {' | |||||
226 | } |
|
226 | } | |
227 | } |
|
227 | } | |
228 |
|
228 | |||
229 | #[derive(Debug)] |
|
229 | #[derive(Debug, derive_more::From)] | |
230 | pub enum ConfigError { |
|
230 | pub enum ConfigError { | |
231 | Parse { |
|
231 | Parse { | |
232 | origin: ConfigOrigin, |
|
232 | origin: ConfigOrigin, | |
@@ -239,15 +239,10 b' pub enum ConfigError {' | |||||
239 | io_error: std::io::Error, |
|
239 | io_error: std::io::Error, | |
240 | }, |
|
240 | }, | |
241 | /// Any IO error that isn't expected |
|
241 | /// Any IO error that isn't expected | |
|
242 | #[from] | |||
242 | IO(std::io::Error), |
|
243 | IO(std::io::Error), | |
243 | } |
|
244 | } | |
244 |
|
245 | |||
245 | impl From<std::io::Error> for ConfigError { |
|
|||
246 | fn from(e: std::io::Error) -> Self { |
|
|||
247 | Self::IO(e) |
|
|||
248 | } |
|
|||
249 | } |
|
|||
250 |
|
||||
251 | fn make_regex(pattern: &'static str) -> Regex { |
|
246 | fn make_regex(pattern: &'static str) -> Regex { | |
252 | Regex::new(pattern).expect("expected a valid regex") |
|
247 | Regex::new(pattern).expect("expected a valid regex") | |
253 | } |
|
248 | } |
@@ -265,7 +265,7 b" pub struct DirstateStatus<'a> {" | |||||
265 | pub traversed: Vec<HgPathBuf>, |
|
265 | pub traversed: Vec<HgPathBuf>, | |
266 | } |
|
266 | } | |
267 |
|
267 | |||
268 | #[derive(Debug)] |
|
268 | #[derive(Debug, derive_more::From)] | |
269 | pub enum StatusError { |
|
269 | pub enum StatusError { | |
270 | /// Generic IO error |
|
270 | /// Generic IO error | |
271 | IO(std::io::Error), |
|
271 | IO(std::io::Error), | |
@@ -277,22 +277,6 b' pub enum StatusError {' | |||||
277 |
|
277 | |||
278 | pub type StatusResult<T> = Result<T, StatusError>; |
|
278 | pub type StatusResult<T> = Result<T, StatusError>; | |
279 |
|
279 | |||
280 | impl From<PatternError> for StatusError { |
|
|||
281 | fn from(e: PatternError) -> Self { |
|
|||
282 | StatusError::Pattern(e) |
|
|||
283 | } |
|
|||
284 | } |
|
|||
285 | impl From<HgPathError> for StatusError { |
|
|||
286 | fn from(e: HgPathError) -> Self { |
|
|||
287 | StatusError::Path(e) |
|
|||
288 | } |
|
|||
289 | } |
|
|||
290 | impl From<std::io::Error> for StatusError { |
|
|||
291 | fn from(e: std::io::Error) -> Self { |
|
|||
292 | StatusError::IO(e) |
|
|||
293 | } |
|
|||
294 | } |
|
|||
295 |
|
||||
296 | impl ToString for StatusError { |
|
280 | impl ToString for StatusError { | |
297 | fn to_string(&self) -> String { |
|
281 | fn to_string(&self) -> String { | |
298 | match self { |
|
282 | match self { |
@@ -89,6 +89,7 b' impl From<std::io::Error> for DirstatePa' | |||||
89 | DirstatePackError::CorruptedEntry(e.to_string()) |
|
89 | DirstatePackError::CorruptedEntry(e.to_string()) | |
90 | } |
|
90 | } | |
91 | } |
|
91 | } | |
|
92 | ||||
92 | #[derive(Debug, PartialEq)] |
|
93 | #[derive(Debug, PartialEq)] | |
93 | pub enum DirstateMapError { |
|
94 | pub enum DirstateMapError { | |
94 | PathNotFound(HgPathBuf), |
|
95 | PathNotFound(HgPathBuf), | |
@@ -108,7 +109,7 b' impl ToString for DirstateMapError {' | |||||
108 | } |
|
109 | } | |
109 | } |
|
110 | } | |
110 |
|
111 | |||
111 | #[derive(Debug)] |
|
112 | #[derive(Debug, derive_more::From)] | |
112 | pub enum DirstateError { |
|
113 | pub enum DirstateError { | |
113 | Parse(DirstateParseError), |
|
114 | Parse(DirstateParseError), | |
114 | Pack(DirstatePackError), |
|
115 | Pack(DirstatePackError), | |
@@ -116,24 +117,14 b' pub enum DirstateError {' | |||||
116 | IO(std::io::Error), |
|
117 | IO(std::io::Error), | |
117 | } |
|
118 | } | |
118 |
|
119 | |||
119 | impl From<DirstateParseError> for DirstateError { |
|
120 | #[derive(Debug, derive_more::From)] | |
120 | fn from(e: DirstateParseError) -> Self { |
|
|||
121 | DirstateError::Parse(e) |
|
|||
122 | } |
|
|||
123 | } |
|
|||
124 |
|
||||
125 | impl From<DirstatePackError> for DirstateError { |
|
|||
126 | fn from(e: DirstatePackError) -> Self { |
|
|||
127 | DirstateError::Pack(e) |
|
|||
128 | } |
|
|||
129 | } |
|
|||
130 |
|
||||
131 | #[derive(Debug)] |
|
|||
132 | pub enum PatternError { |
|
121 | pub enum PatternError { | |
|
122 | #[from] | |||
133 | Path(HgPathError), |
|
123 | Path(HgPathError), | |
134 | UnsupportedSyntax(String), |
|
124 | UnsupportedSyntax(String), | |
135 | UnsupportedSyntaxInFile(String, String, usize), |
|
125 | UnsupportedSyntaxInFile(String, String, usize), | |
136 | TooLong(usize), |
|
126 | TooLong(usize), | |
|
127 | #[from] | |||
137 | IO(std::io::Error), |
|
128 | IO(std::io::Error), | |
138 | /// Needed a pattern that can be turned into a regex but got one that |
|
129 | /// Needed a pattern that can be turned into a regex but got one that | |
139 | /// can't. This should only happen through programmer error. |
|
130 | /// can't. This should only happen through programmer error. | |
@@ -163,27 +154,3 b' impl ToString for PatternError {' | |||||
163 | } |
|
154 | } | |
164 | } |
|
155 | } | |
165 | } |
|
156 | } | |
166 |
|
||||
167 | impl From<DirstateMapError> for DirstateError { |
|
|||
168 | fn from(e: DirstateMapError) -> Self { |
|
|||
169 | DirstateError::Map(e) |
|
|||
170 | } |
|
|||
171 | } |
|
|||
172 |
|
||||
173 | impl From<std::io::Error> for DirstateError { |
|
|||
174 | fn from(e: std::io::Error) -> Self { |
|
|||
175 | DirstateError::IO(e) |
|
|||
176 | } |
|
|||
177 | } |
|
|||
178 |
|
||||
179 | impl From<std::io::Error> for PatternError { |
|
|||
180 | fn from(e: std::io::Error) -> Self { |
|
|||
181 | PatternError::IO(e) |
|
|||
182 | } |
|
|||
183 | } |
|
|||
184 |
|
||||
185 | impl From<HgPathError> for PatternError { |
|
|||
186 | fn from(e: HgPathError) -> Self { |
|
|||
187 | PatternError::Path(e) |
|
|||
188 | } |
|
|||
189 | } |
|
@@ -16,9 +16,10 b' pub enum DebugDataKind {' | |||||
16 | } |
|
16 | } | |
17 |
|
17 | |||
18 | /// Error type for `debug_data` |
|
18 | /// Error type for `debug_data` | |
19 | #[derive(Debug)] |
|
19 | #[derive(Debug, derive_more::From)] | |
20 | pub enum DebugDataError { |
|
20 | pub enum DebugDataError { | |
21 | /// Error when reading a `revlog` file. |
|
21 | /// Error when reading a `revlog` file. | |
|
22 | #[from] | |||
22 | IoError(std::io::Error), |
|
23 | IoError(std::io::Error), | |
23 | /// The revision has not been found. |
|
24 | /// The revision has not been found. | |
24 | InvalidRevision, |
|
25 | InvalidRevision, | |
@@ -32,12 +33,6 b' pub enum DebugDataError {' | |||||
32 | UnknowRevlogDataFormat(u8), |
|
33 | UnknowRevlogDataFormat(u8), | |
33 | } |
|
34 | } | |
34 |
|
35 | |||
35 | impl From<std::io::Error> for DebugDataError { |
|
|||
36 | fn from(err: std::io::Error) -> Self { |
|
|||
37 | DebugDataError::IoError(err) |
|
|||
38 | } |
|
|||
39 | } |
|
|||
40 |
|
||||
41 | impl From<RevlogError> for DebugDataError { |
|
36 | impl From<RevlogError> for DebugDataError { | |
42 | fn from(err: RevlogError) -> Self { |
|
37 | fn from(err: RevlogError) -> Self { | |
43 | match err { |
|
38 | match err { |
@@ -17,7 +17,7 b' use rayon::prelude::*;' | |||||
17 | use std::convert::From; |
|
17 | use std::convert::From; | |
18 |
|
18 | |||
19 | /// Error type for `Dirstate` methods |
|
19 | /// Error type for `Dirstate` methods | |
20 | #[derive(Debug)] |
|
20 | #[derive(Debug, derive_more::From)] | |
21 | pub enum ListDirstateTrackedFilesError { |
|
21 | pub enum ListDirstateTrackedFilesError { | |
22 | /// Error when reading the `dirstate` file |
|
22 | /// Error when reading the `dirstate` file | |
23 | IoError(std::io::Error), |
|
23 | IoError(std::io::Error), | |
@@ -25,12 +25,6 b' pub enum ListDirstateTrackedFilesError {' | |||||
25 | ParseError(DirstateParseError), |
|
25 | ParseError(DirstateParseError), | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | impl From<std::io::Error> for ListDirstateTrackedFilesError { |
|
|||
29 | fn from(err: std::io::Error) -> Self { |
|
|||
30 | ListDirstateTrackedFilesError::IoError(err) |
|
|||
31 | } |
|
|||
32 | } |
|
|||
33 |
|
||||
34 | /// List files under Mercurial control in the working directory |
|
28 | /// List files under Mercurial control in the working directory | |
35 | /// by reading the dirstate |
|
29 | /// by reading the dirstate | |
36 | pub struct Dirstate { |
|
30 | pub struct Dirstate { |
@@ -49,7 +49,7 b' type NodeData = [u8; NODE_BYTES_LENGTH];' | |||||
49 | /// the size or return an error at runtime. |
|
49 | /// the size or return an error at runtime. | |
50 | /// |
|
50 | /// | |
51 | /// [`nybbles_len`]: #method.nybbles_len |
|
51 | /// [`nybbles_len`]: #method.nybbles_len | |
52 | #[derive(Copy, Clone, Debug, PartialEq, BytesCast)] |
|
52 | #[derive(Copy, Clone, Debug, PartialEq, BytesCast, derive_more::From)] | |
53 | #[repr(transparent)] |
|
53 | #[repr(transparent)] | |
54 | pub struct Node { |
|
54 | pub struct Node { | |
55 | data: NodeData, |
|
55 | data: NodeData, | |
@@ -60,12 +60,6 b' pub const NULL_NODE: Node = Node {' | |||||
60 | data: [0; NODE_BYTES_LENGTH], |
|
60 | data: [0; NODE_BYTES_LENGTH], | |
61 | }; |
|
61 | }; | |
62 |
|
62 | |||
63 | impl From<NodeData> for Node { |
|
|||
64 | fn from(data: NodeData) -> Node { |
|
|||
65 | Node { data } |
|
|||
66 | } |
|
|||
67 | } |
|
|||
68 |
|
||||
69 | /// Return an error if the slice has an unexpected length |
|
63 | /// Return an error if the slice has an unexpected length | |
70 | impl<'a> TryFrom<&'a [u8]> for &'a Node { |
|
64 | impl<'a> TryFrom<&'a [u8]> for &'a Node { | |
71 | type Error = (); |
|
65 | type Error = (); |
@@ -367,7 +367,9 b' impl fmt::Display for HgPath {' | |||||
367 | } |
|
367 | } | |
368 | } |
|
368 | } | |
369 |
|
369 | |||
370 | #[derive(Default, Eq, Ord, Clone, PartialEq, PartialOrd, Hash)] |
|
370 | #[derive( | |
|
371 | Default, Eq, Ord, Clone, PartialEq, PartialOrd, Hash, derive_more::From, | |||
|
372 | )] | |||
371 | pub struct HgPathBuf { |
|
373 | pub struct HgPathBuf { | |
372 | inner: Vec<u8>, |
|
374 | inner: Vec<u8>, | |
373 | } |
|
375 | } | |
@@ -408,12 +410,6 b' impl Deref for HgPathBuf {' | |||||
408 | } |
|
410 | } | |
409 | } |
|
411 | } | |
410 |
|
412 | |||
411 | impl From<Vec<u8>> for HgPathBuf { |
|
|||
412 | fn from(vec: Vec<u8>) -> Self { |
|
|||
413 | Self { inner: vec } |
|
|||
414 | } |
|
|||
415 | } |
|
|||
416 |
|
||||
417 | impl<T: ?Sized + AsRef<HgPath>> From<&T> for HgPathBuf { |
|
413 | impl<T: ?Sized + AsRef<HgPath>> From<&T> for HgPathBuf { | |
418 | fn from(s: &T) -> HgPathBuf { |
|
414 | fn from(s: &T) -> HgPathBuf { | |
419 | s.as_ref().to_owned() |
|
415 | s.as_ref().to_owned() |
@@ -10,6 +10,7 b' edition = "2018"' | |||||
10 | [dependencies] |
|
10 | [dependencies] | |
11 | hg-core = { path = "../hg-core"} |
|
11 | hg-core = { path = "../hg-core"} | |
12 | clap = "2.33.1" |
|
12 | clap = "2.33.1" | |
|
13 | derive_more = "0.99" | |||
13 | log = "0.4.11" |
|
14 | log = "0.4.11" | |
14 | micro-timer = "0.3.1" |
|
15 | micro-timer = "0.3.1" | |
15 | env_logger = "0.7.1" |
|
16 | env_logger = "0.7.1" |
@@ -8,13 +8,14 b' use std::convert::From;' | |||||
8 | use std::path::PathBuf; |
|
8 | use std::path::PathBuf; | |
9 |
|
9 | |||
10 | /// The kind of command error |
|
10 | /// The kind of command error | |
11 | #[derive(Debug)] |
|
11 | #[derive(Debug, derive_more::From)] | |
12 | pub enum CommandError { |
|
12 | pub enum CommandError { | |
13 | /// The root of the repository cannot be found |
|
13 | /// The root of the repository cannot be found | |
14 | RootNotFound(PathBuf), |
|
14 | RootNotFound(PathBuf), | |
15 | /// The current directory cannot be found |
|
15 | /// The current directory cannot be found | |
16 | CurrentDirNotFound(std::io::Error), |
|
16 | CurrentDirNotFound(std::io::Error), | |
17 | /// `.hg/requires` |
|
17 | /// `.hg/requires` | |
|
18 | #[from] | |||
18 | RequirementsError(RequirementsError), |
|
19 | RequirementsError(RequirementsError), | |
19 | /// The standard output stream cannot be written to |
|
20 | /// The standard output stream cannot be written to | |
20 | StdoutError, |
|
21 | StdoutError, | |
@@ -93,9 +94,3 b' impl From<FindRootError> for CommandErro' | |||||
93 | } |
|
94 | } | |
94 | } |
|
95 | } | |
95 | } |
|
96 | } | |
96 |
|
||||
97 | impl From<RequirementsError> for CommandError { |
|
|||
98 | fn from(err: RequirementsError) -> Self { |
|
|||
99 | CommandError::RequirementsError(err) |
|
|||
100 | } |
|
|||
101 | } |
|
General Comments 0
You need to be logged in to leave comments.
Login now