diff --git a/Cargo.lock b/Cargo.lock index e00832c40df..d931110237a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -448,7 +448,7 @@ dependencies = [ [[package]] name = "cargo-test-macro" -version = "0.4.3" +version = "0.4.4" [[package]] name = "cargo-test-support" diff --git a/crates/cargo-test-macro/Cargo.toml b/crates/cargo-test-macro/Cargo.toml index 73c8f57e083..096919a5eaf 100644 --- a/crates/cargo-test-macro/Cargo.toml +++ b/crates/cargo-test-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-test-macro" -version = "0.4.3" +version = "0.4.4" edition.workspace = true rust-version = "1.86" # MSRV:1 license.workspace = true diff --git a/crates/cargo-test-macro/src/lib.rs b/crates/cargo-test-macro/src/lib.rs index c3b82fe7695..44afbad5d87 100644 --- a/crates/cargo-test-macro/src/lib.rs +++ b/crates/cargo-test-macro/src/lib.rs @@ -282,7 +282,8 @@ fn check_command(command_path: &Path, args: &[&str]) -> bool { // environments like Docker. Consider installing it if Cargo // gains more hg support, but otherwise it isn't critical. // * lldb is not pre-installed on Ubuntu and Windows, so skip. - if is_ci() && !matches!(command_name.as_str(), "hg" | "lldb") { + // * rcs is not installed on GitHub runners nor on Windows, skip. + if is_ci() && !matches!(command_name.as_str(), "hg" | "lldb" | "rcs") { panic!("expected command `{command_name}` to be somewhere in PATH: {e}",); } return false; diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index 88d2d6bf162..4706575dac6 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -1,7 +1,7 @@ use crate::core::{Edition, Shell, Workspace}; use crate::util::errors::CargoResult; use crate::util::important_paths::find_root_manifest_for_wd; -use crate::util::{existing_vcs_repo, FossilRepo, GitRepo, HgRepo, PijulRepo}; +use crate::util::{existing_vcs_repo, FossilRepo, GitRepo, HgRepo, PijulRepo, RcsRepo}; use crate::util::{restricted_names, GlobalContext}; use anyhow::{anyhow, Context as _}; use cargo_util::paths::{self, write_atomic}; @@ -22,6 +22,7 @@ pub enum VersionControl { Hg, Pijul, Fossil, + Rcs, NoVcs, } @@ -34,6 +35,7 @@ impl FromStr for VersionControl { "hg" => Ok(VersionControl::Hg), "pijul" => Ok(VersionControl::Pijul), "fossil" => Ok(VersionControl::Fossil), + "rcs" => Ok(VersionControl::Rcs), "none" => Ok(VersionControl::NoVcs), other => anyhow::bail!("unknown vcs specification: `{}`", other), } @@ -542,11 +544,16 @@ pub fn init(opts: &NewOptions, gctx: &GlobalContext) -> CargoResult 1 { anyhow::bail!( - "more than one of .hg, .git, .pijul, .fossil configurations \ + "more than one of .hg, .git, .pijul, .fossil, RCS configurations \ found and the ignore file can't be filled in as \ a result. specify --vcs to override detection" ); @@ -688,7 +695,7 @@ fn write_ignore_file(base_path: &Path, list: &IgnoreList, vcs: VersionControl) - base_path.join(".fossil-settings/ignore-glob"), base_path.join(".fossil-settings/clean-glob"), ], - VersionControl::NoVcs => return Ok(()), + VersionControl::Rcs | VersionControl::NoVcs => return Ok(()), } { let ignore: String = match paths::open(&fp_ignore) { Err(err) => match err.downcast_ref::() { @@ -731,6 +738,11 @@ fn init_vcs(path: &Path, vcs: VersionControl, gctx: &GlobalContext) -> CargoResu FossilRepo::init(path, gctx.cwd())?; } } + VersionControl::Rcs => { + if !path.join("RCS").exists() { + RcsRepo::init(path, gctx.cwd())?; + } + } VersionControl::NoVcs => { paths::create_dir_all(path)?; } @@ -914,6 +926,10 @@ mod tests { ); } + if vcs == VersionControl::Rcs { + RcsRepo::late_init(path)?; + } + gctx.shell().note( "see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html", )?; diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 77169a432fc..6b1eb23cf6a 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -403,7 +403,7 @@ pub trait CommandExt: Sized { a global configuration.", ) .value_name("VCS") - .value_parser(["git", "hg", "pijul", "fossil", "none"]), + .value_parser(["git", "hg", "pijul", "fossil", "rcs", "none"]), ) ._arg( flag("bin", "Use a binary (application) template [default]") @@ -906,6 +906,7 @@ Run `{cmd}` to see possible targets." "hg" => VersionControl::Hg, "pijul" => VersionControl::Pijul, "fossil" => VersionControl::Fossil, + "rcs" => VersionControl::Rcs, "none" => VersionControl::NoVcs, vcs => panic!("Impossible vcs: {:?}", vcs), }); diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs index 18f950dd34f..9d0b82c7444 100644 --- a/src/cargo/util/mod.rs +++ b/src/cargo/util/mod.rs @@ -22,7 +22,7 @@ pub use self::progress::{Progress, ProgressStyle}; pub use self::queue::Queue; pub use self::rustc::Rustc; pub use self::semver_ext::{OptVersionReq, VersionExt}; -pub use self::vcs::{existing_vcs_repo, FossilRepo, GitRepo, HgRepo, PijulRepo}; +pub use self::vcs::{existing_vcs_repo, FossilRepo, GitRepo, HgRepo, PijulRepo, RcsRepo}; pub use self::workspace::{ add_path_args, path_args, print_available_benches, print_available_binaries, print_available_examples, print_available_packages, print_available_tests, diff --git a/src/cargo/util/vcs.rs b/src/cargo/util/vcs.rs index 095164e23df..6d0c58f0c92 100644 --- a/src/cargo/util/vcs.rs +++ b/src/cargo/util/vcs.rs @@ -22,13 +22,16 @@ pub fn existing_vcs_repo(path: &Path, cwd: &Path) -> bool { } } - in_git_repo(path, cwd) || HgRepo::discover(path, cwd).is_ok() + in_git_repo(path, cwd) + || HgRepo::discover(path, cwd).is_ok() + || RcsRepo::discover(path, cwd).is_ok() } pub struct HgRepo; pub struct GitRepo; pub struct PijulRepo; pub struct FossilRepo; +pub struct RcsRepo; impl GitRepo { pub fn init(path: &Path, _: &Path) -> CargoResult { @@ -102,3 +105,44 @@ impl FossilRepo { Ok(FossilRepo) } } + +impl RcsRepo { + pub fn init(path: &Path, _cwd: &Path) -> CargoResult { + paths::create_dir_all(path.join("RCS"))?; + Ok(RcsRepo) + } + + pub fn late_init(path: &Path) -> CargoResult<()> { + for entry in walkdir::WalkDir::new(path) + .into_iter() + .filter_entry(|e| e.file_name() != "RCS") + .filter_map(|e| e.ok()) + { + let p = entry.path(); + if p.is_file() { + if let Some(parent) = p.parent() { + ProcessBuilder::new("ci") + .cwd(parent) + .arg("-i") + .arg("-l") + .arg("-q") + .arg("-t-''") + .arg(entry.file_name()) + .exec()?; + } + } else if p.is_dir() { + paths::create_dir_all(p.join("RCS"))?; + } + } + + Ok(()) + } + + pub fn discover(path: &Path, _cwd: &Path) -> CargoResult { + ProcessBuilder::new("rlog") + .cwd(&path) + .arg("Cargo.toml") + .exec_with_output()?; + Ok(RcsRepo {}) + } +} diff --git a/src/doc/man/generated_txt/cargo-init.txt b/src/doc/man/generated_txt/cargo-init.txt index 0747257fd7a..29ac49f45e6 100644 --- a/src/doc/man/generated_txt/cargo-init.txt +++ b/src/doc/man/generated_txt/cargo-init.txt @@ -38,8 +38,8 @@ OPTIONS --vcs vcs Initialize a new VCS repository for the given version control system - (git, hg, pijul, or fossil) or do not initialize any version control - at all (none). If not specified, defaults to git or the + (git, hg, pijul, fossil, or rcs) or do not initialize any version + control at all (none). If not specified, defaults to git or the configuration value cargo-new.vcs, or none if already inside a VCS repository. diff --git a/src/doc/man/generated_txt/cargo-new.txt b/src/doc/man/generated_txt/cargo-new.txt index 8aa420c7aa9..ababb808305 100644 --- a/src/doc/man/generated_txt/cargo-new.txt +++ b/src/doc/man/generated_txt/cargo-new.txt @@ -33,8 +33,8 @@ OPTIONS --vcs vcs Initialize a new VCS repository for the given version control system - (git, hg, pijul, or fossil) or do not initialize any version control - at all (none). If not specified, defaults to git or the + (git, hg, pijul, fossil, or rcs) or do not initialize any version + control at all (none). If not specified, defaults to git or the configuration value cargo-new.vcs, or none if already inside a VCS repository. diff --git a/src/doc/man/includes/options-new.md b/src/doc/man/includes/options-new.md index 5711f2420ad..0f7373e2cbe 100644 --- a/src/doc/man/includes/options-new.md +++ b/src/doc/man/includes/options-new.md @@ -20,7 +20,7 @@ Set the package name. Defaults to the directory name. {{#option "`--vcs` _vcs_" }} Initialize a new VCS repository for the given version control system (git, -hg, pijul, or fossil) or do not initialize any version control at all +hg, pijul, fossil, or rcs) or do not initialize any version control at all (none). If not specified, defaults to `git` or the configuration value `cargo-new.vcs`, or `none` if already inside a VCS repository. {{/option}} diff --git a/src/doc/src/commands/cargo-init.md b/src/doc/src/commands/cargo-init.md index e2188564705..18c07ed1b5e 100644 --- a/src/doc/src/commands/cargo-init.md +++ b/src/doc/src/commands/cargo-init.md @@ -49,7 +49,7 @@ Possible values: 2015, 2018, 2021, 2024
--vcs vcs
Initialize a new VCS repository for the given version control system (git, -hg, pijul, or fossil) or do not initialize any version control at all +hg, pijul, fossil, or rcs) or do not initialize any version control at all (none). If not specified, defaults to git or the configuration value cargo-new.vcs, or none if already inside a VCS repository.
diff --git a/src/doc/src/commands/cargo-new.md b/src/doc/src/commands/cargo-new.md index 8aed7fdf1f5..5ad66d54cd2 100644 --- a/src/doc/src/commands/cargo-new.md +++ b/src/doc/src/commands/cargo-new.md @@ -44,7 +44,7 @@ Possible values: 2015, 2018, 2021, 2024
--vcs vcs
Initialize a new VCS repository for the given version control system (git, -hg, pijul, or fossil) or do not initialize any version control at all +hg, pijul, fossil, or rcs) or do not initialize any version control at all (none). If not specified, defaults to git or the configuration value cargo-new.vcs, or none if already inside a VCS repository.
diff --git a/src/doc/src/reference/config.md b/src/doc/src/reference/config.md index 105de8f502c..0a6d39cfc2d 100644 --- a/src/doc/src/reference/config.md +++ b/src/doc/src/reference/config.md @@ -99,7 +99,7 @@ frequency = 'always' # when to display a notification about a future incompat re auto-clean-frequency = "1 day" # How often to perform automatic cache cleaning [cargo-new] -vcs = "none" # VCS to use ('git', 'hg', 'pijul', 'fossil', 'none') +vcs = "none" # VCS to use ('git', 'hg', 'pijul', 'fossil', 'rcs', 'none') [http] debug = false # HTTP debugging @@ -625,8 +625,8 @@ This option is deprecated and unused. * Environment: `CARGO_CARGO_NEW_VCS` Specifies the source control system to use for initializing a new repository. -Valid values are `git`, `hg` (for Mercurial), `pijul`, `fossil` or `none` to -disable this behavior. Defaults to `git`, or `none` if already inside a VCS +Valid values are `git`, `hg` (for Mercurial), `pijul`, `fossil`, `rcs` or `none` +to disable this behavior. Defaults to `git`, or `none` if already inside a VCS repository. Can be overridden with the `--vcs` CLI option. ### `[env]` diff --git a/src/etc/_cargo b/src/etc/_cargo index 12aab736bd5..d616c8546c6 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -173,7 +173,7 @@ _cargo() { _arguments -s -S $common $registry \ '--lib[use library template]' \ '--edition=[specify edition to set for the crate generated]:edition:(2015 2018 2021)' \ - '--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \ + '--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil rcs none)' \ '--name=[set the resulting package name]:name' \ '1:path:_directories' ;; diff --git a/src/etc/cargo.bashcomp.sh b/src/etc/cargo.bashcomp.sh index 50ece8df466..415b842a23a 100644 --- a/src/etc/cargo.bashcomp.sh +++ b/src/etc/cargo.bashcomp.sh @@ -28,7 +28,7 @@ _cargo() fi done - local vcs='git hg none pijul fossil' + local vcs='git hg none pijul fossil rcs' local color='auto always never' local msg_format='human json short' diff --git a/src/etc/man/cargo-init.1 b/src/etc/man/cargo-init.1 index abeb9ebb99f..e5cf9ad93ea 100644 --- a/src/etc/man/cargo-init.1 +++ b/src/etc/man/cargo-init.1 @@ -48,7 +48,7 @@ Set the package name. Defaults to the directory name. \fB\-\-vcs\fR \fIvcs\fR .RS 4 Initialize a new VCS repository for the given version control system (git, -hg, pijul, or fossil) or do not initialize any version control at all +hg, pijul, fossil, or rcs) or do not initialize any version control at all (none). If not specified, defaults to \fBgit\fR or the configuration value \fBcargo\-new.vcs\fR, or \fBnone\fR if already inside a VCS repository. .RE diff --git a/src/etc/man/cargo-new.1 b/src/etc/man/cargo-new.1 index 6a33a8a7c96..ec8f28ede5b 100644 --- a/src/etc/man/cargo-new.1 +++ b/src/etc/man/cargo-new.1 @@ -43,7 +43,7 @@ Set the package name. Defaults to the directory name. \fB\-\-vcs\fR \fIvcs\fR .RS 4 Initialize a new VCS repository for the given version control system (git, -hg, pijul, or fossil) or do not initialize any version control at all +hg, pijul, fossil, or rcs) or do not initialize any version control at all (none). If not specified, defaults to \fBgit\fR or the configuration value \fBcargo\-new.vcs\fR, or \fBnone\fR if already inside a VCS repository. .RE diff --git a/tests/testsuite/cargo_init/help/stdout.term.svg b/tests/testsuite/cargo_init/help/stdout.term.svg index d6fff110d4b..76185e3c8fc 100644 --- a/tests/testsuite/cargo_init/help/stdout.term.svg +++ b/tests/testsuite/cargo_init/help/stdout.term.svg @@ -39,7 +39,7 @@ overriding a global configuration. [possible values: git, hg, - pijul, fossil, none] + pijul, fossil, rcs, none] --bin Use a binary (application) template [default] diff --git a/tests/testsuite/cargo_new/help/stdout.term.svg b/tests/testsuite/cargo_new/help/stdout.term.svg index 1985d04e7e2..84f524ba905 100644 --- a/tests/testsuite/cargo_new/help/stdout.term.svg +++ b/tests/testsuite/cargo_new/help/stdout.term.svg @@ -39,7 +39,7 @@ overriding a global configuration. [possible values: git, hg, - pijul, fossil, none] + pijul, fossil, rcs, none] --bin Use a binary (application) template [default] diff --git a/tests/testsuite/new.rs b/tests/testsuite/new.rs index 4c02c45752a..e0be55d934a 100644 --- a/tests/testsuite/new.rs +++ b/tests/testsuite/new.rs @@ -131,6 +131,21 @@ fn simple_hg() { cargo_process("build").cwd(&paths::root().join("foo")).run(); } +#[cargo_test(requires = "rcs")] +fn simple_rcs() { + cargo_process("new --lib foo --vcs rcs").run(); + + assert!(paths::root().is_dir()); + assert!(paths::root().join("foo/RCS").is_dir()); + assert!(paths::root().join("foo/RCS/Cargo.toml,v").is_file()); + assert!(paths::root().join("foo/Cargo.toml").is_file()); + assert!(paths::root().join("foo/src/RCS").is_dir()); + assert!(paths::root().join("foo/src/RCS/lib.rs,v").is_file()); + assert!(paths::root().join("foo/src/lib.rs").is_file()); + + cargo_process("build").cwd(&paths::root().join("foo")).run(); +} + #[cargo_test] fn no_argument() { cargo_process("new")