comparison 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
comparison
equal deleted inserted replaced
45535:72b7d58d6e35 45536:639f33f22faf
40 Self { 40 Self {
41 bytes, 41 bytes,
42 offsets: None, 42 offsets: None,
43 } 43 }
44 } 44 }
45 }
46
47 /// Return number of entries of the revlog index.
48 pub fn len(&self) -> usize {
49 if let Some(offsets) = &self.offsets {
50 offsets.len()
51 } else {
52 self.bytes.len() / INDEX_ENTRY_SIZE
53 }
54 }
55
56 /// Returns `true` if the `Index` has zero `entries`.
57 pub fn is_empty(&self) -> bool {
58 self.len() == 0
45 } 59 }
46 60
47 /// Return the index entry corresponding to the given revision if it 61 /// Return the index entry corresponding to the given revision if it
48 /// exists. 62 /// exists.
49 pub fn get_entry(&self, rev: Revision) -> Option<IndexEntry> { 63 pub fn get_entry(&self, rev: Revision) -> Option<IndexEntry> {