author | Simon Sapin <simon.sapin@octobus.net> |
Wed, 27 Jan 2021 14:59:09 +0100 | |
changeset 46442 | 02d3bb972121 |
parent 46441 | 741e36f472a5 |
child 46443 | 43d63979a75e |
permissions | -rw-r--r-- |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
1 |
use crate::exitcode; |
46436
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
2 |
use crate::ui::utf8_to_local; |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
3 |
use crate::ui::UiError; |
45984
fada33872b5b
rhg: use `format_bytes!` for error messages
Raphaël Gomès <rgomes@octobus.net>
parents:
45937
diff
changeset
|
4 |
use format_bytes::format_bytes; |
46440
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46437
diff
changeset
|
5 |
use hg::errors::HgError; |
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46437
diff
changeset
|
6 |
use hg::operations::FindRootError; |
46437
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46436
diff
changeset
|
7 |
use hg::revlog::revlog::RevlogError; |
45361
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45360
diff
changeset
|
8 |
use hg::utils::files::get_bytes_from_path; |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
9 |
use std::convert::From; |
45361
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45360
diff
changeset
|
10 |
use std::path::PathBuf; |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
11 |
|
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
12 |
/// The kind of command error |
46435
2e2033081274
rust: replace trivial `impl From …` with `#[derive(derive_more::From)]`
Simon Sapin <simon.sapin@octobus.net>
parents:
46434
diff
changeset
|
13 |
#[derive(Debug, derive_more::From)] |
46434
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
14 |
pub enum CommandError { |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
15 |
/// The root of the repository cannot be found |
45361
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45360
diff
changeset
|
16 |
RootNotFound(PathBuf), |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
17 |
/// The current directory cannot be found |
45361
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45360
diff
changeset
|
18 |
CurrentDirNotFound(std::io::Error), |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
19 |
/// The standard output stream cannot be written to |
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
20 |
StdoutError, |
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
21 |
/// The standard error stream cannot be written to |
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
22 |
StderrError, |
45364
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45363
diff
changeset
|
23 |
/// The command aborted |
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45363
diff
changeset
|
24 |
Abort(Option<Vec<u8>>), |
45542
33ded2d3f4fc
rhg: add a limited `rhg cat -r` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45439
diff
changeset
|
25 |
/// A mercurial capability as not been implemented. |
33ded2d3f4fc
rhg: add a limited `rhg cat -r` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45439
diff
changeset
|
26 |
Unimplemented, |
46440
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46437
diff
changeset
|
27 |
/// Common cases |
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46437
diff
changeset
|
28 |
#[from] |
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46437
diff
changeset
|
29 |
Other(HgError), |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
30 |
} |
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
31 |
|
46434
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
32 |
impl CommandError { |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
33 |
pub fn get_exit_code(&self) -> exitcode::ExitCode { |
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
34 |
match self { |
46434
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
35 |
CommandError::RootNotFound(_) => exitcode::ABORT, |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
36 |
CommandError::CurrentDirNotFound(_) => exitcode::ABORT, |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
37 |
CommandError::StdoutError => exitcode::ABORT, |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
38 |
CommandError::StderrError => exitcode::ABORT, |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
39 |
CommandError::Abort(_) => exitcode::ABORT, |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
40 |
CommandError::Unimplemented => exitcode::UNIMPLEMENTED_COMMAND, |
46440
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46437
diff
changeset
|
41 |
CommandError::Other(HgError::UnsupportedFeature(_)) => { |
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46437
diff
changeset
|
42 |
exitcode::UNIMPLEMENTED_COMMAND |
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46437
diff
changeset
|
43 |
} |
776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents:
46437
diff
changeset
|
44 |
CommandError::Other(_) => exitcode::ABORT, |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
45 |
} |
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
46 |
} |
45361
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45360
diff
changeset
|
47 |
|
46434
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
48 |
/// Return the message corresponding to the error if any |
45361
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45360
diff
changeset
|
49 |
pub fn get_error_message_bytes(&self) -> Option<Vec<u8>> { |
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45360
diff
changeset
|
50 |
match self { |
46434
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
51 |
CommandError::RootNotFound(path) => { |
45361
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45360
diff
changeset
|
52 |
let bytes = get_bytes_from_path(path); |
45984
fada33872b5b
rhg: use `format_bytes!` for error messages
Raphaël Gomès <rgomes@octobus.net>
parents:
45937
diff
changeset
|
53 |
Some(format_bytes!( |
fada33872b5b
rhg: use `format_bytes!` for error messages
Raphaël Gomès <rgomes@octobus.net>
parents:
45937
diff
changeset
|
54 |
b"abort: no repository found in '{}' (.hg not found)!\n", |
fada33872b5b
rhg: use `format_bytes!` for error messages
Raphaël Gomès <rgomes@octobus.net>
parents:
45937
diff
changeset
|
55 |
bytes.as_slice() |
fada33872b5b
rhg: use `format_bytes!` for error messages
Raphaël Gomès <rgomes@octobus.net>
parents:
45937
diff
changeset
|
56 |
)) |
45361
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45360
diff
changeset
|
57 |
} |
46434
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
58 |
CommandError::CurrentDirNotFound(e) => Some(format_bytes!( |
45984
fada33872b5b
rhg: use `format_bytes!` for error messages
Raphaël Gomès <rgomes@octobus.net>
parents:
45937
diff
changeset
|
59 |
b"abort: error getting current working directory: {}\n", |
fada33872b5b
rhg: use `format_bytes!` for error messages
Raphaël Gomès <rgomes@octobus.net>
parents:
45937
diff
changeset
|
60 |
e.to_string().as_bytes(), |
fada33872b5b
rhg: use `format_bytes!` for error messages
Raphaël Gomès <rgomes@octobus.net>
parents:
45937
diff
changeset
|
61 |
)), |
46434
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
62 |
CommandError::Abort(message) => message.to_owned(), |
46441
741e36f472a5
rhg: Print an error message in more cases
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
63 |
|
46442
02d3bb972121
rust: replace RequirementsError with HgError
Simon Sapin <simon.sapin@octobus.net>
parents:
46441
diff
changeset
|
64 |
CommandError::StdoutError |
46441
741e36f472a5
rhg: Print an error message in more cases
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
65 |
| CommandError::StderrError |
741e36f472a5
rhg: Print an error message in more cases
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
66 |
| CommandError::Unimplemented |
741e36f472a5
rhg: Print an error message in more cases
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
67 |
| CommandError::Other(HgError::UnsupportedFeature(_)) => None, |
741e36f472a5
rhg: Print an error message in more cases
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
68 |
|
741e36f472a5
rhg: Print an error message in more cases
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
69 |
CommandError::Other(e) => { |
741e36f472a5
rhg: Print an error message in more cases
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
70 |
Some(format_bytes!(b"{}\n", e.to_string().as_bytes())) |
741e36f472a5
rhg: Print an error message in more cases
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
71 |
} |
45361
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45360
diff
changeset
|
72 |
} |
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45360
diff
changeset
|
73 |
} |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
74 |
|
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
75 |
/// Exist the process with the corresponding exit code. |
45439
fbc373b7cbc3
rhg: fix `clippy` warnings
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45364
diff
changeset
|
76 |
pub fn exit(&self) { |
46434
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
77 |
std::process::exit(self.get_exit_code()) |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
78 |
} |
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
79 |
} |
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
80 |
|
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
81 |
impl From<UiError> for CommandError { |
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
82 |
fn from(error: UiError) -> Self { |
46434
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
83 |
match error { |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
84 |
UiError::StdoutError(_) => CommandError::StdoutError, |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
85 |
UiError::StderrError(_) => CommandError::StderrError, |
45049
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
86 |
} |
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
87 |
} |
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
44982
diff
changeset
|
88 |
} |
45363
5dbf875b3275
rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45361
diff
changeset
|
89 |
|
5dbf875b3275
rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45361
diff
changeset
|
90 |
impl From<FindRootError> for CommandError { |
5dbf875b3275
rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45361
diff
changeset
|
91 |
fn from(err: FindRootError) -> Self { |
46434
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
92 |
match err { |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
93 |
FindRootError::RootNotFound(path) => { |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
94 |
CommandError::RootNotFound(path) |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
95 |
} |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
96 |
FindRootError::GetCurrentDirError(e) => { |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
97 |
CommandError::CurrentDirNotFound(e) |
3e2d539d0d1a
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field
Simon Sapin <simon.sapin@octobus.net>
parents:
45984
diff
changeset
|
98 |
} |
45363
5dbf875b3275
rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45361
diff
changeset
|
99 |
} |
5dbf875b3275
rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45361
diff
changeset
|
100 |
} |
5dbf875b3275
rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45361
diff
changeset
|
101 |
} |
46436
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
102 |
|
46437
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46436
diff
changeset
|
103 |
impl From<(RevlogError, &str)> for CommandError { |
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46436
diff
changeset
|
104 |
fn from((err, rev): (RevlogError, &str)) -> CommandError { |
46436
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
105 |
match err { |
46437
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46436
diff
changeset
|
106 |
RevlogError::IoError(err) => CommandError::Abort(Some( |
46436
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
107 |
utf8_to_local(&format!("abort: {}\n", err)).into(), |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
108 |
)), |
46437
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46436
diff
changeset
|
109 |
RevlogError::InvalidRevision => CommandError::Abort(Some( |
46436
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
110 |
utf8_to_local(&format!( |
46437
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46436
diff
changeset
|
111 |
"abort: invalid revision identifier {}\n", |
46436
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
112 |
rev |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
113 |
)) |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
114 |
.into(), |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
115 |
)), |
46437
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46436
diff
changeset
|
116 |
RevlogError::AmbiguousPrefix => CommandError::Abort(Some( |
46436
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
117 |
utf8_to_local(&format!( |
46437
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46436
diff
changeset
|
118 |
"abort: ambiguous revision identifier {}\n", |
46436
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
119 |
rev |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
120 |
)) |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
121 |
.into(), |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
122 |
)), |
46437
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46436
diff
changeset
|
123 |
RevlogError::UnsuportedVersion(version) => { |
46436
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
124 |
CommandError::Abort(Some( |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
125 |
utf8_to_local(&format!( |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
126 |
"abort: unsupported revlog version {}\n", |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
127 |
version |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
128 |
)) |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
129 |
.into(), |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
130 |
)) |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
131 |
} |
46437
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46436
diff
changeset
|
132 |
RevlogError::Corrupted => { |
46436
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
133 |
CommandError::Abort(Some("abort: corrupted revlog\n".into())) |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
134 |
} |
46437
b274aa2f20fd
rust: remove three enums that were identical to `RevlogError`
Simon Sapin <simon.sapin@octobus.net>
parents:
46436
diff
changeset
|
135 |
RevlogError::UnknowDataFormat(format) => { |
46436
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
136 |
CommandError::Abort(Some( |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
137 |
utf8_to_local(&format!( |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
138 |
"abort: unknow revlog dataformat {:?}\n", |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
139 |
format |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
140 |
)) |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
141 |
.into(), |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
142 |
)) |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
143 |
} |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
144 |
} |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
145 |
} |
252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Simon Sapin <simon.sapin@octobus.net>
parents:
46435
diff
changeset
|
146 |
} |