##// END OF EJS Templates
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`...
Antoine Cezar -
r45592:513b3ef2 default
parent child Browse files
Show More
@@ -0,0 +1,76
1 use crate::commands::Command;
2 use crate::error::{CommandError, CommandErrorKind};
3 use crate::ui::Ui;
4 use hg::operations::{FindRoot, FindRootError, FindRootErrorKind, Operation};
5 use hg::utils::files::get_bytes_from_path;
6 use std::path::PathBuf;
7
8 pub const HELP_TEXT: &str = "
9 Print the root directory of the current repository.
10
11 Returns 0 on success.
12 ";
13
14 pub struct RootCommand {
15 ui: Ui,
16 }
17
18 impl RootCommand {
19 pub fn new() -> Self {
20 RootCommand { ui: Ui::new() }
21 }
22
23 fn display_found_path(
24 &self,
25 path_buf: PathBuf,
26 ) -> Result<(), CommandError> {
27 let bytes = get_bytes_from_path(path_buf);
28
29 // TODO use formating macro
30 self.ui.write_stdout(&[bytes.as_slice(), b"\n"].concat())?;
31
32 Err(CommandErrorKind::Ok.into())
33 }
34
35 fn display_error(&self, error: FindRootError) -> Result<(), CommandError> {
36 match error.kind {
37 FindRootErrorKind::RootNotFound(path) => {
38 let bytes = get_bytes_from_path(path);
39
40 // TODO use formating macro
41 self.ui.write_stderr(
42 &[
43 b"abort: no repository found in '",
44 bytes.as_slice(),
45 b"' (.hg not found)!\n",
46 ]
47 .concat(),
48 )?;
49
50 Err(CommandErrorKind::RootNotFound.into())
51 }
52 FindRootErrorKind::GetCurrentDirError(e) => {
53 // TODO use formating macro
54 self.ui.write_stderr(
55 &[
56 b"abort: error getting current working directory: ",
57 e.to_string().as_bytes(),
58 b"\n",
59 ]
60 .concat(),
61 )?;
62
63 Err(CommandErrorKind::CurrentDirNotFound.into())
64 }
65 }
66 }
67 }
68
69 impl Command for RootCommand {
70 fn run(&self) -> Result<(), CommandError> {
71 match FindRoot::new().run() {
72 Ok(path_buf) => self.display_found_path(path_buf),
73 Err(e) => self.display_error(e),
74 }
75 }
76 }
@@ -0,0 +1,54
1 use std::io;
2 use std::io::Write;
3
4 pub struct Ui {}
5
6 /// The kind of user interface error
7 pub enum UiError {
8 /// The standard output stream cannot be written to
9 StdoutError(io::Error),
10 /// The standard error stream cannot be written to
11 StderrError(io::Error),
12 }
13
14 /// The commandline user interface
15 impl Ui {
16 pub fn new() -> Self {
17 Ui {}
18 }
19
20 /// Write bytes to stdout
21 pub fn write_stdout(&self, bytes: &[u8]) -> Result<(), UiError> {
22 let mut stdout = io::stdout();
23
24 self.write_stream(&mut stdout, bytes)
25 .or_else(|e| self.into_stdout_error(e))?;
26
27 stdout.flush().or_else(|e| self.into_stdout_error(e))
28 }
29
30 fn into_stdout_error(&self, error: io::Error) -> Result<(), UiError> {
31 self.write_stderr(
32 &[b"abort: ", error.to_string().as_bytes(), b"\n"].concat(),
33 )?;
34 Err(UiError::StdoutError(error))
35 }
36
37 /// Write bytes to stderr
38 pub fn write_stderr(&self, bytes: &[u8]) -> Result<(), UiError> {
39 let mut stderr = io::stderr();
40
41 self.write_stream(&mut stderr, bytes)
42 .or_else(|e| Err(UiError::StderrError(e)))?;
43
44 stderr.flush().or_else(|e| Err(UiError::StderrError(e)))
45 }
46
47 fn write_stream(
48 &self,
49 stream: &mut impl Write,
50 bytes: &[u8],
51 ) -> Result<(), io::Error> {
52 stream.write_all(bytes)
53 }
54 }
@@ -1,723 +1,726
1 1 # This file is automatically @generated by Cargo.
2 2 # It is not intended for manual editing.
3 3 [[package]]
4 4 name = "aho-corasick"
5 5 version = "0.7.10"
6 6 source = "registry+https://github.com/rust-lang/crates.io-index"
7 7 dependencies = [
8 8 "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
9 9 ]
10 10
11 11 [[package]]
12 12 name = "ansi_term"
13 13 version = "0.11.0"
14 14 source = "registry+https://github.com/rust-lang/crates.io-index"
15 15 dependencies = [
16 16 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
17 17 ]
18 18
19 19 [[package]]
20 20 name = "atty"
21 21 version = "0.2.14"
22 22 source = "registry+https://github.com/rust-lang/crates.io-index"
23 23 dependencies = [
24 24 "hermit-abi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
25 25 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
26 26 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
27 27 ]
28 28
29 29 [[package]]
30 30 name = "autocfg"
31 31 version = "1.0.0"
32 32 source = "registry+https://github.com/rust-lang/crates.io-index"
33 33
34 34 [[package]]
35 35 name = "bitflags"
36 36 version = "1.2.1"
37 37 source = "registry+https://github.com/rust-lang/crates.io-index"
38 38
39 39 [[package]]
40 40 name = "byteorder"
41 41 version = "1.3.4"
42 42 source = "registry+https://github.com/rust-lang/crates.io-index"
43 43
44 44 [[package]]
45 45 name = "cfg-if"
46 46 version = "0.1.10"
47 47 source = "registry+https://github.com/rust-lang/crates.io-index"
48 48
49 49 [[package]]
50 50 name = "chrono"
51 51 version = "0.4.11"
52 52 source = "registry+https://github.com/rust-lang/crates.io-index"
53 53 dependencies = [
54 54 "num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
55 55 "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
56 56 "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
57 57 ]
58 58
59 59 [[package]]
60 60 name = "clap"
61 61 version = "2.33.0"
62 62 source = "registry+https://github.com/rust-lang/crates.io-index"
63 63 dependencies = [
64 64 "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
65 65 "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
66 66 "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
67 67 "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
68 68 "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
69 69 "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
70 70 "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
71 71 ]
72 72
73 73 [[package]]
74 74 name = "colored"
75 75 version = "1.9.3"
76 76 source = "registry+https://github.com/rust-lang/crates.io-index"
77 77 dependencies = [
78 78 "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
79 79 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
80 80 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
81 81 ]
82 82
83 83 [[package]]
84 84 name = "cpython"
85 85 version = "0.4.1"
86 86 source = "registry+https://github.com/rust-lang/crates.io-index"
87 87 dependencies = [
88 88 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
89 89 "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
90 90 "python27-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
91 91 "python3-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
92 92 ]
93 93
94 94 [[package]]
95 95 name = "crossbeam"
96 96 version = "0.7.3"
97 97 source = "registry+https://github.com/rust-lang/crates.io-index"
98 98 dependencies = [
99 99 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
100 100 "crossbeam-channel 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
101 101 "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
102 102 "crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
103 103 "crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
104 104 "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
105 105 ]
106 106
107 107 [[package]]
108 108 name = "crossbeam-channel"
109 109 version = "0.4.2"
110 110 source = "registry+https://github.com/rust-lang/crates.io-index"
111 111 dependencies = [
112 112 "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
113 113 "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
114 114 ]
115 115
116 116 [[package]]
117 117 name = "crossbeam-deque"
118 118 version = "0.7.3"
119 119 source = "registry+https://github.com/rust-lang/crates.io-index"
120 120 dependencies = [
121 121 "crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
122 122 "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
123 123 "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
124 124 ]
125 125
126 126 [[package]]
127 127 name = "crossbeam-epoch"
128 128 version = "0.8.2"
129 129 source = "registry+https://github.com/rust-lang/crates.io-index"
130 130 dependencies = [
131 131 "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
132 132 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
133 133 "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
134 134 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
135 135 "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
136 136 "memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
137 137 "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
138 138 ]
139 139
140 140 [[package]]
141 141 name = "crossbeam-queue"
142 142 version = "0.2.1"
143 143 source = "registry+https://github.com/rust-lang/crates.io-index"
144 144 dependencies = [
145 145 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
146 146 "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
147 147 ]
148 148
149 149 [[package]]
150 150 name = "crossbeam-utils"
151 151 version = "0.7.2"
152 152 source = "registry+https://github.com/rust-lang/crates.io-index"
153 153 dependencies = [
154 154 "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
155 155 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
156 156 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
157 157 ]
158 158
159 159 [[package]]
160 160 name = "ctor"
161 161 version = "0.1.13"
162 162 source = "registry+https://github.com/rust-lang/crates.io-index"
163 163 dependencies = [
164 164 "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
165 165 "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
166 166 ]
167 167
168 168 [[package]]
169 169 name = "difference"
170 170 version = "2.0.0"
171 171 source = "registry+https://github.com/rust-lang/crates.io-index"
172 172
173 173 [[package]]
174 174 name = "either"
175 175 version = "1.5.3"
176 176 source = "registry+https://github.com/rust-lang/crates.io-index"
177 177
178 178 [[package]]
179 179 name = "getrandom"
180 180 version = "0.1.14"
181 181 source = "registry+https://github.com/rust-lang/crates.io-index"
182 182 dependencies = [
183 183 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
184 184 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
185 185 "wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
186 186 ]
187 187
188 188 [[package]]
189 189 name = "hermit-abi"
190 190 version = "0.1.8"
191 191 source = "registry+https://github.com/rust-lang/crates.io-index"
192 192 dependencies = [
193 193 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
194 194 ]
195 195
196 196 [[package]]
197 197 name = "hex"
198 198 version = "0.4.2"
199 199 source = "registry+https://github.com/rust-lang/crates.io-index"
200 200
201 201 [[package]]
202 202 name = "hg-core"
203 203 version = "0.1.0"
204 204 dependencies = [
205 205 "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
206 206 "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
207 207 "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
208 208 "hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
209 209 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
210 210 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
211 211 "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
212 212 "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
213 213 "micro-timer 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
214 214 "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
215 215 "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
216 216 "rand_distr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
217 217 "rand_pcg 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
218 218 "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
219 219 "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
220 220 "same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
221 221 "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
222 222 "twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
223 223 ]
224 224
225 225 [[package]]
226 226 name = "hg-cpython"
227 227 version = "0.1.0"
228 228 dependencies = [
229 229 "cpython 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
230 230 "hg-core 0.1.0",
231 231 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
232 232 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
233 233 "simple_logger 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
234 234 ]
235 235
236 236 [[package]]
237 237 name = "lazy_static"
238 238 version = "1.4.0"
239 239 source = "registry+https://github.com/rust-lang/crates.io-index"
240 240
241 241 [[package]]
242 242 name = "libc"
243 243 version = "0.2.67"
244 244 source = "registry+https://github.com/rust-lang/crates.io-index"
245 245
246 246 [[package]]
247 247 name = "log"
248 248 version = "0.4.8"
249 249 source = "registry+https://github.com/rust-lang/crates.io-index"
250 250 dependencies = [
251 251 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
252 252 ]
253 253
254 254 [[package]]
255 255 name = "maybe-uninit"
256 256 version = "2.0.0"
257 257 source = "registry+https://github.com/rust-lang/crates.io-index"
258 258
259 259 [[package]]
260 260 name = "memchr"
261 261 version = "2.3.3"
262 262 source = "registry+https://github.com/rust-lang/crates.io-index"
263 263
264 264 [[package]]
265 265 name = "memmap"
266 266 version = "0.7.0"
267 267 source = "registry+https://github.com/rust-lang/crates.io-index"
268 268 dependencies = [
269 269 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
270 270 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
271 271 ]
272 272
273 273 [[package]]
274 274 name = "memoffset"
275 275 version = "0.5.3"
276 276 source = "registry+https://github.com/rust-lang/crates.io-index"
277 277 dependencies = [
278 278 "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
279 279 ]
280 280
281 281 [[package]]
282 282 name = "micro-timer"
283 283 version = "0.3.0"
284 284 source = "registry+https://github.com/rust-lang/crates.io-index"
285 285 dependencies = [
286 286 "micro-timer-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
287 287 "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
288 288 ]
289 289
290 290 [[package]]
291 291 name = "micro-timer-macros"
292 292 version = "0.3.0"
293 293 source = "registry+https://github.com/rust-lang/crates.io-index"
294 294 dependencies = [
295 295 "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
296 296 "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
297 297 "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
298 298 "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
299 299 ]
300 300
301 301 [[package]]
302 302 name = "num-integer"
303 303 version = "0.1.42"
304 304 source = "registry+https://github.com/rust-lang/crates.io-index"
305 305 dependencies = [
306 306 "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
307 307 "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
308 308 ]
309 309
310 310 [[package]]
311 311 name = "num-traits"
312 312 version = "0.2.11"
313 313 source = "registry+https://github.com/rust-lang/crates.io-index"
314 314 dependencies = [
315 315 "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
316 316 ]
317 317
318 318 [[package]]
319 319 name = "num_cpus"
320 320 version = "1.12.0"
321 321 source = "registry+https://github.com/rust-lang/crates.io-index"
322 322 dependencies = [
323 323 "hermit-abi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
324 324 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
325 325 ]
326 326
327 327 [[package]]
328 328 name = "output_vt100"
329 329 version = "0.1.2"
330 330 source = "registry+https://github.com/rust-lang/crates.io-index"
331 331 dependencies = [
332 332 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
333 333 ]
334 334
335 335 [[package]]
336 336 name = "ppv-lite86"
337 337 version = "0.2.6"
338 338 source = "registry+https://github.com/rust-lang/crates.io-index"
339 339
340 340 [[package]]
341 341 name = "pretty_assertions"
342 342 version = "0.6.1"
343 343 source = "registry+https://github.com/rust-lang/crates.io-index"
344 344 dependencies = [
345 345 "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
346 346 "ctor 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
347 347 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
348 348 "output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
349 349 ]
350 350
351 351 [[package]]
352 352 name = "proc-macro2"
353 353 version = "1.0.9"
354 354 source = "registry+https://github.com/rust-lang/crates.io-index"
355 355 dependencies = [
356 356 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
357 357 ]
358 358
359 359 [[package]]
360 360 name = "python27-sys"
361 361 version = "0.4.1"
362 362 source = "registry+https://github.com/rust-lang/crates.io-index"
363 363 dependencies = [
364 364 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
365 365 "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
366 366 ]
367 367
368 368 [[package]]
369 369 name = "python3-sys"
370 370 version = "0.4.1"
371 371 source = "registry+https://github.com/rust-lang/crates.io-index"
372 372 dependencies = [
373 373 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
374 374 "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
375 375 ]
376 376
377 377 [[package]]
378 378 name = "quote"
379 379 version = "1.0.3"
380 380 source = "registry+https://github.com/rust-lang/crates.io-index"
381 381 dependencies = [
382 382 "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
383 383 ]
384 384
385 385 [[package]]
386 386 name = "rand"
387 387 version = "0.7.3"
388 388 source = "registry+https://github.com/rust-lang/crates.io-index"
389 389 dependencies = [
390 390 "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
391 391 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
392 392 "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
393 393 "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
394 394 "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
395 395 ]
396 396
397 397 [[package]]
398 398 name = "rand_chacha"
399 399 version = "0.2.2"
400 400 source = "registry+https://github.com/rust-lang/crates.io-index"
401 401 dependencies = [
402 402 "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
403 403 "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
404 404 ]
405 405
406 406 [[package]]
407 407 name = "rand_core"
408 408 version = "0.5.1"
409 409 source = "registry+https://github.com/rust-lang/crates.io-index"
410 410 dependencies = [
411 411 "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
412 412 ]
413 413
414 414 [[package]]
415 415 name = "rand_distr"
416 416 version = "0.2.2"
417 417 source = "registry+https://github.com/rust-lang/crates.io-index"
418 418 dependencies = [
419 419 "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
420 420 ]
421 421
422 422 [[package]]
423 423 name = "rand_hc"
424 424 version = "0.2.0"
425 425 source = "registry+https://github.com/rust-lang/crates.io-index"
426 426 dependencies = [
427 427 "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
428 428 ]
429 429
430 430 [[package]]
431 431 name = "rand_pcg"
432 432 version = "0.2.1"
433 433 source = "registry+https://github.com/rust-lang/crates.io-index"
434 434 dependencies = [
435 435 "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
436 436 ]
437 437
438 438 [[package]]
439 439 name = "rayon"
440 440 version = "1.3.0"
441 441 source = "registry+https://github.com/rust-lang/crates.io-index"
442 442 dependencies = [
443 443 "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
444 444 "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
445 445 "rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
446 446 ]
447 447
448 448 [[package]]
449 449 name = "rayon-core"
450 450 version = "1.7.0"
451 451 source = "registry+https://github.com/rust-lang/crates.io-index"
452 452 dependencies = [
453 453 "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
454 454 "crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
455 455 "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
456 456 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
457 457 "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
458 458 ]
459 459
460 460 [[package]]
461 461 name = "redox_syscall"
462 462 version = "0.1.56"
463 463 source = "registry+https://github.com/rust-lang/crates.io-index"
464 464
465 465 [[package]]
466 466 name = "regex"
467 467 version = "1.3.9"
468 468 source = "registry+https://github.com/rust-lang/crates.io-index"
469 469 dependencies = [
470 470 "aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
471 471 "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
472 472 "regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
473 473 "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
474 474 ]
475 475
476 476 [[package]]
477 477 name = "regex-syntax"
478 478 version = "0.6.18"
479 479 source = "registry+https://github.com/rust-lang/crates.io-index"
480 480
481 481 [[package]]
482 482 name = "remove_dir_all"
483 483 version = "0.5.2"
484 484 source = "registry+https://github.com/rust-lang/crates.io-index"
485 485 dependencies = [
486 486 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
487 487 ]
488 488
489 489 [[package]]
490 490 name = "rhg"
491 491 version = "0.1.0"
492 dependencies = [
493 "hg-core 0.1.0",
494 ]
492 495
493 496 [[package]]
494 497 name = "rustc_version"
495 498 version = "0.2.3"
496 499 source = "registry+https://github.com/rust-lang/crates.io-index"
497 500 dependencies = [
498 501 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
499 502 ]
500 503
501 504 [[package]]
502 505 name = "same-file"
503 506 version = "1.0.6"
504 507 source = "registry+https://github.com/rust-lang/crates.io-index"
505 508 dependencies = [
506 509 "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
507 510 ]
508 511
509 512 [[package]]
510 513 name = "scopeguard"
511 514 version = "1.1.0"
512 515 source = "registry+https://github.com/rust-lang/crates.io-index"
513 516
514 517 [[package]]
515 518 name = "semver"
516 519 version = "0.9.0"
517 520 source = "registry+https://github.com/rust-lang/crates.io-index"
518 521 dependencies = [
519 522 "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
520 523 ]
521 524
522 525 [[package]]
523 526 name = "semver-parser"
524 527 version = "0.7.0"
525 528 source = "registry+https://github.com/rust-lang/crates.io-index"
526 529
527 530 [[package]]
528 531 name = "simple_logger"
529 532 version = "1.6.0"
530 533 source = "registry+https://github.com/rust-lang/crates.io-index"
531 534 dependencies = [
532 535 "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
533 536 "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
534 537 "colored 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
535 538 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
536 539 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
537 540 ]
538 541
539 542 [[package]]
540 543 name = "strsim"
541 544 version = "0.8.0"
542 545 source = "registry+https://github.com/rust-lang/crates.io-index"
543 546
544 547 [[package]]
545 548 name = "syn"
546 549 version = "1.0.16"
547 550 source = "registry+https://github.com/rust-lang/crates.io-index"
548 551 dependencies = [
549 552 "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
550 553 "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
551 554 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
552 555 ]
553 556
554 557 [[package]]
555 558 name = "tempfile"
556 559 version = "3.1.0"
557 560 source = "registry+https://github.com/rust-lang/crates.io-index"
558 561 dependencies = [
559 562 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
560 563 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
561 564 "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
562 565 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
563 566 "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
564 567 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
565 568 ]
566 569
567 570 [[package]]
568 571 name = "textwrap"
569 572 version = "0.11.0"
570 573 source = "registry+https://github.com/rust-lang/crates.io-index"
571 574 dependencies = [
572 575 "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
573 576 ]
574 577
575 578 [[package]]
576 579 name = "thread_local"
577 580 version = "1.0.1"
578 581 source = "registry+https://github.com/rust-lang/crates.io-index"
579 582 dependencies = [
580 583 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
581 584 ]
582 585
583 586 [[package]]
584 587 name = "time"
585 588 version = "0.1.42"
586 589 source = "registry+https://github.com/rust-lang/crates.io-index"
587 590 dependencies = [
588 591 "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
589 592 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
590 593 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
591 594 ]
592 595
593 596 [[package]]
594 597 name = "twox-hash"
595 598 version = "1.5.0"
596 599 source = "registry+https://github.com/rust-lang/crates.io-index"
597 600 dependencies = [
598 601 "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
599 602 ]
600 603
601 604 [[package]]
602 605 name = "unicode-width"
603 606 version = "0.1.7"
604 607 source = "registry+https://github.com/rust-lang/crates.io-index"
605 608
606 609 [[package]]
607 610 name = "unicode-xid"
608 611 version = "0.2.0"
609 612 source = "registry+https://github.com/rust-lang/crates.io-index"
610 613
611 614 [[package]]
612 615 name = "vec_map"
613 616 version = "0.8.1"
614 617 source = "registry+https://github.com/rust-lang/crates.io-index"
615 618
616 619 [[package]]
617 620 name = "wasi"
618 621 version = "0.9.0+wasi-snapshot-preview1"
619 622 source = "registry+https://github.com/rust-lang/crates.io-index"
620 623
621 624 [[package]]
622 625 name = "winapi"
623 626 version = "0.3.8"
624 627 source = "registry+https://github.com/rust-lang/crates.io-index"
625 628 dependencies = [
626 629 "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
627 630 "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
628 631 ]
629 632
630 633 [[package]]
631 634 name = "winapi-i686-pc-windows-gnu"
632 635 version = "0.4.0"
633 636 source = "registry+https://github.com/rust-lang/crates.io-index"
634 637
635 638 [[package]]
636 639 name = "winapi-util"
637 640 version = "0.1.3"
638 641 source = "registry+https://github.com/rust-lang/crates.io-index"
639 642 dependencies = [
640 643 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
641 644 ]
642 645
643 646 [[package]]
644 647 name = "winapi-x86_64-pc-windows-gnu"
645 648 version = "0.4.0"
646 649 source = "registry+https://github.com/rust-lang/crates.io-index"
647 650
648 651 [metadata]
649 652 "checksum aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada"
650 653 "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
651 654 "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
652 655 "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
653 656 "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
654 657 "checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
655 658 "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
656 659 "checksum chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2"
657 660 "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
658 661 "checksum colored 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59"
659 662 "checksum cpython 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bfaf3847ab963e40c4f6dd8d6be279bdf74007ae2413786a0dcbb28c52139a95"
660 663 "checksum crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e"
661 664 "checksum crossbeam-channel 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cced8691919c02aac3cb0a1bc2e9b73d89e832bf9a06fc579d4e71b68a2da061"
662 665 "checksum crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"
663 666 "checksum crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
664 667 "checksum crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db"
665 668 "checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
666 669 "checksum ctor 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "47c5e5ac752e18207b12e16b10631ae5f7f68f8805f335f9b817ead83d9ffce1"
667 670 "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
668 671 "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
669 672 "checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
670 673 "checksum hermit-abi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
671 674 "checksum hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"
672 675 "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
673 676 "checksum libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)" = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018"
674 677 "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
675 678 "checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
676 679 "checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
677 680 "checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
678 681 "checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9"
679 682 "checksum micro-timer 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "25b31d6cb9112984323d05d7a353f272ae5d7a307074f9ab9b25c00121b8c947"
680 683 "checksum micro-timer-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5694085dd384bb9e824207facc040c248d9df653f55e28c3ad0686958b448504"
681 684 "checksum num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba"
682 685 "checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
683 686 "checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6"
684 687 "checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9"
685 688 "checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
686 689 "checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427"
687 690 "checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435"
688 691 "checksum python27-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "67cb041de8615111bf224dd75667af5f25c6e032118251426fed7f1b70ce4c8c"
689 692 "checksum python3-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90af11779515a1e530af60782d273b59ac79d33b0e253c071a728563957c76d4"
690 693 "checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
691 694 "checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
692 695 "checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
693 696 "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
694 697 "checksum rand_distr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96977acbdd3a6576fb1d27391900035bf3863d4a16422973a409b488cf29ffb2"
695 698 "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
696 699 "checksum rand_pcg 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429"
697 700 "checksum rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098"
698 701 "checksum rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9"
699 702 "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
700 703 "checksum regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
701 704 "checksum regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
702 705 "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
703 706 "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
704 707 "checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
705 708 "checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
706 709 "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
707 710 "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
708 711 "checksum simple_logger 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fea0c4611f32f4c2bac73754f22dca1f57e6c1945e0590dae4e5f2a077b92367"
709 712 "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
710 713 "checksum syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859"
711 714 "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
712 715 "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
713 716 "checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
714 717 "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
715 718 "checksum twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56"
716 719 "checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
717 720 "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
718 721 "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
719 722 "checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
720 723 "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
721 724 "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
722 725 "checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"
723 726 "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
@@ -1,8 +1,9
1 1 [package]
2 2 name = "rhg"
3 3 version = "0.1.0"
4 4 authors = ["Antoine Cezar <antoine.cezar@octobus.net>"]
5 5 edition = "2018"
6 6
7 7 [dependencies]
8 hg-core = { path = "../hg-core"}
8 9
@@ -1,8 +1,9
1 pub mod root;
1 2 use crate::error::CommandError;
2 3
3 4 /// The common trait for rhg commands
4 5 ///
5 6 /// Normalize the interface of the commands provided by rhg
6 7 pub trait Command {
7 8 fn run(&self) -> Result<(), CommandError>;
8 9 }
@@ -1,3 +1,60
1 use crate::exitcode;
2 use crate::ui::UiError;
3 use std::convert::From;
4
5 /// The kind of command error
6 #[derive(Debug, PartialEq)]
7 pub enum CommandErrorKind {
8 /// The command finished without error
9 Ok,
10 /// The root of the repository cannot be found
11 RootNotFound,
12 /// The current directory cannot be found
13 CurrentDirNotFound,
14 /// The standard output stream cannot be written to
15 StdoutError,
16 /// The standard error stream cannot be written to
17 StderrError,
18 }
19
20 impl CommandErrorKind {
21 pub fn get_exit_code(&self) -> exitcode::ExitCode {
22 match self {
23 CommandErrorKind::Ok => exitcode::OK,
24 CommandErrorKind::RootNotFound => exitcode::ABORT,
25 CommandErrorKind::CurrentDirNotFound => exitcode::ABORT,
26 CommandErrorKind::StdoutError => exitcode::ABORT,
27 CommandErrorKind::StderrError => exitcode::ABORT,
28 }
29 }
30 }
31
1 32 /// The error type for the Command trait
2 33 #[derive(Debug, PartialEq)]
3 pub struct CommandError {}
34 pub struct CommandError {
35 pub kind: CommandErrorKind,
36 }
37
38 impl CommandError {
39 /// Exist the process with the corresponding exit code.
40 pub fn exit(&self) -> () {
41 std::process::exit(self.kind.get_exit_code())
42 }
43 }
44
45 impl From<CommandErrorKind> for CommandError {
46 fn from(kind: CommandErrorKind) -> Self {
47 CommandError { kind }
48 }
49 }
50
51 impl From<UiError> for CommandError {
52 fn from(error: UiError) -> Self {
53 CommandError {
54 kind: match error {
55 UiError::StdoutError(_) => CommandErrorKind::StdoutError,
56 UiError::StderrError(_) => CommandErrorKind::StderrError,
57 },
58 }
59 }
60 }
@@ -1,4 +1,10
1 1 pub type ExitCode = i32;
2 2
3 /// Successful exit
4 pub const OK: ExitCode = 0;
5
6 /// Generic abort
7 pub const ABORT: ExitCode = 255;
8
3 9 /// Command not implemented by rhg
4 10 pub const UNIMPLEMENTED_COMMAND: ExitCode = 252;
@@ -1,7 +1,8
1 1 mod commands;
2 2 mod error;
3 3 mod exitcode;
4 mod ui;
4 5
5 6 fn main() {
6 7 std::process::exit(exitcode::UNIMPLEMENTED_COMMAND)
7 8 }
General Comments 0
You need to be logged in to leave comments. Login now