D7789: rust-revlog: a trait for the revlog index

gracinet (Georges Racinet) phabricator at mercurial-scm.org
Mon Jan 6 19:25:19 UTC 2020


gracinet created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  As explained in the doc comment, this is the minimum needed
  for our immediate concern, which is to implement a nodemap
  in Rust.
  
  The trait will be later implemented in `hg-cpython` by the
  index Python object implemented in C, thanks to exposition
  of the corresponding functions as a capsule.
  
  The `None` return cases in `node()` match what the `index_node()`
  C function does.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7789

AFFECTED FILES
  rust/hg-core/src/revlog.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/revlog.rs b/rust/hg-core/src/revlog.rs
--- a/rust/hg-core/src/revlog.rs
+++ b/rust/hg-core/src/revlog.rs
@@ -40,3 +40,15 @@
     ParentOutOfRange(Revision),
     WorkingDirectoryUnsupported,
 }
+
+/// The Mercurial Revlog Index
+///
+/// This is currently limited to the minimal interface that is needed for
+/// the [`nodemap`](nodemap/index.html) module
+pub trait RevlogIndex {
+    /// Total number of Revisions referenced in this index
+    fn len(&self) -> usize;
+
+    /// Return the Node or `None` if rev is out of bounds or `NULL_REVISON`
+    fn node(&self, rev: Revision) -> Option<&Node>;
+}



To: gracinet, #hg-reviewers
Cc: durin42, kevincox, mercurial-devel


More information about the Mercurial-devel mailing list