diff rust/hg-core/src/requirements.rs @ 45952: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 a2eda1ff22aa
children f5d62f4d5327
line wrap: on
line diff
--- a/rust/hg-core/src/requirements.rs	Tue Oct 06 03:25:15 2020 +0200
+++ b/rust/hg-core/src/requirements.rs	Tue Nov 24 18:52:38 2020 +0100
@@ -51,3 +51,22 @@
         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",
+];