blob: 73051b77266ec01d16715df377b94a9a8686a70f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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)
}
}
|