diff rust/hg-core/src/errors.rs @ 46485:f031fe1c6ede

rhg: Abort based on config on share-safe mismatch Differential Revision: https://phab.mercurial-scm.org/D9963
author Simon Sapin <simon.sapin@octobus.net>
date Thu, 04 Feb 2021 14:29:47 +0100
parents 2845892dd489
children bc08c2331f99
line wrap: on
line diff
--- a/rust/hg-core/src/errors.rs	Thu Feb 04 13:17:55 2021 +0100
+++ b/rust/hg-core/src/errors.rs	Thu Feb 04 14:29:47 2021 +0100
@@ -8,7 +8,9 @@
         context: IoErrorContext,
     },
 
-    /// A file under `.hg/` normally only written by Mercurial
+    /// A file under `.hg/` normally only written by Mercurial is not in the
+    /// expected format. This indicates a bug in Mercurial, filesystem
+    /// corruption, or hardware failure.
     ///
     /// The given string is a short explanation for users, not intended to be
     /// machine-readable.
@@ -21,6 +23,12 @@
     /// The given string is a short explanation for users, not intended to be
     /// machine-readable.
     UnsupportedFeature(String),
+
+    /// Operation cannot proceed for some other reason.
+    ///
+    /// The given string is a short explanation for users, not intended to be
+    /// machine-readable.
+    Abort(String),
 }
 
 /// Details about where an I/O error happened
@@ -46,6 +54,9 @@
     pub fn unsupported(explanation: impl Into<String>) -> Self {
         HgError::UnsupportedFeature(explanation.into())
     }
+    pub fn abort(explanation: impl Into<String>) -> Self {
+        HgError::Abort(explanation.into())
+    }
 }
 
 // TODO: use `DisplayBytes` instead to show non-Unicode filenames losslessly?
@@ -61,6 +72,7 @@
             HgError::UnsupportedFeature(explanation) => {
                 write!(f, "unsupported feature: {}", explanation)
             }
+            HgError::Abort(explanation) => explanation.fmt(f),
         }
     }
 }