rust/rhg/src/error.rs
author Simon Sapin <simon-commits@exyr.org>
Tue, 24 Nov 2020 18:52:38 +0100
changeset 45937 2ad2745e0be9
parent 45924 a2eda1ff22aa
child 45984 fada33872b5b
permissions -rw-r--r--
rhg: exit with relevant code for unsupported requirements Differential Revision: https://phab.mercurial-scm.org/D9399
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
     2
use crate::ui::UiError;
45363
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
     3
use hg::operations::{FindRootError, FindRootErrorKind};
45924
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
     4
use hg::requirements::RequirementsError;
45361
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
     5
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
     6
use std::convert::From;
45361
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
     7
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
     8
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
     9
/// The kind of command error
45361
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    10
#[derive(Debug)]
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
pub enum CommandErrorKind {
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 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
    13
    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
    14
    /// 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
    15
    CurrentDirNotFound(std::io::Error),
45924
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
    16
    /// `.hg/requires`
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
    17
    RequirementsError(RequirementsError),
45049
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    18
    /// 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
    19
    StdoutError,
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    20
    /// 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
    21
    StderrError,
45364
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45363
diff changeset
    22
    /// 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
    23
    Abort(Option<Vec<u8>>),
45542
33ded2d3f4fc rhg: add a limited `rhg cat -r` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45439
diff changeset
    24
    /// 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
    25
    Unimplemented,
45049
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    26
}
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    27
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    28
impl CommandErrorKind {
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    29
    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
    30
        match self {
45361
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    31
            CommandErrorKind::RootNotFound(_) => exitcode::ABORT,
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    32
            CommandErrorKind::CurrentDirNotFound(_) => exitcode::ABORT,
45937
2ad2745e0be9 rhg: exit with relevant code for unsupported requirements
Simon Sapin <simon-commits@exyr.org>
parents: 45924
diff changeset
    33
            CommandErrorKind::RequirementsError(
2ad2745e0be9 rhg: exit with relevant code for unsupported requirements
Simon Sapin <simon-commits@exyr.org>
parents: 45924
diff changeset
    34
                RequirementsError::Unsupported { .. },
2ad2745e0be9 rhg: exit with relevant code for unsupported requirements
Simon Sapin <simon-commits@exyr.org>
parents: 45924
diff changeset
    35
            ) => exitcode::UNIMPLEMENTED_COMMAND,
45924
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
    36
            CommandErrorKind::RequirementsError(_) => 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
    37
            CommandErrorKind::StdoutError => exitcode::ABORT,
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    38
            CommandErrorKind::StderrError => exitcode::ABORT,
45364
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45363
diff changeset
    39
            CommandErrorKind::Abort(_) => exitcode::ABORT,
45542
33ded2d3f4fc rhg: add a limited `rhg cat -r` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45439
diff changeset
    40
            CommandErrorKind::Unimplemented => exitcode::UNIMPLEMENTED_COMMAND,
45049
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    41
        }
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    42
    }
45361
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    43
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    44
    /// Return the message corresponding to the error kind if any
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    45
    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
    46
        match self {
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    47
            // TODO use formating macro
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    48
            CommandErrorKind::RootNotFound(path) => {
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    49
                let bytes = get_bytes_from_path(path);
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    50
                Some(
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    51
                    [
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    52
                        b"abort: no repository found in '",
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    53
                        bytes.as_slice(),
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    54
                        b"' (.hg not found)!\n",
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    55
                    ]
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    56
                    .concat(),
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    57
                )
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    58
            }
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    59
            // TODO use formating macro
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    60
            CommandErrorKind::CurrentDirNotFound(e) => Some(
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    61
                [
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    62
                    b"abort: error getting current working directory: ",
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    63
                    e.to_string().as_bytes(),
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    64
                    b"\n",
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    65
                ]
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    66
                .concat(),
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    67
            ),
45924
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
    68
            CommandErrorKind::RequirementsError(
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
    69
                RequirementsError::Corrupted,
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
    70
            ) => Some(
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
    71
                "abort: .hg/requires is corrupted\n".as_bytes().to_owned(),
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
    72
            ),
45364
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45363
diff changeset
    73
            CommandErrorKind::Abort(message) => message.to_owned(),
45361
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    74
            _ => None,
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    75
        }
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    76
    }
45049
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    77
}
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    78
44982
bacf6c7ef01b rhg: add Command trait for subcommands implemented by rhg
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
    79
/// The error type for the Command trait
45361
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    80
#[derive(Debug)]
45049
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    81
pub struct 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
    pub kind: CommandErrorKind,
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    83
}
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    84
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    85
impl CommandError {
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    86
    /// Exist the process with the corresponding exit code.
45439
fbc373b7cbc3 rhg: fix `clippy` warnings
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45364
diff changeset
    87
    pub fn exit(&self) {
45049
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    88
        std::process::exit(self.kind.get_exit_code())
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    89
    }
45361
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    90
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    91
    /// Return the message corresponding to the command error if any
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    92
    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
    93
        self.kind.get_error_message_bytes()
47997afadf08 rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45360
diff changeset
    94
    }
45049
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    95
}
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    96
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    97
impl From<CommandErrorKind> 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
    98
    fn from(kind: CommandErrorKind) -> Self {
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
    99
        CommandError { kind }
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   100
    }
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   101
}
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   102
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   103
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
   104
    fn from(error: UiError) -> Self {
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   105
        CommandError {
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   106
            kind: match error {
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   107
                UiError::StdoutError(_) => CommandErrorKind::StdoutError,
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   108
                UiError::StderrError(_) => CommandErrorKind::StderrError,
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   109
            },
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   110
        }
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   111
    }
513b3ef277a3 rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44982
diff changeset
   112
}
45363
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   113
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   114
impl From<FindRootError> for CommandError {
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   115
    fn from(err: FindRootError) -> Self {
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   116
        match err.kind {
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   117
            FindRootErrorKind::RootNotFound(path) => CommandError {
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   118
                kind: CommandErrorKind::RootNotFound(path),
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   119
            },
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   120
            FindRootErrorKind::GetCurrentDirError(e) => CommandError {
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   121
                kind: CommandErrorKind::CurrentDirNotFound(e),
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   122
            },
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   123
        }
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   124
    }
5dbf875b3275 rhg: simplify `FindRootError` handling
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45361
diff changeset
   125
}
45924
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
   126
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
   127
impl From<RequirementsError> for CommandError {
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
   128
    fn from(err: RequirementsError) -> Self {
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
   129
        CommandError {
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
   130
            kind: CommandErrorKind::RequirementsError(err),
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
   131
        }
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
   132
    }
a2eda1ff22aa requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents: 45923
diff changeset
   133
}