comparison rust/rhg/src/commands/cat.rs @ 45937:2ad2745e0be9

rhg: exit with relevant code for unsupported requirements Differential Revision: https://phab.mercurial-scm.org/D9399
author Simon Sapin <simon-commits@exyr.org>
date Tue, 24 Nov 2020 18:52:38 +0100
parents db11f8f39caf
children 904647f7d983
comparison
equal deleted inserted replaced
45936:0ce15a8c7b8b 45937:2ad2745e0be9
2 use crate::error::{CommandError, CommandErrorKind}; 2 use crate::error::{CommandError, CommandErrorKind};
3 use crate::ui::utf8_to_local; 3 use crate::ui::utf8_to_local;
4 use crate::ui::Ui; 4 use crate::ui::Ui;
5 use hg::operations::FindRoot; 5 use hg::operations::FindRoot;
6 use hg::operations::{CatRev, CatRevError, CatRevErrorKind}; 6 use hg::operations::{CatRev, CatRevError, CatRevErrorKind};
7 use hg::requirements;
7 use hg::utils::hg_path::HgPathBuf; 8 use hg::utils::hg_path::HgPathBuf;
8 use micro_timer::timed; 9 use micro_timer::timed;
9 use std::convert::TryFrom; 10 use std::convert::TryFrom;
10 11
11 pub const HELP_TEXT: &str = " 12 pub const HELP_TEXT: &str = "
30 31
31 impl<'a> Command for CatCommand<'a> { 32 impl<'a> Command for CatCommand<'a> {
32 #[timed] 33 #[timed]
33 fn run(&self, ui: &Ui) -> Result<(), CommandError> { 34 fn run(&self, ui: &Ui) -> Result<(), CommandError> {
34 let root = FindRoot::new().run()?; 35 let root = FindRoot::new().run()?;
36 requirements::check(&root)?;
35 let cwd = std::env::current_dir() 37 let cwd = std::env::current_dir()
36 .or_else(|e| Err(CommandErrorKind::CurrentDirNotFound(e)))?; 38 .or_else(|e| Err(CommandErrorKind::CurrentDirNotFound(e)))?;
37 39
38 let mut files = vec![]; 40 let mut files = vec![];
39 for file in self.files.iter() { 41 for file in self.files.iter() {