diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 562a676e255a5db7e246daea47bc7d7f3cc8746b_cnVzdC9DYXJnby5sb2Nr..6cd9f53aaed8ad1a982185a8c299c45374c3bb58_cnVzdC9DYXJnby5sb2Nr 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -826,5 +826,6 @@ "env_logger", "format-bytes", "hg-core", + "lazy_static", "log", "micro-timer", @@ -829,5 +830,6 @@ "log", "micro-timer", + "regex", "users", ] diff --git a/rust/rhg/Cargo.toml b/rust/rhg/Cargo.toml index 562a676e255a5db7e246daea47bc7d7f3cc8746b_cnVzdC9yaGcvQ2FyZ28udG9tbA==..6cd9f53aaed8ad1a982185a8c299c45374c3bb58_cnVzdC9yaGcvQ2FyZ28udG9tbA== 100644 --- a/rust/rhg/Cargo.toml +++ b/rust/rhg/Cargo.toml @@ -12,5 +12,6 @@ chrono = "0.4.19" clap = "2.33.1" derive_more = "0.99" +lazy_static = "1.4.0" log = "0.4.11" micro-timer = "0.3.1" @@ -15,5 +16,6 @@ log = "0.4.11" micro-timer = "0.3.1" +regex = "1.3.9" env_logger = "0.7.1" format-bytes = "0.2.0" users = "0.11.0" diff --git a/rust/rhg/src/main.rs b/rust/rhg/src/main.rs index 562a676e255a5db7e246daea47bc7d7f3cc8746b_cnVzdC9yaGcvc3JjL21haW4ucnM=..6cd9f53aaed8ad1a982185a8c299c45374c3bb58_cnVzdC9yaGcvc3JjL21haW4ucnM= 100644 --- a/rust/rhg/src/main.rs +++ b/rust/rhg/src/main.rs @@ -95,6 +95,25 @@ exit(&ui, on_unsupported, Err(error.into())) }); + if let Some(repo_path_bytes) = &early_args.repo { + lazy_static::lazy_static! { + static ref SCHEME_RE: regex::bytes::Regex = + // Same as `_matchscheme` in `mercurial/util.py` + regex::bytes::Regex::new("^[a-zA-Z0-9+.\\-]+:").unwrap(); + } + if SCHEME_RE.is_match(&repo_path_bytes) { + exit( + &ui, + OnUnsupported::from_config(&non_repo_config), + Err(CommandError::UnsupportedFeature { + message: format_bytes!( + b"URL-like --repository {}", + repo_path_bytes + ), + }), + ) + } + } let repo_path = early_args.repo.as_deref().map(get_path_from_bytes); let repo_result = match Repo::find(&non_repo_config, repo_path) { Ok(repo) => Ok(repo),