Show More
@@ -50,15 +50,6 b' dependencies = [' | |||||
50 | ] |
|
50 | ] | |
51 |
|
51 | |||
52 | [[package]] |
|
52 | [[package]] | |
53 | name = "ansi_term" |
|
|||
54 | version = "0.12.1" |
|
|||
55 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
|||
56 | checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" |
|
|||
57 | dependencies = [ |
|
|||
58 | "winapi", |
|
|||
59 | ] |
|
|||
60 |
|
||||
61 | [[package]] |
|
|||
62 | name = "atty" |
|
53 | name = "atty" | |
63 | version = "0.2.14" |
|
54 | version = "0.2.14" | |
64 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
55 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
@@ -172,21 +163,6 b' dependencies = [' | |||||
172 |
|
163 | |||
173 | [[package]] |
|
164 | [[package]] | |
174 | name = "clap" |
|
165 | name = "clap" | |
175 | version = "2.34.0" |
|
|||
176 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
|||
177 | checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" |
|
|||
178 | dependencies = [ |
|
|||
179 | "ansi_term", |
|
|||
180 | "atty", |
|
|||
181 | "bitflags", |
|
|||
182 | "strsim 0.8.0", |
|
|||
183 | "textwrap", |
|
|||
184 | "unicode-width", |
|
|||
185 | "vec_map", |
|
|||
186 | ] |
|
|||
187 |
|
||||
188 | [[package]] |
|
|||
189 | name = "clap" |
|
|||
190 | version = "4.0.24" |
|
166 | version = "4.0.24" | |
191 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
167 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
192 | checksum = "60494cedb60cb47462c0ff7be53de32c0e42a6fc2c772184554fa12bd9489c03" |
|
168 | checksum = "60494cedb60cb47462c0ff7be53de32c0e42a6fc2c772184554fa12bd9489c03" | |
@@ -196,7 +172,7 b' dependencies = [' | |||||
196 | "clap_derive", |
|
172 | "clap_derive", | |
197 | "clap_lex", |
|
173 | "clap_lex", | |
198 | "once_cell", |
|
174 | "once_cell", | |
199 |
"strsim |
|
175 | "strsim", | |
200 | "termcolor", |
|
176 | "termcolor", | |
201 | ] |
|
177 | ] | |
202 |
|
178 | |||
@@ -548,7 +524,7 b' dependencies = [' | |||||
548 | "bitflags", |
|
524 | "bitflags", | |
549 | "byteorder", |
|
525 | "byteorder", | |
550 | "bytes-cast", |
|
526 | "bytes-cast", | |
551 |
"clap |
|
527 | "clap", | |
552 | "crossbeam-channel", |
|
528 | "crossbeam-channel", | |
553 | "derive_more", |
|
529 | "derive_more", | |
554 | "flate2", |
|
530 | "flate2", | |
@@ -1110,7 +1086,7 b' version = "0.1.0"' | |||||
1110 | dependencies = [ |
|
1086 | dependencies = [ | |
1111 | "atty", |
|
1087 | "atty", | |
1112 | "chrono", |
|
1088 | "chrono", | |
1113 |
"clap |
|
1089 | "clap", | |
1114 | "derive_more", |
|
1090 | "derive_more", | |
1115 | "env_logger", |
|
1091 | "env_logger", | |
1116 | "format-bytes", |
|
1092 | "format-bytes", | |
@@ -1209,12 +1185,6 b' checksum = "a2eb9349b6444b326872e140eb1c' | |||||
1209 |
|
1185 | |||
1210 | [[package]] |
|
1186 | [[package]] | |
1211 | name = "strsim" |
|
1187 | name = "strsim" | |
1212 | version = "0.8.0" |
|
|||
1213 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
|||
1214 | checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" |
|
|||
1215 |
|
||||
1216 | [[package]] |
|
|||
1217 | name = "strsim" |
|
|||
1218 | version = "0.10.0" |
|
1188 | version = "0.10.0" | |
1219 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
1189 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
1220 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" |
|
1190 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" | |
@@ -1254,15 +1224,6 b' dependencies = [' | |||||
1254 | ] |
|
1224 | ] | |
1255 |
|
1225 | |||
1256 | [[package]] |
|
1226 | [[package]] | |
1257 | name = "textwrap" |
|
|||
1258 | version = "0.11.0" |
|
|||
1259 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
|||
1260 | checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" |
|
|||
1261 | dependencies = [ |
|
|||
1262 | "unicode-width", |
|
|||
1263 | ] |
|
|||
1264 |
|
||||
1265 | [[package]] |
|
|||
1266 | name = "thread_local" |
|
1227 | name = "thread_local" | |
1267 | version = "1.1.4" |
|
1228 | version = "1.1.4" | |
1268 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
1229 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
@@ -1339,12 +1300,6 b' dependencies = [' | |||||
1339 | ] |
|
1300 | ] | |
1340 |
|
1301 | |||
1341 | [[package]] |
|
1302 | [[package]] | |
1342 | name = "vec_map" |
|
|||
1343 | version = "0.8.2" |
|
|||
1344 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
|||
1345 | checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" |
|
|||
1346 |
|
||||
1347 | [[package]] |
|
|||
1348 | name = "version_check" |
|
1303 | name = "version_check" | |
1349 | version = "0.9.4" |
|
1304 | version = "0.9.4" | |
1350 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
1305 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -11,7 +11,7 b' edition = "2021"' | |||||
11 | atty = "0.2.14" |
|
11 | atty = "0.2.14" | |
12 | hg-core = { path = "../hg-core"} |
|
12 | hg-core = { path = "../hg-core"} | |
13 | chrono = "0.4.19" |
|
13 | chrono = "0.4.19" | |
14 | clap = "2.34.0" |
|
14 | clap = { version = "4.0.24", features = ["cargo"] } | |
15 | derive_more = "0.99.17" |
|
15 | derive_more = "0.99.17" | |
16 | home = "0.5.3" |
|
16 | home = "0.5.3" | |
17 | lazy_static = "1.4.0" |
|
17 | lazy_static = "1.4.0" |
@@ -4,27 +4,28 b' use format_bytes::format_bytes;' | |||||
4 | use hg::operations::cat; |
|
4 | use hg::operations::cat; | |
5 | use hg::utils::hg_path::HgPathBuf; |
|
5 | use hg::utils::hg_path::HgPathBuf; | |
6 | use micro_timer::timed; |
|
6 | use micro_timer::timed; | |
|
7 | use std::ffi::OsString; | |||
|
8 | use std::os::unix::prelude::OsStrExt; | |||
7 |
|
9 | |||
8 | pub const HELP_TEXT: &str = " |
|
10 | pub const HELP_TEXT: &str = " | |
9 | Output the current or given revision of files |
|
11 | Output the current or given revision of files | |
10 | "; |
|
12 | "; | |
11 |
|
13 | |||
12 |
pub fn args() -> clap:: |
|
14 | pub fn args() -> clap::Command { | |
13 |
clap:: |
|
15 | clap::command!("cat") | |
14 | .arg( |
|
16 | .arg( | |
15 |
Arg:: |
|
17 | Arg::new("rev") | |
16 | .help("search the repository as it is in REV") |
|
18 | .help("search the repository as it is in REV") | |
17 |
.short( |
|
19 | .short('r') | |
18 |
.long(" |
|
20 | .long("rev") | |
19 | .value_name("REV") |
|
21 | .value_name("REV"), | |
20 | .takes_value(true), |
|
|||
21 | ) |
|
22 | ) | |
22 | .arg( |
|
23 | .arg( | |
23 |
clap::Arg:: |
|
24 | clap::Arg::new("files") | |
24 | .required(true) |
|
25 | .required(true) | |
25 |
. |
|
26 | .num_args(1..) | |
26 | .empty_values(false) |
|
|||
27 | .value_name("FILE") |
|
27 | .value_name("FILE") | |
|
28 | .value_parser(clap::value_parser!(std::ffi::OsString)) | |||
28 | .help("Files to output"), |
|
29 | .help("Files to output"), | |
29 | ) |
|
30 | ) | |
30 | .about(HELP_TEXT) |
|
31 | .about(HELP_TEXT) | |
@@ -41,11 +42,15 b' pub fn run(invocation: &crate::CliInvoca' | |||||
41 | )); |
|
42 | )); | |
42 | } |
|
43 | } | |
43 |
|
44 | |||
44 |
let rev = invocation.subcommand_args. |
|
45 | let rev = invocation.subcommand_args.get_one::<String>("rev"); | |
45 | let file_args = match invocation.subcommand_args.values_of("files") { |
|
46 | let file_args = | |
46 | Some(files) => files.collect(), |
|
47 | match invocation.subcommand_args.get_many::<OsString>("files") { | |
47 | None => vec![], |
|
48 | Some(files) => files | |
48 | }; |
|
49 | .filter(|s| !s.is_empty()) | |
|
50 | .map(|s| s.as_os_str()) | |||
|
51 | .collect(), | |||
|
52 | None => vec![], | |||
|
53 | }; | |||
49 |
|
54 | |||
50 | let repo = invocation.repo?; |
|
55 | let repo = invocation.repo?; | |
51 | let cwd = hg::utils::current_dir()?; |
|
56 | let cwd = hg::utils::current_dir()?; | |
@@ -53,8 +58,8 b' pub fn run(invocation: &crate::CliInvoca' | |||||
53 | let working_directory = cwd.join(working_directory); // Make it absolute |
|
58 | let working_directory = cwd.join(working_directory); // Make it absolute | |
54 |
|
59 | |||
55 | let mut files = vec![]; |
|
60 | let mut files = vec![]; | |
56 |
for file in file_args |
|
61 | for file in file_args { | |
57 | if file.starts_with("set:") { |
|
62 | if file.as_bytes().starts_with(b"set:") { | |
58 | let message = "fileset"; |
|
63 | let message = "fileset"; | |
59 | return Err(CommandError::unsupported(message)); |
|
64 | return Err(CommandError::unsupported(message)); | |
60 | } |
|
65 | } | |
@@ -62,7 +67,7 b' pub fn run(invocation: &crate::CliInvoca' | |||||
62 | let normalized = cwd.join(&file); |
|
67 | let normalized = cwd.join(&file); | |
63 | // TODO: actually normalize `..` path segments etc? |
|
68 | // TODO: actually normalize `..` path segments etc? | |
64 | let dotted = normalized.components().any(|c| c.as_os_str() == ".."); |
|
69 | let dotted = normalized.components().any(|c| c.as_os_str() == ".."); | |
65 |
if file == |
|
70 | if file.as_bytes() == b"." || dotted { | |
66 | let message = "`..` or `.` path segment"; |
|
71 | let message = "`..` or `.` path segment"; | |
67 | return Err(CommandError::unsupported(message)); |
|
72 | return Err(CommandError::unsupported(message)); | |
68 | } |
|
73 | } | |
@@ -74,7 +79,7 b' pub fn run(invocation: &crate::CliInvoca' | |||||
74 | .map_err(|_| { |
|
79 | .map_err(|_| { | |
75 | CommandError::abort(format!( |
|
80 | CommandError::abort(format!( | |
76 | "abort: {} not under root '{}'\n(consider using '--cwd {}')", |
|
81 | "abort: {} not under root '{}'\n(consider using '--cwd {}')", | |
77 | file, |
|
82 | String::from_utf8_lossy(file.as_bytes()), | |
78 | working_directory.display(), |
|
83 | working_directory.display(), | |
79 | relative_path.display(), |
|
84 | relative_path.display(), | |
80 | )) |
|
85 | )) |
@@ -8,14 +8,13 b' pub const HELP_TEXT: &str = "' | |||||
8 | With one argument of the form section.name, print just the value of that config item. |
|
8 | With one argument of the form section.name, print just the value of that config item. | |
9 | "; |
|
9 | "; | |
10 |
|
10 | |||
11 |
pub fn args() -> clap:: |
|
11 | pub fn args() -> clap::Command { | |
12 |
clap:: |
|
12 | clap::command!("config") | |
13 | .arg( |
|
13 | .arg( | |
14 |
Arg:: |
|
14 | Arg::new("name") | |
15 | .help("the section.name to print") |
|
15 | .help("the section.name to print") | |
16 | .value_name("NAME") |
|
16 | .value_name("NAME") | |
17 | .required(true) |
|
17 | .required(true), | |
18 | .takes_value(true), |
|
|||
19 | ) |
|
18 | ) | |
20 | .about(HELP_TEXT) |
|
19 | .about(HELP_TEXT) | |
21 | } |
|
20 | } | |
@@ -23,7 +22,7 b" pub fn args() -> clap::App<'static, 'sta" | |||||
23 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
|
22 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { | |
24 | let (section, name) = invocation |
|
23 | let (section, name) = invocation | |
25 | .subcommand_args |
|
24 | .subcommand_args | |
26 |
. |
|
25 | .get_one::<String>("name") | |
27 | .expect("missing required CLI argument") |
|
26 | .expect("missing required CLI argument") | |
28 | .as_bytes() |
|
27 | .as_bytes() | |
29 | .split_2(b'.') |
|
28 | .split_2(b'.') |
@@ -8,27 +8,27 b' pub const HELP_TEXT: &str = "' | |||||
8 | Dump the contents of a data file revision |
|
8 | Dump the contents of a data file revision | |
9 | "; |
|
9 | "; | |
10 |
|
10 | |||
11 |
pub fn args() -> clap:: |
|
11 | pub fn args() -> clap::Command { | |
12 |
clap:: |
|
12 | clap::command!("debugdata") | |
13 | .arg( |
|
13 | .arg( | |
14 |
Arg:: |
|
14 | Arg::new("changelog") | |
15 | .help("open changelog") |
|
15 | .help("open changelog") | |
16 |
.short( |
|
16 | .short('c') | |
17 | .long("--changelog"), |
|
17 | .action(clap::ArgAction::SetTrue), | |
18 | ) |
|
18 | ) | |
19 | .arg( |
|
19 | .arg( | |
20 |
Arg:: |
|
20 | Arg::new("manifest") | |
21 | .help("open manifest") |
|
21 | .help("open manifest") | |
22 |
.short( |
|
22 | .short('m') | |
23 | .long("--manifest"), |
|
23 | .action(clap::ArgAction::SetTrue), | |
24 | ) |
|
24 | ) | |
25 | .group( |
|
25 | .group( | |
26 |
ArgGroup:: |
|
26 | ArgGroup::new("revlog") | |
27 | .args(&["changelog", "manifest"]) |
|
27 | .args(&["changelog", "manifest"]) | |
28 | .required(true), |
|
28 | .required(true), | |
29 | ) |
|
29 | ) | |
30 | .arg( |
|
30 | .arg( | |
31 |
Arg:: |
|
31 | Arg::new("rev") | |
32 | .help("revision") |
|
32 | .help("revision") | |
33 | .required(true) |
|
33 | .required(true) | |
34 | .value_name("REV"), |
|
34 | .value_name("REV"), | |
@@ -40,19 +40,21 b" pub fn args() -> clap::App<'static, 'sta" | |||||
40 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
|
40 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { | |
41 | let args = invocation.subcommand_args; |
|
41 | let args = invocation.subcommand_args; | |
42 | let rev = args |
|
42 | let rev = args | |
43 |
. |
|
43 | .get_one::<String>("rev") | |
44 | .expect("rev should be a required argument"); |
|
44 | .expect("rev should be a required argument"); | |
45 | let kind = |
|
45 | let kind = match ( | |
46 | match (args.is_present("changelog"), args.is_present("manifest")) { |
|
46 | args.get_one::<bool>("changelog").unwrap(), | |
47 | (true, false) => DebugDataKind::Changelog, |
|
47 | args.get_one::<bool>("manifest").unwrap(), | |
48 | (false, true) => DebugDataKind::Manifest, |
|
48 | ) { | |
49 | (true, true) => { |
|
49 | (true, false) => DebugDataKind::Changelog, | |
50 | unreachable!("Should not happen since options are exclusive") |
|
50 | (false, true) => DebugDataKind::Manifest, | |
51 | } |
|
51 | (true, true) => { | |
52 | (false, false) => { |
|
52 | unreachable!("Should not happen since options are exclusive") | |
53 | unreachable!("Should not happen since options are required") |
|
53 | } | |
54 | } |
|
54 | (false, false) => { | |
55 | }; |
|
55 | unreachable!("Should not happen since options are required") | |
|
56 | } | |||
|
57 | }; | |||
56 |
|
58 | |||
57 | let repo = invocation.repo?; |
|
59 | let repo = invocation.repo?; | |
58 | if repo.has_narrow() { |
|
60 | if repo.has_narrow() { | |
@@ -60,7 +62,7 b' pub fn run(invocation: &crate::CliInvoca' | |||||
60 | "support for ellipsis nodes is missing and repo has narrow enabled", |
|
62 | "support for ellipsis nodes is missing and repo has narrow enabled", | |
61 | )); |
|
63 | )); | |
62 | } |
|
64 | } | |
63 | let data = debug_data(repo, rev, kind).map_err(|e| (e, rev))?; |
|
65 | let data = debug_data(repo, rev, kind).map_err(|e| (e, rev.as_ref()))?; | |
64 |
|
66 | |||
65 | let mut stdout = invocation.ui.stdout_buffer(); |
|
67 | let mut stdout = invocation.ui.stdout_buffer(); | |
66 | stdout.write_all(&data)?; |
|
68 | stdout.write_all(&data)?; |
@@ -1,5 +1,4 b'' | |||||
1 | use crate::error::CommandError; |
|
1 | use crate::error::CommandError; | |
2 | use clap::SubCommand; |
|
|||
3 | use hg; |
|
2 | use hg; | |
4 | use hg::matchers::get_ignore_matcher; |
|
3 | use hg::matchers::get_ignore_matcher; | |
5 | use hg::StatusError; |
|
4 | use hg::StatusError; | |
@@ -13,8 +12,8 b' This is a pure Rust version of `hg debug' | |||||
13 | Some options might be missing, check the list below. |
|
12 | Some options might be missing, check the list below. | |
14 | "; |
|
13 | "; | |
15 |
|
14 | |||
16 |
pub fn args() -> clap:: |
|
15 | pub fn args() -> clap::Command { | |
17 |
|
|
16 | clap::command!("debugignorerhg").about(HELP_TEXT) | |
18 | } |
|
17 | } | |
19 |
|
18 | |||
20 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
|
19 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
@@ -4,8 +4,8 b' pub const HELP_TEXT: &str = "' | |||||
4 | Print the current repo requirements. |
|
4 | Print the current repo requirements. | |
5 | "; |
|
5 | "; | |
6 |
|
6 | |||
7 |
pub fn args() -> clap:: |
|
7 | pub fn args() -> clap::Command { | |
8 |
clap:: |
|
8 | clap::command!("debugrequirements").about(HELP_TEXT) | |
9 | } |
|
9 | } | |
10 |
|
10 | |||
11 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
|
11 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
@@ -1,19 +1,21 b'' | |||||
1 | use std::os::unix::prelude::OsStrExt; |
|
1 | use std::{ | |
|
2 | ffi::{OsStr, OsString}, | |||
|
3 | os::unix::prelude::OsStrExt, | |||
|
4 | }; | |||
2 |
|
5 | |||
3 | use crate::error::CommandError; |
|
6 | use crate::error::CommandError; | |
4 | use clap::SubCommand; |
|
|||
5 | use hg::{self, utils::hg_path::HgPath}; |
|
7 | use hg::{self, utils::hg_path::HgPath}; | |
6 |
|
8 | |||
7 | pub const HELP_TEXT: &str = ""; |
|
9 | pub const HELP_TEXT: &str = ""; | |
8 |
|
10 | |||
9 |
pub fn args() -> clap:: |
|
11 | pub fn args() -> clap::Command { | |
10 |
|
|
12 | clap::command!("debugrhgsparse") | |
11 | .arg( |
|
13 | .arg( | |
12 |
clap::Arg:: |
|
14 | clap::Arg::new("files") | |
|
15 | .value_name("FILES") | |||
13 | .required(true) |
|
16 | .required(true) | |
14 |
. |
|
17 | .num_args(1..) | |
15 | .empty_values(false) |
|
18 | .value_parser(clap::value_parser!(std::ffi::OsString)) | |
16 | .value_name("FILES") |
|
|||
17 | .help("Files to check against sparse profile"), |
|
19 | .help("Files to check against sparse profile"), | |
18 | ) |
|
20 | ) | |
19 | .about(HELP_TEXT) |
|
21 | .about(HELP_TEXT) | |
@@ -23,8 +25,12 b' pub fn run(invocation: &crate::CliInvoca' | |||||
23 | let repo = invocation.repo?; |
|
25 | let repo = invocation.repo?; | |
24 |
|
26 | |||
25 | let (matcher, _warnings) = hg::sparse::matcher(&repo).unwrap(); |
|
27 | let (matcher, _warnings) = hg::sparse::matcher(&repo).unwrap(); | |
26 |
let files = invocation.subcommand_args. |
|
28 | let files = invocation.subcommand_args.get_many::<OsString>("files"); | |
27 | if let Some(files) = files { |
|
29 | if let Some(files) = files { | |
|
30 | let files: Vec<&OsStr> = files | |||
|
31 | .filter(|s| !s.is_empty()) | |||
|
32 | .map(|s| s.as_os_str()) | |||
|
33 | .collect(); | |||
28 | for file in files { |
|
34 | for file in files { | |
29 | invocation.ui.write_stdout(b"matches: ")?; |
|
35 | invocation.ui.write_stdout(b"matches: ")?; | |
30 | invocation.ui.write_stdout( |
|
36 | invocation.ui.write_stdout( |
@@ -14,15 +14,14 b' List tracked files.' | |||||
14 | Returns 0 on success. |
|
14 | Returns 0 on success. | |
15 | "; |
|
15 | "; | |
16 |
|
16 | |||
17 |
pub fn args() -> clap:: |
|
17 | pub fn args() -> clap::Command { | |
18 |
clap:: |
|
18 | clap::command!("files") | |
19 | .arg( |
|
19 | .arg( | |
20 |
Arg:: |
|
20 | Arg::new("rev") | |
21 | .help("search the repository as it is in REV") |
|
21 | .help("search the repository as it is in REV") | |
22 |
.short( |
|
22 | .short('r') | |
23 |
.long(" |
|
23 | .long("revision") | |
24 | .value_name("REV") |
|
24 | .value_name("REV"), | |
25 | .takes_value(true), |
|
|||
26 | ) |
|
25 | ) | |
27 | .about(HELP_TEXT) |
|
26 | .about(HELP_TEXT) | |
28 | } |
|
27 | } | |
@@ -35,7 +34,7 b' pub fn run(invocation: &crate::CliInvoca' | |||||
35 | )); |
|
34 | )); | |
36 | } |
|
35 | } | |
37 |
|
36 | |||
38 |
let rev = invocation.subcommand_args. |
|
37 | let rev = invocation.subcommand_args.get_one::<String>("rev"); | |
39 |
|
38 | |||
40 | let repo = invocation.repo?; |
|
39 | let repo = invocation.repo?; | |
41 |
|
40 | |||
@@ -57,7 +56,8 b' pub fn run(invocation: &crate::CliInvoca' | |||||
57 | "rhg files -r <rev> is not supported in narrow clones", |
|
56 | "rhg files -r <rev> is not supported in narrow clones", | |
58 | )); |
|
57 | )); | |
59 | } |
|
58 | } | |
60 |
let files = list_rev_tracked_files(repo, rev) |
|
59 | let files = list_rev_tracked_files(repo, rev) | |
|
60 | .map_err(|e| (e, rev.as_ref()))?; | |||
61 | display_files(invocation.ui, repo, files.iter()) |
|
61 | display_files(invocation.ui, repo, files.iter()) | |
62 | } else { |
|
62 | } else { | |
63 | // The dirstate always reflects the sparse narrowspec, so if |
|
63 | // The dirstate always reflects the sparse narrowspec, so if |
@@ -9,8 +9,8 b' Print the root directory of the current ' | |||||
9 | Returns 0 on success. |
|
9 | Returns 0 on success. | |
10 | "; |
|
10 | "; | |
11 |
|
11 | |||
12 |
pub fn args() -> clap:: |
|
12 | pub fn args() -> clap::Command { | |
13 |
clap:: |
|
13 | clap::command!("root").about(HELP_TEXT) | |
14 | } |
|
14 | } | |
15 |
|
15 | |||
16 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
|
16 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
@@ -8,7 +8,7 b'' | |||||
8 | use crate::error::CommandError; |
|
8 | use crate::error::CommandError; | |
9 | use crate::ui::Ui; |
|
9 | use crate::ui::Ui; | |
10 | use crate::utils::path_utils::RelativizePaths; |
|
10 | use crate::utils::path_utils::RelativizePaths; | |
11 |
use clap:: |
|
11 | use clap::Arg; | |
12 | use format_bytes::format_bytes; |
|
12 | use format_bytes::format_bytes; | |
13 | use hg::config::Config; |
|
13 | use hg::config::Config; | |
14 | use hg::dirstate::has_exec_bit; |
|
14 | use hg::dirstate::has_exec_bit; | |
@@ -41,75 +41,86 b' This is a pure Rust version of `hg statu' | |||||
41 | Some options might be missing, check the list below. |
|
41 | Some options might be missing, check the list below. | |
42 | "; |
|
42 | "; | |
43 |
|
43 | |||
44 |
pub fn args() -> clap:: |
|
44 | pub fn args() -> clap::Command { | |
45 |
|
|
45 | clap::command!("status") | |
46 | .alias("st") |
|
46 | .alias("st") | |
47 | .about(HELP_TEXT) |
|
47 | .about(HELP_TEXT) | |
48 | .arg( |
|
48 | .arg( | |
49 |
Arg:: |
|
49 | Arg::new("all") | |
50 | .help("show status of all files") |
|
50 | .help("show status of all files") | |
51 |
.short( |
|
51 | .short('A') | |
52 | .long("--all"), |
|
52 | .action(clap::ArgAction::SetTrue) | |
|
53 | .long("all"), | |||
53 | ) |
|
54 | ) | |
54 | .arg( |
|
55 | .arg( | |
55 |
Arg:: |
|
56 | Arg::new("modified") | |
56 | .help("show only modified files") |
|
57 | .help("show only modified files") | |
57 |
.short( |
|
58 | .short('m') | |
58 | .long("--modified"), |
|
59 | .action(clap::ArgAction::SetTrue) | |
|
60 | .long("modified"), | |||
59 | ) |
|
61 | ) | |
60 | .arg( |
|
62 | .arg( | |
61 |
Arg:: |
|
63 | Arg::new("added") | |
62 | .help("show only added files") |
|
64 | .help("show only added files") | |
63 |
.short( |
|
65 | .short('a') | |
64 | .long("--added"), |
|
66 | .action(clap::ArgAction::SetTrue) | |
|
67 | .long("added"), | |||
65 | ) |
|
68 | ) | |
66 | .arg( |
|
69 | .arg( | |
67 |
Arg:: |
|
70 | Arg::new("removed") | |
68 | .help("show only removed files") |
|
71 | .help("show only removed files") | |
69 |
.short( |
|
72 | .short('r') | |
70 | .long("--removed"), |
|
73 | .action(clap::ArgAction::SetTrue) | |
|
74 | .long("removed"), | |||
71 | ) |
|
75 | ) | |
72 | .arg( |
|
76 | .arg( | |
73 |
Arg:: |
|
77 | Arg::new("clean") | |
74 | .help("show only clean files") |
|
78 | .help("show only clean files") | |
75 |
.short( |
|
79 | .short('c') | |
76 | .long("--clean"), |
|
80 | .action(clap::ArgAction::SetTrue) | |
|
81 | .long("clean"), | |||
77 | ) |
|
82 | ) | |
78 | .arg( |
|
83 | .arg( | |
79 |
Arg:: |
|
84 | Arg::new("deleted") | |
80 | .help("show only deleted files") |
|
85 | .help("show only deleted files") | |
81 |
.short( |
|
86 | .short('d') | |
82 | .long("--deleted"), |
|
87 | .action(clap::ArgAction::SetTrue) | |
|
88 | .long("deleted"), | |||
83 | ) |
|
89 | ) | |
84 | .arg( |
|
90 | .arg( | |
85 |
Arg:: |
|
91 | Arg::new("unknown") | |
86 | .help("show only unknown (not tracked) files") |
|
92 | .help("show only unknown (not tracked) files") | |
87 |
.short( |
|
93 | .short('u') | |
88 | .long("--unknown"), |
|
94 | .action(clap::ArgAction::SetTrue) | |
|
95 | .long("unknown"), | |||
89 | ) |
|
96 | ) | |
90 | .arg( |
|
97 | .arg( | |
91 |
Arg:: |
|
98 | Arg::new("ignored") | |
92 | .help("show only ignored files") |
|
99 | .help("show only ignored files") | |
93 |
.short( |
|
100 | .short('i') | |
94 | .long("--ignored"), |
|
101 | .action(clap::ArgAction::SetTrue) | |
|
102 | .long("ignored"), | |||
95 | ) |
|
103 | ) | |
96 | .arg( |
|
104 | .arg( | |
97 |
Arg:: |
|
105 | Arg::new("copies") | |
98 | .help("show source of copied files (DEFAULT: ui.statuscopies)") |
|
106 | .help("show source of copied files (DEFAULT: ui.statuscopies)") | |
99 |
.short( |
|
107 | .short('C') | |
100 | .long("--copies"), |
|
108 | .action(clap::ArgAction::SetTrue) | |
|
109 | .long("copies"), | |||
101 | ) |
|
110 | ) | |
102 | .arg( |
|
111 | .arg( | |
103 |
Arg:: |
|
112 | Arg::new("no-status") | |
104 | .help("hide status prefix") |
|
113 | .help("hide status prefix") | |
105 |
.short( |
|
114 | .short('n') | |
106 | .long("--no-status"), |
|
115 | .action(clap::ArgAction::SetTrue) | |
|
116 | .long("no-status"), | |||
107 | ) |
|
117 | ) | |
108 | .arg( |
|
118 | .arg( | |
109 |
Arg:: |
|
119 | Arg::new("verbose") | |
110 | .help("enable additional output") |
|
120 | .help("enable additional output") | |
111 |
.short( |
|
121 | .short('v') | |
112 | .long("--verbose"), |
|
122 | .action(clap::ArgAction::SetTrue) | |
|
123 | .long("verbose"), | |||
113 | ) |
|
124 | ) | |
114 | } |
|
125 | } | |
115 |
|
126 | |||
@@ -200,25 +211,25 b' pub fn run(invocation: &crate::CliInvoca' | |||||
200 | let config = invocation.config; |
|
211 | let config = invocation.config; | |
201 | let args = invocation.subcommand_args; |
|
212 | let args = invocation.subcommand_args; | |
202 |
|
213 | |||
203 | let verbose = !args.is_present("print0") |
|
214 | // TODO add `!args.get_flag("print0") &&` when we support `print0` | |
204 |
|
|
215 | let verbose = args.get_flag("verbose") | |
205 |
|
|
216 | || config.get_bool(b"ui", b"verbose")? | |
206 |
|
|
217 | || config.get_bool(b"commands", b"status.verbose")?; | |
207 |
|
218 | |||
208 |
let all = args. |
|
219 | let all = args.get_flag("all"); | |
209 | let display_states = if all { |
|
220 | let display_states = if all { | |
210 | // TODO when implementing `--quiet`: it excludes clean files |
|
221 | // TODO when implementing `--quiet`: it excludes clean files | |
211 | // from `--all` |
|
222 | // from `--all` | |
212 | ALL_DISPLAY_STATES |
|
223 | ALL_DISPLAY_STATES | |
213 | } else { |
|
224 | } else { | |
214 | let requested = DisplayStates { |
|
225 | let requested = DisplayStates { | |
215 |
modified: args. |
|
226 | modified: args.get_flag("modified"), | |
216 |
added: args. |
|
227 | added: args.get_flag("added"), | |
217 |
removed: args. |
|
228 | removed: args.get_flag("removed"), | |
218 |
clean: args. |
|
229 | clean: args.get_flag("clean"), | |
219 |
deleted: args. |
|
230 | deleted: args.get_flag("deleted"), | |
220 |
unknown: args. |
|
231 | unknown: args.get_flag("unknown"), | |
221 |
ignored: args. |
|
232 | ignored: args.get_flag("ignored"), | |
222 | }; |
|
233 | }; | |
223 | if requested.is_empty() { |
|
234 | if requested.is_empty() { | |
224 | DEFAULT_DISPLAY_STATES |
|
235 | DEFAULT_DISPLAY_STATES | |
@@ -226,9 +237,9 b' pub fn run(invocation: &crate::CliInvoca' | |||||
226 | requested |
|
237 | requested | |
227 | } |
|
238 | } | |
228 | }; |
|
239 | }; | |
229 |
let no_status = args. |
|
240 | let no_status = args.get_flag("no-status"); | |
230 | let list_copies = all |
|
241 | let list_copies = all | |
231 |
|| args. |
|
242 | || args.get_flag("copies") | |
232 | || config.get_bool(b"ui", b"statuscopies")?; |
|
243 | || config.get_bool(b"ui", b"statuscopies")?; | |
233 |
|
244 | |||
234 | let repo = invocation.repo?; |
|
245 | let repo = invocation.repo?; |
@@ -1,10 +1,7 b'' | |||||
1 | extern crate log; |
|
1 | extern crate log; | |
2 | use crate::error::CommandError; |
|
2 | use crate::error::CommandError; | |
3 | use crate::ui::{local_to_utf8, Ui}; |
|
3 | use crate::ui::{local_to_utf8, Ui}; | |
4 | use clap::App; |
|
4 | use clap::{command, Arg, ArgMatches}; | |
5 | use clap::AppSettings; |
|
|||
6 | use clap::Arg; |
|
|||
7 | use clap::ArgMatches; |
|
|||
8 | use format_bytes::{format_bytes, join}; |
|
5 | use format_bytes::{format_bytes, join}; | |
9 | use hg::config::{Config, ConfigSource, PlainInfo}; |
|
6 | use hg::config::{Config, ConfigSource, PlainInfo}; | |
10 | use hg::repo::{Repo, RepoError}; |
|
7 | use hg::repo::{Repo, RepoError}; | |
@@ -35,55 +32,47 b' fn main_with_result(' | |||||
35 | ) -> Result<(), CommandError> { |
|
32 | ) -> Result<(), CommandError> { | |
36 | check_unsupported(config, repo)?; |
|
33 | check_unsupported(config, repo)?; | |
37 |
|
34 | |||
38 |
let app = |
|
35 | let app = command!() | |
39 | .global_setting(AppSettings::AllowInvalidUtf8) |
|
36 | .subcommand_required(true) | |
40 | .global_setting(AppSettings::DisableVersion) |
|
|||
41 | .setting(AppSettings::SubcommandRequired) |
|
|||
42 | .setting(AppSettings::VersionlessSubcommands) |
|
|||
43 | .arg( |
|
37 | .arg( | |
44 |
Arg:: |
|
38 | Arg::new("repository") | |
45 | .help("repository root directory") |
|
39 | .help("repository root directory") | |
46 |
.short( |
|
40 | .short('R') | |
47 | .long("--repository") |
|
|||
48 | .value_name("REPO") |
|
41 | .value_name("REPO") | |
49 | .takes_value(true) |
|
|||
50 | // Both ok: `hg -R ./foo log` or `hg log -R ./foo` |
|
42 | // Both ok: `hg -R ./foo log` or `hg log -R ./foo` | |
51 | .global(true), |
|
43 | .global(true), | |
52 | ) |
|
44 | ) | |
53 | .arg( |
|
45 | .arg( | |
54 |
Arg:: |
|
46 | Arg::new("config") | |
55 | .help("set/override config option (use 'section.name=value')") |
|
47 | .help("set/override config option (use 'section.name=value')") | |
56 | .long("--config") |
|
|||
57 | .value_name("CONFIG") |
|
48 | .value_name("CONFIG") | |
58 | .takes_value(true) |
|
|||
59 | .global(true) |
|
49 | .global(true) | |
|
50 | .long("config") | |||
60 | // Ok: `--config section.key1=val --config section.key2=val2` |
|
51 | // Ok: `--config section.key1=val --config section.key2=val2` | |
61 | .multiple(true) |
|
|||
62 | // Not ok: `--config section.key1=val section.key2=val2` |
|
52 | // Not ok: `--config section.key1=val section.key2=val2` | |
63 | .number_of_values(1), |
|
53 | .action(clap::ArgAction::Append), | |
64 | ) |
|
54 | ) | |
65 | .arg( |
|
55 | .arg( | |
66 |
Arg:: |
|
56 | Arg::new("cwd") | |
67 | .help("change working directory") |
|
57 | .help("change working directory") | |
68 | .long("--cwd") |
|
|||
69 | .value_name("DIR") |
|
58 | .value_name("DIR") | |
70 |
. |
|
59 | .long("cwd") | |
71 | .global(true), |
|
60 | .global(true), | |
72 | ) |
|
61 | ) | |
73 | .arg( |
|
62 | .arg( | |
74 |
Arg:: |
|
63 | Arg::new("color") | |
75 | .help("when to colorize (boolean, always, auto, never, or debug)") |
|
64 | .help("when to colorize (boolean, always, auto, never, or debug)") | |
76 | .long("--color") |
|
|||
77 | .value_name("TYPE") |
|
65 | .value_name("TYPE") | |
78 |
. |
|
66 | .long("color") | |
79 | .global(true), |
|
67 | .global(true), | |
80 | ) |
|
68 | ) | |
81 | .version("0.0.1"); |
|
69 | .version("0.0.1"); | |
82 | let app = add_subcommand_args(app); |
|
70 | let app = add_subcommand_args(app); | |
83 |
|
71 | |||
84 |
let matches = app.clone().get_matches_from |
|
72 | let matches = app.clone().try_get_matches_from(argv.iter())?; | |
85 |
|
73 | |||
86 |
let (subcommand_name, subcommand_ |
|
74 | let (subcommand_name, subcommand_args) = | |
|
75 | matches.subcommand().expect("subcommand required"); | |||
87 |
|
76 | |||
88 | // Mercurial allows users to define "defaults" for commands, fallback |
|
77 | // Mercurial allows users to define "defaults" for commands, fallback | |
89 | // if a default is detected for the current command |
|
78 | // if a default is detected for the current command | |
@@ -104,9 +93,7 b' fn main_with_result(' | |||||
104 | } |
|
93 | } | |
105 | } |
|
94 | } | |
106 | let run = subcommand_run_fn(subcommand_name) |
|
95 | let run = subcommand_run_fn(subcommand_name) | |
107 |
.expect("unknown subcommand name from clap despite |
|
96 | .expect("unknown subcommand name from clap despite Command::subcommand_required"); | |
108 | let subcommand_args = subcommand_matches |
|
|||
109 | .expect("no subcommand arguments from clap despite AppSettings::SubcommandRequired"); |
|
|||
110 |
|
97 | |||
111 | let invocation = CliInvocation { |
|
98 | let invocation = CliInvocation { | |
112 | ui, |
|
99 | ui, | |
@@ -535,7 +522,7 b' macro_rules! subcommands {' | |||||
535 | )+ |
|
522 | )+ | |
536 | } |
|
523 | } | |
537 |
|
524 | |||
538 |
fn add_subcommand_args |
|
525 | fn add_subcommand_args(app: clap::Command) -> clap::Command { | |
539 | app |
|
526 | app | |
540 | $( |
|
527 | $( | |
541 | .subcommand(commands::$command::args()) |
|
528 | .subcommand(commands::$command::args()) | |
@@ -569,7 +556,7 b' subcommands! {' | |||||
569 |
|
556 | |||
570 | pub struct CliInvocation<'a> { |
|
557 | pub struct CliInvocation<'a> { | |
571 | ui: &'a Ui, |
|
558 | ui: &'a Ui, | |
572 |
subcommand_args: &'a ArgMatches |
|
559 | subcommand_args: &'a ArgMatches, | |
573 | config: &'a Config, |
|
560 | config: &'a Config, | |
574 | /// References inside `Result` is a bit peculiar but allow |
|
561 | /// References inside `Result` is a bit peculiar but allow | |
575 | /// `invocation.repo?` to work out with `&CliInvocation` since this |
|
562 | /// `invocation.repo?` to work out with `&CliInvocation` since this |
@@ -4,12 +4,11 b'' | |||||
4 |
|
4 | |||
5 | Unimplemented command |
|
5 | Unimplemented command | |
6 | $ $NO_FALLBACK rhg unimplemented-command |
|
6 | $ $NO_FALLBACK rhg unimplemented-command | |
7 |
unsupported feature: error: |
|
7 | unsupported feature: error: The subcommand 'unimplemented-command' wasn't recognized | |
8 |
|
|
8 | ||
9 | USAGE: |
|
9 | Usage: rhg [OPTIONS] <COMMAND> | |
10 | rhg [OPTIONS] <SUBCOMMAND> |
|
|||
11 |
|
|
10 | ||
12 | For more information try --help |
|
11 | For more information try '--help' | |
13 |
|
|
12 | ||
14 | [252] |
|
13 | [252] | |
15 | $ rhg unimplemented-command --config rhg.on-unsupported=abort-silent |
|
14 | $ rhg unimplemented-command --config rhg.on-unsupported=abort-silent | |
@@ -159,10 +158,11 b' Fallback to Python' | |||||
159 | $ $NO_FALLBACK rhg cat original --exclude="*.rs" |
|
158 | $ $NO_FALLBACK rhg cat original --exclude="*.rs" | |
160 |
unsupported feature: error: Found argument '--exclude' which wasn' |
|
159 | unsupported feature: error: Found argument '--exclude' which wasn't expected, or isn't valid in this context | |
161 |
|
|
160 | ||
162 | USAGE: |
|
161 | If you tried to supply '--exclude' as a value rather than a flag, use '-- --exclude' | |
163 | rhg cat [OPTIONS] <FILE>... |
|
|||
164 |
|
|
162 | ||
165 | For more information try --help |
|
163 | Usage: rhg cat <FILE>... | |
|
164 | ||||
|
165 | For more information try '--help' | |||
166 |
|
|
166 | ||
167 | [252] |
|
167 | [252] | |
168 | $ rhg cat original --exclude="*.rs" |
|
168 | $ rhg cat original --exclude="*.rs" | |
@@ -190,10 +190,11 b' Check that `fallback-immediately` overri' | |||||
190 |
Blocking |
|
190 | Blocking recursive fallback. The 'rhg.fallback-executable = rhg' config points to `rhg` itself. | |
191 |
unsupported feature: error: Found argument '--exclude' which wasn' |
|
191 | unsupported feature: error: Found argument '--exclude' which wasn't expected, or isn't valid in this context | |
192 |
|
|
192 | ||
193 | USAGE: |
|
193 | If you tried to supply '--exclude' as a value rather than a flag, use '-- --exclude' | |
194 | rhg cat [OPTIONS] <FILE>... |
|
|||
195 |
|
|
194 | ||
196 | For more information try --help |
|
195 | Usage: rhg cat <FILE>... | |
|
196 | ||||
|
197 | For more information try '--help' | |||
197 |
|
|
198 | ||
198 | [252] |
|
199 | [252] | |
199 |
|
200 |
General Comments 0
You need to be logged in to leave comments.
Login now