Mercurial > public > mercurial-scm > hg-stable
comparison rust/rhg/src/commands/status.rs @ 48548:c9abfb80b4e3
rhg: Properly format warnings related to ignore patterns
Differential Revision: https://phab.mercurial-scm.org/D11941
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Fri, 17 Dec 2021 16:54:22 +0100 |
parents | 4afb9627dc77 |
children | 47f2a82ae3e4 |
comparison
equal
deleted
inserted
replaced
48547:7f633432ca92 | 48548:c9abfb80b4e3 |
---|---|
20 use hg::lock::LockError; | 20 use hg::lock::LockError; |
21 use hg::manifest::Manifest; | 21 use hg::manifest::Manifest; |
22 use hg::matchers::AlwaysMatcher; | 22 use hg::matchers::AlwaysMatcher; |
23 use hg::repo::Repo; | 23 use hg::repo::Repo; |
24 use hg::utils::files::get_bytes_from_os_string; | 24 use hg::utils::files::get_bytes_from_os_string; |
25 use hg::utils::files::get_bytes_from_path; | |
25 use hg::utils::files::get_path_from_bytes; | 26 use hg::utils::files::get_path_from_bytes; |
26 use hg::utils::hg_path::{hg_path_to_path_buf, HgPath}; | 27 use hg::utils::hg_path::{hg_path_to_path_buf, HgPath}; |
27 use hg::StatusOptions; | 28 use hg::StatusOptions; |
28 use log::{info, warn}; | 29 use log::info; |
29 use std::io; | 30 use std::io; |
30 use std::path::PathBuf; | 31 use std::path::PathBuf; |
31 | 32 |
32 pub const HELP_TEXT: &str = " | 33 pub const HELP_TEXT: &str = " |
33 Show changed files in the working directory | 34 Show changed files in the working directory |
231 &AlwaysMatcher, | 232 &AlwaysMatcher, |
232 repo.working_directory_path().to_owned(), | 233 repo.working_directory_path().to_owned(), |
233 ignore_files(repo, config), | 234 ignore_files(repo, config), |
234 options, | 235 options, |
235 )?; | 236 )?; |
236 if !pattern_warnings.is_empty() { | 237 for warning in pattern_warnings { |
237 warn!("Pattern warnings: {:?}", &pattern_warnings); | 238 match warning { |
239 hg::PatternFileWarning::InvalidSyntax(path, syntax) => ui | |
240 .write_stderr(&format_bytes!( | |
241 b"{}: ignoring invalid syntax '{}'\n", | |
242 get_bytes_from_path(path), | |
243 &*syntax | |
244 ))?, | |
245 hg::PatternFileWarning::NoSuchFile(path) => { | |
246 let path = if let Ok(relative) = | |
247 path.strip_prefix(repo.working_directory_path()) | |
248 { | |
249 relative | |
250 } else { | |
251 &*path | |
252 }; | |
253 ui.write_stderr(&format_bytes!( | |
254 b"skipping unreadable pattern file '{}': \ | |
255 No such file or directory\n", | |
256 get_bytes_from_path(path), | |
257 ))? | |
258 } | |
259 } | |
238 } | 260 } |
239 | 261 |
240 for (path, error) in ds_status.bad { | 262 for (path, error) in ds_status.bad { |
241 let error = match error { | 263 let error = match error { |
242 hg::BadMatch::OsError(code) => { | 264 hg::BadMatch::OsError(code) => { |