rust/rhg/src/commands/status.rs
changeset 49483 b18e877ea304
parent 49439 b07465adbcc8
child 49485 ffd4b1f1c9cb
equal deleted inserted replaced
49482:5fbdd88824dc 49483:b18e877ea304
   274         Result<(DirstateStatus<'a>, Vec<PatternFileWarning>), StatusError>;
   274         Result<(DirstateStatus<'a>, Vec<PatternFileWarning>), StatusError>;
   275 
   275 
   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 {
   304             let error = match error {
   283             let error = match error {
   305                 hg::BadMatch::OsError(code) => {
   284                 hg::BadMatch::OsError(code) => {
   580     } else {
   559     } else {
   581         vfs.read(fs_path)?
   560         vfs.read(fs_path)?
   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 }