changeset 48506:0c408831b2f1

rhg: Print "bad match" errors in rhg status Previously these would only be visible if enabled with some RUST_LOG environment variable. Differential Revision: https://phab.mercurial-scm.org/D11908
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 13 Dec 2021 14:37:16 +0100
parents bf2738e03e96
children 9dd151a39950
files rust/rhg/src/commands/status.rs tests/test-permissions.t
diffstat 2 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/rust/rhg/src/commands/status.rs	Tue Dec 07 15:14:08 2021 +0100
+++ b/rust/rhg/src/commands/status.rs	Mon Dec 13 14:37:16 2021 +0100
@@ -237,8 +237,20 @@
         warn!("Pattern warnings: {:?}", &pattern_warnings);
     }
 
-    if !ds_status.bad.is_empty() {
-        warn!("Bad matches {:?}", &(ds_status.bad))
+    for (path, error) in ds_status.bad {
+        let error = match error {
+            hg::BadMatch::OsError(code) => {
+                std::io::Error::from_raw_os_error(code).to_string()
+            }
+            hg::BadMatch::BadType(ty) => {
+                format!("unsupported file type (type is {})", ty)
+            }
+        };
+        ui.write_stderr(&format_bytes!(
+            b"{}: {}\n",
+            path.as_bytes(),
+            error.as_bytes()
+        ))?
     }
     if !ds_status.unsure.is_empty() {
         info!(
--- a/tests/test-permissions.t	Tue Dec 07 15:14:08 2021 +0100
+++ b/tests/test-permissions.t	Mon Dec 13 14:37:16 2021 +0100
@@ -11,10 +11,6 @@
   > EOF
 #endif
 
-TODO: fix rhg bugs that make this test fail when status is enabled
-  $ unset RHG_STATUS
-
-
   $ hg init t
   $ cd t
 
@@ -82,7 +78,7 @@
 (fsmonitor makes "hg status" avoid accessing to "dir")
 
   $ hg status
-  dir: Permission denied
+  dir: Permission denied* (glob)
   M a
 
 #endif