Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/revlog/index.rs @ 45536:639f33f22faf
hg-core: add a `ListRevTrackedFiles` operation
List files tracked at a given revision.
Differential Revision: https://phab.mercurial-scm.org/D9014
author | Antoine Cezar <antoine.cezar@octobus.net> |
---|---|
date | Fri, 18 Sep 2020 16:52:16 +0200 |
parents | b0d6309ff50c |
children | 11f3c3f408fd |
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/index.rs Wed Sep 09 12:12:11 2020 +0200 +++ b/rust/hg-core/src/revlog/index.rs Fri Sep 18 16:52:16 2020 +0200 @@ -44,6 +44,20 @@ } } + /// Return number of entries of the revlog index. + pub fn len(&self) -> usize { + if let Some(offsets) = &self.offsets { + offsets.len() + } else { + self.bytes.len() / INDEX_ENTRY_SIZE + } + } + + /// Returns `true` if the `Index` has zero `entries`. + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + /// Return the index entry corresponding to the given revision if it /// exists. pub fn get_entry(&self, rev: Revision) -> Option<IndexEntry> {