##// END OF EJS Templates
rhg: exit with relevant code for unsupported requirements...
Simon Sapin -
r46549:2ad2745e default
parent child Browse files
Show More
@@ -51,3 +51,22 b' pub fn load(repo_root: &Path) -> Result<'
51 Err(error) => Err(RequirementsError::Io(error))?,
51 Err(error) => Err(RequirementsError::Io(error))?,
52 }
52 }
53 }
53 }
54
55 pub fn check(repo_root: &Path) -> Result<(), RequirementsError> {
56 for feature in load(repo_root)? {
57 if !SUPPORTED.contains(&&*feature) {
58 return Err(RequirementsError::Unsupported { feature })
59 }
60 }
61 Ok(())
62 }
63
64 // TODO: set this to actually-supported features
65 const SUPPORTED: &[&str] = &[
66 "dotencode",
67 "fncache",
68 "generaldelta",
69 "revlogv1",
70 "sparserevlog",
71 "store",
72 ];
@@ -4,6 +4,7 b' 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;
@@ -32,6 +33,7 b" 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
@@ -11,6 +11,7 b' use hg::operations::{'
11 ListRevTrackedFiles, ListRevTrackedFilesError,
11 ListRevTrackedFiles, ListRevTrackedFilesError,
12 ListRevTrackedFilesErrorKind,
12 ListRevTrackedFilesErrorKind,
13 };
13 };
14 use hg::requirements;
14 use hg::utils::files::{get_bytes_from_path, relativize_path};
15 use hg::utils::files::{get_bytes_from_path, relativize_path};
15 use hg::utils::hg_path::{HgPath, HgPathBuf};
16 use hg::utils::hg_path::{HgPath, HgPathBuf};
16 use std::path::PathBuf;
17 use std::path::PathBuf;
@@ -57,6 +58,7 b" impl<'a> FilesCommand<'a> {"
57 impl<'a> Command for FilesCommand<'a> {
58 impl<'a> Command for FilesCommand<'a> {
58 fn run(&self, ui: &Ui) -> Result<(), CommandError> {
59 fn run(&self, ui: &Ui) -> Result<(), CommandError> {
59 let root = FindRoot::new().run()?;
60 let root = FindRoot::new().run()?;
61 requirements::check(&root)?;
60 if let Some(rev) = self.rev {
62 if let Some(rev) = self.rev {
61 let mut operation = ListRevTrackedFiles::new(&root, rev)
63 let mut operation = ListRevTrackedFiles::new(&root, rev)
62 .map_err(|e| map_rev_error(rev, e))?;
64 .map_err(|e| map_rev_error(rev, e))?;
@@ -30,6 +30,9 b' impl CommandErrorKind {'
30 match self {
30 match self {
31 CommandErrorKind::RootNotFound(_) => exitcode::ABORT,
31 CommandErrorKind::RootNotFound(_) => exitcode::ABORT,
32 CommandErrorKind::CurrentDirNotFound(_) => exitcode::ABORT,
32 CommandErrorKind::CurrentDirNotFound(_) => exitcode::ABORT,
33 CommandErrorKind::RequirementsError(
34 RequirementsError::Unsupported { .. },
35 ) => exitcode::UNIMPLEMENTED_COMMAND,
33 CommandErrorKind::RequirementsError(_) => exitcode::ABORT,
36 CommandErrorKind::RequirementsError(_) => exitcode::ABORT,
34 CommandErrorKind::StdoutError => exitcode::ABORT,
37 CommandErrorKind::StdoutError => exitcode::ABORT,
35 CommandErrorKind::StderrError => exitcode::ABORT,
38 CommandErrorKind::StderrError => exitcode::ABORT,
@@ -124,3 +124,19 b' Requirements'
124 revlogv1
124 revlogv1
125 sparserevlog
125 sparserevlog
126 store
126 store
127
128 $ echo indoor-pool >> .hg/requires
129 $ rhg files
130 [252]
131
132 $ rhg cat -r 1 copy_of_original
133 [252]
134
135 $ rhg debugrequirements
136 dotencode
137 fncache
138 generaldelta
139 revlogv1
140 sparserevlog
141 store
142 indoor-pool
General Comments 0
You need to be logged in to leave comments. Login now