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 29 30
use std::path::Path; use git2; use util::{CargoResult, process}; pub struct HgRepo; pub struct GitRepo; impl GitRepo { pub fn init(path: &Path, _: &Path) -> CargoResult<GitRepo> { git2::Repository::init(path)?; Ok(GitRepo) } pub fn discover(path: &Path, _: &Path) -> Result<git2::Repository,git2::Error> { git2::Repository::discover(path) } } impl HgRepo { pub fn init(path: &Path, cwd: &Path) -> CargoResult<HgRepo> { process("hg").cwd(cwd).arg("init").arg(path).exec()?; Ok(HgRepo) } pub fn discover(path: &Path, cwd: &Path) -> CargoResult<HgRepo> { process("hg").cwd(cwd).arg("root").cwd(path).exec_with_output()?; Ok(HgRepo) } }