diff rust/hg-core/src/revlog/mod.rs @ 52785:2fb13c3f4496

rust: add GraphError::ParentOutOfOrder This will be used in a follow-up commit that creates a data structure optimized for inserting revisions in descending order, since it will need to fail if a revision number is greater than its descendant (meaning the graph is corrupted).
author Mitchell Kember <mkember@janestreet.com>
date Fri, 07 Feb 2025 16:07:35 -0500
parents 169ccd142ef8
children 155e1e8dc055
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/mod.rs	Fri Feb 07 16:03:35 2025 -0500
+++ b/rust/hg-core/src/revlog/mod.rs	Fri Feb 07 16:07:35 2025 -0500
@@ -136,7 +136,10 @@
 
 #[derive(Clone, Debug, PartialEq)]
 pub enum GraphError {
+    /// Parent revision does not exist, i.e. below 0 or above max revision.
     ParentOutOfRange(Revision),
+    /// Parent revision number is greater than one of its descendants.
+    ParentOutOfOrder(Revision),
 }
 
 impl std::fmt::Display for GraphError {
@@ -145,6 +148,9 @@
             GraphError::ParentOutOfRange(revision) => {
                 write!(f, "parent out of range ({})", revision)
             }
+            GraphError::ParentOutOfOrder(revision) => {
+                write!(f, "parent out of order ({})", revision)
+            }
         }
     }
 }