##// 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 138 exit(
139 139 &initial_current_dir,
140 140 &ui,
141 OnUnsupported::from_config(&non_repo_config),
141 OnUnsupported::from_config(&ui, &non_repo_config),
142 142 Err(CommandError::UnsupportedFeature {
143 143 message: format_bytes!(
144 144 b"URL-like --repository {}",
@@ -158,7 +158,7 b' fn main() {'
158 158 Err(error) => exit(
159 159 &initial_current_dir,
160 160 &ui,
161 OnUnsupported::from_config(&non_repo_config),
161 OnUnsupported::from_config(&ui, &non_repo_config),
162 162 Err(error.into()),
163 163 ),
164 164 };
@@ -168,6 +168,7 b' fn main() {'
168 168 } else {
169 169 &non_repo_config
170 170 };
171 let on_unsupported = OnUnsupported::from_config(&ui, config);
171 172
172 173 let result = main_with_result(
173 174 &process_start_time,
@@ -175,12 +176,7 b' fn main() {'
175 176 repo_result.as_ref(),
176 177 config,
177 178 );
178 exit(
179 &initial_current_dir,
180 &ui,
181 OnUnsupported::from_config(config),
182 result,
183 )
179 exit(&initial_current_dir, &ui, on_unsupported, result)
184 180 }
185 181
186 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 249 match &result {
246 250 Ok(_) => {}
247 251 Err(CommandError::Unsuccessful) => {}
@@ -387,9 +391,8 b' enum OnUnsupported {'
387 391
388 392 impl OnUnsupported {
389 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 396 match config
394 397 .get(b"rhg", b"on-unsupported")
395 398 .map(|value| value.to_ascii_lowercase())
@@ -400,7 +403,16 b' impl OnUnsupported {'
400 403 Some(b"fallback") => OnUnsupported::Fallback {
401 404 executable: config
402 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 416 .to_owned(),
405 417 },
406 418 None => Self::DEFAULT,
@@ -150,6 +150,14 b' Fallback to Python'
150 150 $ rhg cat original
151 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 161 $ rhg cat original --config rhg.fallback-executable=false
154 162 [1]
155 163
General Comments 0
You need to be logged in to leave comments. Login now