##// END OF EJS Templates
rhg-status: extract a function for printing pattern file warnings...
Raphaël Gomès -
r50378:b18e877e default
parent child Browse files
Show More
@@ -276,28 +276,7 b' pub fn run(invocation: &crate::CliInvoca'
276 let after_status = |res: StatusResult| -> Result<_, CommandError> {
276 let after_status = |res: StatusResult| -> Result<_, CommandError> {
277 let (mut ds_status, pattern_warnings) = res?;
277 let (mut ds_status, pattern_warnings) = res?;
278 for warning in pattern_warnings {
278 for warning in pattern_warnings {
279 match warning {
279 ui.write_stderr(&print_pattern_file_warning(&warning, &repo))?;
280 hg::PatternFileWarning::InvalidSyntax(path, syntax) => ui
281 .write_stderr(&format_bytes!(
282 b"{}: ignoring invalid syntax '{}'\n",
283 get_bytes_from_path(path),
284 &*syntax
285 ))?,
286 hg::PatternFileWarning::NoSuchFile(path) => {
287 let path = if let Ok(relative) =
288 path.strip_prefix(repo.working_directory_path())
289 {
290 relative
291 } else {
292 &*path
293 };
294 ui.write_stderr(&format_bytes!(
295 b"skipping unreadable pattern file '{}': \
296 No such file or directory\n",
297 get_bytes_from_path(path),
298 ))?
299 }
300 }
301 }
280 }
302
281
303 for (path, error) in ds_status.bad {
282 for (path, error) in ds_status.bad {
@@ -582,3 +561,30 b' fn unsure_is_modified('
582 };
561 };
583 Ok(p1_contents != &*fs_contents)
562 Ok(p1_contents != &*fs_contents)
584 }
563 }
564
565 fn print_pattern_file_warning(
566 warning: &PatternFileWarning,
567 repo: &Repo,
568 ) -> Vec<u8> {
569 match warning {
570 PatternFileWarning::InvalidSyntax(path, syntax) => format_bytes!(
571 b"{}: ignoring invalid syntax '{}'\n",
572 get_bytes_from_path(path),
573 &*syntax
574 ),
575 PatternFileWarning::NoSuchFile(path) => {
576 let path = if let Ok(relative) =
577 path.strip_prefix(repo.working_directory_path())
578 {
579 relative
580 } else {
581 &*path
582 };
583 format_bytes!(
584 b"skipping unreadable pattern file '{}': \
585 No such file or directory\n",
586 get_bytes_from_path(path),
587 )
588 }
589 }
590 }
General Comments 0
You need to be logged in to leave comments. Login now