diff --git a/src/bin/new.rs b/src/bin/new.rs index 865985e367d..834134ba0a7 100644 --- a/src/bin/new.rs +++ b/src/bin/new.rs @@ -27,7 +27,7 @@ Usage: Options: -h, --help Print this message --vcs VCS Initialize a new repository for the given version - control system (git or hg) or do not initialize any version + control system (git, hg, or pijul) or do not initialize any version control at all (none) overriding a global configuration. --bin Use a binary (application) template --lib Use a library template diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index 989035cf902..088e4c5b44c 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -10,13 +10,13 @@ use git2::Config as GitConfig; use term::color::BLACK; use core::Workspace; -use util::{GitRepo, HgRepo, CargoResult, human, ChainError, internal}; +use util::{GitRepo, HgRepo, PijulRepo, CargoResult, human, ChainError, internal}; use util::{Config, paths}; use toml; #[derive(Clone, Copy, Debug, PartialEq)] -pub enum VersionControl { Git, Hg, NoVcs } +pub enum VersionControl { Git, Hg, Pijul, NoVcs } pub struct NewOptions<'a> { pub version_control: Option, @@ -45,6 +45,7 @@ impl Decodable for VersionControl { Ok(match &d.read_str()?[..] { "git" => VersionControl::Git, "hg" => VersionControl::Hg, + "pijul" => VersionControl::Pijul, "none" => VersionControl::NoVcs, n => { let err = format!("could not decode '{}' as version control", n); @@ -331,10 +332,15 @@ pub fn init(opts: NewOptions, config: &Config) -> CargoResult<()> { num_detected_vsces += 1; } + if fs::metadata(&path.join(".pijul")).is_ok() { + version_control = Some(VersionControl::Pijul); + num_detected_vsces += 1; + } + // if none exists, maybe create git, like in `cargo new` if num_detected_vsces > 1 { - bail!("both .git and .hg directories found \ + bail!("more than one of .hg, .git, or .pijul directories found \ and the ignore file can't be \ filled in as a result, \ specify --vcs to override detection"); @@ -401,6 +407,11 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> { } paths::append(&path.join(".hgignore"), ignore.as_bytes())?; }, + VersionControl::Pijul => { + if !fs::metadata(&path.join(".pijul")).is_ok() { + PijulRepo::init(path, config.cwd())?; + } + }, VersionControl::NoVcs => { fs::create_dir_all(path)?; }, diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs index 572398ba240..27da14148c2 100644 --- a/src/cargo/util/mod.rs +++ b/src/cargo/util/mod.rs @@ -17,7 +17,7 @@ pub use self::rustc::Rustc; pub use self::sha256::Sha256; pub use self::to_semver::ToSemver; pub use self::to_url::ToUrl; -pub use self::vcs::{GitRepo, HgRepo}; +pub use self::vcs::{GitRepo, HgRepo, PijulRepo}; pub use self::read2::read2; pub mod config; diff --git a/src/cargo/util/vcs.rs b/src/cargo/util/vcs.rs index 730200316a0..61a4b1c3942 100644 --- a/src/cargo/util/vcs.rs +++ b/src/cargo/util/vcs.rs @@ -6,6 +6,7 @@ use util::{CargoResult, process}; pub struct HgRepo; pub struct GitRepo; +pub struct PijulRepo; impl GitRepo { pub fn init(path: &Path, _: &Path) -> CargoResult { @@ -28,3 +29,9 @@ impl HgRepo { } } +impl PijulRepo { + pub fn init(path: &Path, cwd: &Path) -> CargoResult { + process("pijul").cwd(cwd).arg("init").arg(path).exec()?; + Ok(PijulRepo) + } +}