changeset 48511: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 7f633432ca92
children 262a38f10427
files rust/rhg/src/commands/status.rs
diffstat 1 files changed, 25 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rust/rhg/src/commands/status.rs	Tue Nov 09 18:17:52 2021 +0100
+++ b/rust/rhg/src/commands/status.rs	Fri Dec 17 16:54:22 2021 +0100
@@ -22,10 +22,11 @@
 use hg::matchers::AlwaysMatcher;
 use hg::repo::Repo;
 use hg::utils::files::get_bytes_from_os_string;
+use hg::utils::files::get_bytes_from_path;
 use hg::utils::files::get_path_from_bytes;
 use hg::utils::hg_path::{hg_path_to_path_buf, HgPath};
 use hg::StatusOptions;
-use log::{info, warn};
+use log::info;
 use std::io;
 use std::path::PathBuf;
 
@@ -233,8 +234,29 @@
         ignore_files(repo, config),
         options,
     )?;
-    if !pattern_warnings.is_empty() {
-        warn!("Pattern warnings: {:?}", &pattern_warnings);
+    for warning in pattern_warnings {
+        match warning {
+            hg::PatternFileWarning::InvalidSyntax(path, syntax) => ui
+                .write_stderr(&format_bytes!(
+                    b"{}: ignoring invalid syntax '{}'\n",
+                    get_bytes_from_path(path),
+                    &*syntax
+                ))?,
+            hg::PatternFileWarning::NoSuchFile(path) => {
+                let path = if let Ok(relative) =
+                    path.strip_prefix(repo.working_directory_path())
+                {
+                    relative
+                } else {
+                    &*path
+                };
+                ui.write_stderr(&format_bytes!(
+                    b"skipping unreadable pattern file '{}': \
+                      No such file or directory\n",
+                    get_bytes_from_path(path),
+                ))?
+            }
+        }
     }
 
     for (path, error) in ds_status.bad {