Show More
@@ -179,7 +179,7 fn main() { | |||
|
179 | 179 | exit( |
|
180 | 180 | &initial_current_dir, |
|
181 | 181 | &ui, |
|
182 |
OnUnsupported::from_config(& |
|
|
182 | OnUnsupported::from_config(&non_repo_config), | |
|
183 | 183 | Err(error.into()), |
|
184 | 184 | non_repo_config |
|
185 | 185 | .get_bool(b"ui", b"detailed-exit-code") |
@@ -197,7 +197,7 fn main() { | |||
|
197 | 197 | exit( |
|
198 | 198 | &initial_current_dir, |
|
199 | 199 | &ui, |
|
200 |
OnUnsupported::from_config(& |
|
|
200 | OnUnsupported::from_config(&non_repo_config), | |
|
201 | 201 | Err(CommandError::UnsupportedFeature { |
|
202 | 202 | message: format_bytes!( |
|
203 | 203 | b"URL-like --repository {}", |
@@ -287,7 +287,7 fn main() { | |||
|
287 | 287 | Err(error) => exit( |
|
288 | 288 | &initial_current_dir, |
|
289 | 289 | &ui, |
|
290 |
OnUnsupported::from_config(& |
|
|
290 | OnUnsupported::from_config(&non_repo_config), | |
|
291 | 291 | Err(error.into()), |
|
292 | 292 | // TODO: show a warning or combine with original error if |
|
293 | 293 | // `get_bool` returns an error |
@@ -302,7 +302,7 fn main() { | |||
|
302 | 302 | } else { |
|
303 | 303 | &non_repo_config |
|
304 | 304 | }; |
|
305 |
let on_unsupported = OnUnsupported::from_config( |
|
|
305 | let on_unsupported = OnUnsupported::from_config(config); | |
|
306 | 306 | |
|
307 | 307 | let result = main_with_result( |
|
308 | 308 | &process_start_time, |
@@ -362,6 +362,20 fn exit( | |||
|
362 | 362 | ) = (&on_unsupported, &result) |
|
363 | 363 | { |
|
364 | 364 | let mut args = std::env::args_os(); |
|
365 | let executable = match executable { | |
|
366 | None => { | |
|
367 | exit_no_fallback( | |
|
368 | ui, | |
|
369 | OnUnsupported::Abort, | |
|
370 | Err(CommandError::abort( | |
|
371 | "abort: 'rhg.on-unsupported=fallback' without \ | |
|
372 | 'rhg.fallback-executable' set.", | |
|
373 | )), | |
|
374 | false, | |
|
375 | ); | |
|
376 | } | |
|
377 | Some(executable) => executable, | |
|
378 | }; | |
|
365 | 379 | let executable_path = get_path_from_bytes(&executable); |
|
366 | 380 | let this_executable = args.next().expect("exepcted argv[0] to exist"); |
|
367 | 381 | if executable_path == &PathBuf::from(this_executable) { |
@@ -374,7 +388,8 fn exit( | |||
|
374 | 388 | )); |
|
375 | 389 | on_unsupported = OnUnsupported::Abort |
|
376 | 390 | } else { |
|
377 |
// `args` is now `argv[1..]` since we’ve already consumed |
|
|
391 | // `args` is now `argv[1..]` since we’ve already consumed | |
|
392 | // `argv[0]` | |
|
378 | 393 | let mut command = Command::new(executable_path); |
|
379 | 394 | command.args(args); |
|
380 | 395 | if let Some(initial) = initial_current_dir { |
@@ -549,13 +564,13 enum OnUnsupported { | |||
|
549 | 564 | /// Silently exit with code 252. |
|
550 | 565 | AbortSilent, |
|
551 | 566 | /// Try running a Python implementation |
|
552 | Fallback { executable: Vec<u8> }, | |
|
567 | Fallback { executable: Option<Vec<u8>> }, | |
|
553 | 568 | } |
|
554 | 569 | |
|
555 | 570 | impl OnUnsupported { |
|
556 | 571 | const DEFAULT: Self = OnUnsupported::Abort; |
|
557 | 572 | |
|
558 |
fn from_config( |
|
|
573 | fn from_config(config: &Config) -> Self { | |
|
559 | 574 | match config |
|
560 | 575 | .get(b"rhg", b"on-unsupported") |
|
561 | 576 | .map(|value| value.to_ascii_lowercase()) |
@@ -566,18 +581,7 impl OnUnsupported { | |||
|
566 | 581 | Some(b"fallback") => OnUnsupported::Fallback { |
|
567 | 582 | executable: config |
|
568 | 583 | .get(b"rhg", b"fallback-executable") |
|
569 |
. |
|
|
570 | exit_no_fallback( | |
|
571 | ui, | |
|
572 | Self::Abort, | |
|
573 | Err(CommandError::abort( | |
|
574 | "abort: 'rhg.on-unsupported=fallback' without \ | |
|
575 | 'rhg.fallback-executable' set." | |
|
576 | )), | |
|
577 | false, | |
|
578 | ) | |
|
579 | }) | |
|
580 | .to_owned(), | |
|
584 | .map(|x| x.to_owned()), | |
|
581 | 585 | }, |
|
582 | 586 | None => Self::DEFAULT, |
|
583 | 587 | Some(_) => { |
@@ -168,13 +168,12 Fallback to Python | |||
|
168 | 168 | $ rhg cat original --exclude="*.rs" |
|
169 | 169 | original content |
|
170 | 170 | |
|
171 | $ FALLBACK_EXE="$RHG_FALLBACK_EXECUTABLE" | |
|
172 | $ unset RHG_FALLBACK_EXECUTABLE | |
|
173 | $ rhg cat original --exclude="*.rs" | |
|
171 | $ (unset RHG_FALLBACK_EXECUTABLE; rhg cat original --exclude="*.rs") | |
|
174 | 172 | abort: 'rhg.on-unsupported=fallback' without 'rhg.fallback-executable' set. |
|
175 | 173 | [255] |
|
176 | $ RHG_FALLBACK_EXECUTABLE="$FALLBACK_EXE" | |
|
177 |
$ |
|
|
174 | ||
|
175 | $ (unset RHG_FALLBACK_EXECUTABLE; rhg cat original) | |
|
176 | original content | |
|
178 | 177 | |
|
179 | 178 | $ rhg cat original --exclude="*.rs" --config rhg.fallback-executable=false |
|
180 | 179 | [1] |
General Comments 0
You need to be logged in to leave comments.
Login now