Skip to content
Snippets Groups Projects
Commit 2ad2745e authored by Simon Sapin's avatar Simon Sapin
Browse files

rhg: exit with relevant code for unsupported requirements

Differential Revision: https://phab.mercurial-scm.org/D9399
parent 0ce15a8c
No related branches found
No related tags found
No related merge requests found
...@@ -51,3 +51,22 @@ ...@@ -51,3 +51,22 @@
Err(error) => Err(RequirementsError::Io(error))?, Err(error) => Err(RequirementsError::Io(error))?,
} }
} }
pub fn check(repo_root: &Path) -> Result<(), RequirementsError> {
for feature in load(repo_root)? {
if !SUPPORTED.contains(&&*feature) {
return Err(RequirementsError::Unsupported { feature })
}
}
Ok(())
}
// TODO: set this to actually-supported features
const SUPPORTED: &[&str] = &[
"dotencode",
"fncache",
"generaldelta",
"revlogv1",
"sparserevlog",
"store",
];
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use crate::ui::Ui; use crate::ui::Ui;
use hg::operations::FindRoot; use hg::operations::FindRoot;
use hg::operations::{CatRev, CatRevError, CatRevErrorKind}; use hg::operations::{CatRev, CatRevError, CatRevErrorKind};
use hg::requirements;
use hg::utils::hg_path::HgPathBuf; use hg::utils::hg_path::HgPathBuf;
use micro_timer::timed; use micro_timer::timed;
use std::convert::TryFrom; use std::convert::TryFrom;
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
#[timed] #[timed]
fn run(&self, ui: &Ui) -> Result<(), CommandError> { fn run(&self, ui: &Ui) -> Result<(), CommandError> {
let root = FindRoot::new().run()?; let root = FindRoot::new().run()?;
requirements::check(&root)?;
let cwd = std::env::current_dir() let cwd = std::env::current_dir()
.or_else(|e| Err(CommandErrorKind::CurrentDirNotFound(e)))?; .or_else(|e| Err(CommandErrorKind::CurrentDirNotFound(e)))?;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
ListRevTrackedFiles, ListRevTrackedFilesError, ListRevTrackedFiles, ListRevTrackedFilesError,
ListRevTrackedFilesErrorKind, ListRevTrackedFilesErrorKind,
}; };
use hg::requirements;
use hg::utils::files::{get_bytes_from_path, relativize_path}; use hg::utils::files::{get_bytes_from_path, relativize_path};
use hg::utils::hg_path::{HgPath, HgPathBuf}; use hg::utils::hg_path::{HgPath, HgPathBuf};
use std::path::PathBuf; use std::path::PathBuf;
...@@ -57,6 +58,7 @@ ...@@ -57,6 +58,7 @@
impl<'a> Command for FilesCommand<'a> { impl<'a> Command for FilesCommand<'a> {
fn run(&self, ui: &Ui) -> Result<(), CommandError> { fn run(&self, ui: &Ui) -> Result<(), CommandError> {
let root = FindRoot::new().run()?; let root = FindRoot::new().run()?;
requirements::check(&root)?;
if let Some(rev) = self.rev { if let Some(rev) = self.rev {
let mut operation = ListRevTrackedFiles::new(&root, rev) let mut operation = ListRevTrackedFiles::new(&root, rev)
.map_err(|e| map_rev_error(rev, e))?; .map_err(|e| map_rev_error(rev, e))?;
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
match self { match self {
CommandErrorKind::RootNotFound(_) => exitcode::ABORT, CommandErrorKind::RootNotFound(_) => exitcode::ABORT,
CommandErrorKind::CurrentDirNotFound(_) => exitcode::ABORT, CommandErrorKind::CurrentDirNotFound(_) => exitcode::ABORT,
CommandErrorKind::RequirementsError(
RequirementsError::Unsupported { .. },
) => exitcode::UNIMPLEMENTED_COMMAND,
CommandErrorKind::RequirementsError(_) => exitcode::ABORT, CommandErrorKind::RequirementsError(_) => exitcode::ABORT,
CommandErrorKind::StdoutError => exitcode::ABORT, CommandErrorKind::StdoutError => exitcode::ABORT,
CommandErrorKind::StderrError => exitcode::ABORT, CommandErrorKind::StderrError => exitcode::ABORT,
......
...@@ -124,3 +124,19 @@ ...@@ -124,3 +124,19 @@
revlogv1 revlogv1
sparserevlog sparserevlog
store store
$ echo indoor-pool >> .hg/requires
$ rhg files
[252]
$ rhg cat -r 1 copy_of_original
[252]
$ rhg debugrequirements
dotencode
fncache
generaldelta
revlogv1
sparserevlog
store
indoor-pool
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment