aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-core/src/vcs/util/hg.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/mozart-core/src/vcs/util/hg.rs')
-rw-r--r--crates/mozart-core/src/vcs/util/hg.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/mozart-core/src/vcs/util/hg.rs b/crates/mozart-core/src/vcs/util/hg.rs
new file mode 100644
index 0000000..73051b7
--- /dev/null
+++ b/crates/mozart-core/src/vcs/util/hg.rs
@@ -0,0 +1,28 @@
+use super::super::process::{ProcessExecutor, ProcessOutput};
+use anyhow::Result;
+use std::path::Path;
+
+/// Mercurial utility for command execution.
+pub struct HgUtil {
+ process: ProcessExecutor,
+}
+
+impl HgUtil {
+ pub fn new(process: ProcessExecutor) -> Self {
+ Self { process }
+ }
+
+ /// Execute a Mercurial command.
+ pub fn execute(&self, args: &[&str], cwd: Option<&Path>) -> Result<ProcessOutput> {
+ let mut full_args = vec!["hg"];
+ full_args.extend_from_slice(args);
+ self.process.execute_checked(&full_args, cwd)
+ }
+
+ /// Execute a Mercurial command, not erroring on non-zero exit.
+ pub fn execute_unchecked(&self, args: &[&str], cwd: Option<&Path>) -> Result<ProcessOutput> {
+ let mut full_args = vec!["hg"];
+ full_args.extend_from_slice(args);
+ self.process.execute(&full_args, cwd)
+ }
+}