348 if let Ok(true) = config.get_bool(b"rhg", b"fallback-immediately") { |
348 if let Ok(true) = config.get_bool(b"rhg", b"fallback-immediately") { |
349 exit( |
349 exit( |
350 &argv, |
350 &argv, |
351 &initial_current_dir, |
351 &initial_current_dir, |
352 &ui, |
352 &ui, |
353 OnUnsupported::Fallback { |
353 OnUnsupported::fallback(config), |
354 executable: config |
|
355 .get(b"rhg", b"fallback-executable") |
|
356 .map(ToOwned::to_owned), |
|
357 }, |
|
358 Err(CommandError::unsupported( |
354 Err(CommandError::unsupported( |
359 "`rhg.fallback-immediately is true`", |
355 "`rhg.fallback-immediately is true`", |
360 )), |
356 )), |
361 false, |
357 false, |
362 ) |
358 ) |
661 } |
657 } |
662 |
658 |
663 impl OnUnsupported { |
659 impl OnUnsupported { |
664 const DEFAULT: Self = OnUnsupported::Abort; |
660 const DEFAULT: Self = OnUnsupported::Abort; |
665 |
661 |
|
662 fn fallback_executable(config: &Config) -> Option<Vec<u8>> { |
|
663 config |
|
664 .get(b"rhg", b"fallback-executable") |
|
665 .map(|x| x.to_owned()) |
|
666 } |
|
667 |
|
668 fn fallback(config: &Config) -> Self { |
|
669 OnUnsupported::Fallback { |
|
670 executable: Self::fallback_executable(config), |
|
671 } |
|
672 } |
|
673 |
666 fn from_config(config: &Config) -> Self { |
674 fn from_config(config: &Config) -> Self { |
667 match config |
675 match config |
668 .get(b"rhg", b"on-unsupported") |
676 .get(b"rhg", b"on-unsupported") |
669 .map(|value| value.to_ascii_lowercase()) |
677 .map(|value| value.to_ascii_lowercase()) |
670 .as_deref() |
678 .as_deref() |
671 { |
679 { |
672 Some(b"abort") => OnUnsupported::Abort, |
680 Some(b"abort") => OnUnsupported::Abort, |
673 Some(b"abort-silent") => OnUnsupported::AbortSilent, |
681 Some(b"abort-silent") => OnUnsupported::AbortSilent, |
674 Some(b"fallback") => OnUnsupported::Fallback { |
682 Some(b"fallback") => Self::fallback(config), |
675 executable: config |
|
676 .get(b"rhg", b"fallback-executable") |
|
677 .map(|x| x.to_owned()), |
|
678 }, |
|
679 None => Self::DEFAULT, |
683 None => Self::DEFAULT, |
680 Some(_) => { |
684 Some(_) => { |
681 // TODO: warn about unknown config value |
685 // TODO: warn about unknown config value |
682 Self::DEFAULT |
686 Self::DEFAULT |
683 } |
687 } |