pub trait Index: Send + Sync {
// Required methods
fn shortest_unique_commit_id_prefix_len(
&self,
commit_id: &CommitId,
) -> usize;
fn resolve_commit_id_prefix(
&self,
prefix: &HexPrefix,
) -> PrefixResolution<CommitId>;
fn has_id(&self, commit_id: &CommitId) -> bool;
fn is_ancestor(
&self,
ancestor_id: &CommitId,
descendant_id: &CommitId,
) -> bool;
fn common_ancestors(
&self,
set1: &[CommitId],
set2: &[CommitId],
) -> Vec<CommitId>;
fn all_heads_for_gc(
&self,
) -> Result<Box<dyn Iterator<Item = CommitId> + '_>, AllHeadsForGcUnsupported>;
fn heads(
&self,
candidates: &mut dyn Iterator<Item = &CommitId>,
) -> Result<Vec<CommitId>, IndexError>;
fn changed_paths_in_commit(
&self,
commit_id: &CommitId,
) -> Result<Option<Box<dyn Iterator<Item = RepoPathBuf> + '_>>, IndexError>;
fn evaluate_revset(
&self,
expression: &ResolvedExpression,
store: &Arc<Store>,
) -> Result<Box<dyn Revset + '_>, RevsetEvaluationError>;
}
Expand description
Defines the interface for types that provide an index of the commits in a
repository by CommitId
.
Required Methods§
Sourcefn shortest_unique_commit_id_prefix_len(&self, commit_id: &CommitId) -> usize
fn shortest_unique_commit_id_prefix_len(&self, commit_id: &CommitId) -> usize
Returns the minimum prefix length to disambiguate commit_id
from other
commits in the index. The length returned is the number of hexadecimal
digits in the minimum prefix.
If the given commit_id
doesn’t exist, returns the minimum prefix
length which matches none of the commits in the index.
Sourcefn resolve_commit_id_prefix(
&self,
prefix: &HexPrefix,
) -> PrefixResolution<CommitId>
fn resolve_commit_id_prefix( &self, prefix: &HexPrefix, ) -> PrefixResolution<CommitId>
Searches the index for commit IDs matching prefix
. Returns a
PrefixResolution
with a CommitId
if the prefix matches a single
commit.
Sourcefn has_id(&self, commit_id: &CommitId) -> bool
fn has_id(&self, commit_id: &CommitId) -> bool
Returns true if commit_id
is present in the index.
Sourcefn is_ancestor(&self, ancestor_id: &CommitId, descendant_id: &CommitId) -> bool
fn is_ancestor(&self, ancestor_id: &CommitId, descendant_id: &CommitId) -> bool
Returns true if ancestor_id
commit is an ancestor of the
descendant_id
commit, or if ancestor_id
equals descendant_id
.
Sourcefn common_ancestors(
&self,
set1: &[CommitId],
set2: &[CommitId],
) -> Vec<CommitId>
fn common_ancestors( &self, set1: &[CommitId], set2: &[CommitId], ) -> Vec<CommitId>
Returns the best common ancestor or ancestors of the commits in set1
and set2
. A “best common ancestor” has no descendants that are also
common ancestors.
Sourcefn all_heads_for_gc(
&self,
) -> Result<Box<dyn Iterator<Item = CommitId> + '_>, AllHeadsForGcUnsupported>
fn all_heads_for_gc( &self, ) -> Result<Box<dyn Iterator<Item = CommitId> + '_>, AllHeadsForGcUnsupported>
Heads among all indexed commits at the associated operation.
Suppose the index contains all the historical heads and their ancestors reachable from the associated operation, this function returns the heads that should be preserved on garbage collection.
The iteration order is unspecified.
Sourcefn heads(
&self,
candidates: &mut dyn Iterator<Item = &CommitId>,
) -> Result<Vec<CommitId>, IndexError>
fn heads( &self, candidates: &mut dyn Iterator<Item = &CommitId>, ) -> Result<Vec<CommitId>, IndexError>
Returns the subset of commit IDs in candidates
which are not ancestors
of other commits in candidates
. If a commit id is duplicated in the
candidates
list it will appear at most once in the output.
Sourcefn changed_paths_in_commit(
&self,
commit_id: &CommitId,
) -> Result<Option<Box<dyn Iterator<Item = RepoPathBuf> + '_>>, IndexError>
fn changed_paths_in_commit( &self, commit_id: &CommitId, ) -> Result<Option<Box<dyn Iterator<Item = RepoPathBuf> + '_>>, IndexError>
Returns iterator over paths changed at the specified commit. The paths
are sorted. Returns None
if the commit wasn’t indexed.
Sourcefn evaluate_revset(
&self,
expression: &ResolvedExpression,
store: &Arc<Store>,
) -> Result<Box<dyn Revset + '_>, RevsetEvaluationError>
fn evaluate_revset( &self, expression: &ResolvedExpression, store: &Arc<Store>, ) -> Result<Box<dyn Revset + '_>, RevsetEvaluationError>
Resolves the revset expression
against the index and corresponding
store
.