##// END OF EJS Templates
rhg: Remove `rhg.fallback-executable=hg` default configuration...
Simon Sapin -
r47482:bde90e9b default
parent child Browse files
Show More
@@ -138,7 +138,7 b' fn main() {'
138 exit(
138 exit(
139 &initial_current_dir,
139 &initial_current_dir,
140 &ui,
140 &ui,
141 OnUnsupported::from_config(&non_repo_config),
141 OnUnsupported::from_config(&ui, &non_repo_config),
142 Err(CommandError::UnsupportedFeature {
142 Err(CommandError::UnsupportedFeature {
143 message: format_bytes!(
143 message: format_bytes!(
144 b"URL-like --repository {}",
144 b"URL-like --repository {}",
@@ -158,7 +158,7 b' fn main() {'
158 Err(error) => exit(
158 Err(error) => exit(
159 &initial_current_dir,
159 &initial_current_dir,
160 &ui,
160 &ui,
161 OnUnsupported::from_config(&non_repo_config),
161 OnUnsupported::from_config(&ui, &non_repo_config),
162 Err(error.into()),
162 Err(error.into()),
163 ),
163 ),
164 };
164 };
@@ -168,6 +168,7 b' fn main() {'
168 } else {
168 } else {
169 &non_repo_config
169 &non_repo_config
170 };
170 };
171 let on_unsupported = OnUnsupported::from_config(&ui, config);
171
172
172 let result = main_with_result(
173 let result = main_with_result(
173 &process_start_time,
174 &process_start_time,
@@ -175,12 +176,7 b' fn main() {'
175 repo_result.as_ref(),
176 repo_result.as_ref(),
176 config,
177 config,
177 );
178 );
178 exit(
179 exit(&initial_current_dir, &ui, on_unsupported, result)
179 &initial_current_dir,
180 &ui,
181 OnUnsupported::from_config(config),
182 result,
183 )
184 }
180 }
185
181
186 fn exit_code(result: &Result<(), CommandError>) -> i32 {
182 fn exit_code(result: &Result<(), CommandError>) -> i32 {
@@ -242,6 +238,14 b' fn exit('
242 }
238 }
243 }
239 }
244 }
240 }
241 exit_no_fallback(ui, on_unsupported, result)
242 }
243
244 fn exit_no_fallback(
245 ui: &Ui,
246 on_unsupported: OnUnsupported,
247 result: Result<(), CommandError>,
248 ) -> ! {
245 match &result {
249 match &result {
246 Ok(_) => {}
250 Ok(_) => {}
247 Err(CommandError::Unsuccessful) => {}
251 Err(CommandError::Unsuccessful) => {}
@@ -387,9 +391,8 b' enum OnUnsupported {'
387
391
388 impl OnUnsupported {
392 impl OnUnsupported {
389 const DEFAULT: Self = OnUnsupported::Abort;
393 const DEFAULT: Self = OnUnsupported::Abort;
390 const DEFAULT_FALLBACK_EXECUTABLE: &'static [u8] = b"hg";
391
394
392 fn from_config(config: &Config) -> Self {
395 fn from_config(ui: &Ui, config: &Config) -> Self {
393 match config
396 match config
394 .get(b"rhg", b"on-unsupported")
397 .get(b"rhg", b"on-unsupported")
395 .map(|value| value.to_ascii_lowercase())
398 .map(|value| value.to_ascii_lowercase())
@@ -400,7 +403,16 b' impl OnUnsupported {'
400 Some(b"fallback") => OnUnsupported::Fallback {
403 Some(b"fallback") => OnUnsupported::Fallback {
401 executable: config
404 executable: config
402 .get(b"rhg", b"fallback-executable")
405 .get(b"rhg", b"fallback-executable")
403 .unwrap_or(Self::DEFAULT_FALLBACK_EXECUTABLE)
406 .unwrap_or_else(|| {
407 exit_no_fallback(
408 ui,
409 Self::Abort,
410 Err(CommandError::abort(
411 "abort: 'rhg.on-unsupported=fallback' without \
412 'rhg.fallback-executable' set."
413 )),
414 )
415 })
404 .to_owned(),
416 .to_owned(),
405 },
417 },
406 None => Self::DEFAULT,
418 None => Self::DEFAULT,
@@ -150,6 +150,14 b' Fallback to Python'
150 $ rhg cat original
150 $ rhg cat original
151 original content
151 original content
152
152
153 $ FALLBACK_EXE="$RHG_FALLBACK_EXECUTABLE"
154 $ unset RHG_FALLBACK_EXECUTABLE
155 $ rhg cat original
156 abort: 'rhg.on-unsupported=fallback' without 'rhg.fallback-executable' set.
157 [255]
158 $ RHG_FALLBACK_EXECUTABLE="$FALLBACK_EXE"
159 $ export RHG_FALLBACK_EXECUTABLE
160
153 $ rhg cat original --config rhg.fallback-executable=false
161 $ rhg cat original --config rhg.fallback-executable=false
154 [1]
162 [1]
155
163
General Comments 0
You need to be logged in to leave comments. Login now