mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-06 11:34:54 +00:00
id_prefix: remove redundant CommidId field from disambiguation index
This commit is contained in:
parent
44927be7c9
commit
4d39fdf614
1 changed files with 5 additions and 7 deletions
|
@ -27,12 +27,11 @@ struct PrefixDisambiguationError;
|
||||||
struct DisambiguationData {
|
struct DisambiguationData {
|
||||||
expression: Rc<RevsetExpression>,
|
expression: Rc<RevsetExpression>,
|
||||||
workspace_id: Option<WorkspaceId>,
|
workspace_id: Option<WorkspaceId>,
|
||||||
// TODO: We shouldn't have to duplicate the CommitId as value
|
|
||||||
indexes: OnceCell<Indexes>,
|
indexes: OnceCell<Indexes>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Indexes {
|
struct Indexes {
|
||||||
commit_index: IdIndex<CommitId, CommitId>,
|
commit_index: IdIndex<CommitId, ()>,
|
||||||
change_index: IdIndex<ChangeId, CommitId>,
|
change_index: IdIndex<ChangeId, CommitId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ impl DisambiguationData {
|
||||||
let mut change_id_vec = vec![];
|
let mut change_id_vec = vec![];
|
||||||
for commit in revset.iter().commits(repo.store()) {
|
for commit in revset.iter().commits(repo.store()) {
|
||||||
let commit = commit.map_err(|_| PrefixDisambiguationError)?;
|
let commit = commit.map_err(|_| PrefixDisambiguationError)?;
|
||||||
commit_id_vec.push((commit.id().clone(), commit.id().clone()));
|
commit_id_vec.push((commit.id().clone(), ()));
|
||||||
change_id_vec.push((commit.change_id().clone(), commit.id().clone()));
|
change_id_vec.push((commit.change_id().clone(), commit.id().clone()));
|
||||||
}
|
}
|
||||||
Ok(Indexes {
|
Ok(Indexes {
|
||||||
|
@ -99,10 +98,9 @@ impl IdPrefixContext {
|
||||||
prefix: &HexPrefix,
|
prefix: &HexPrefix,
|
||||||
) -> PrefixResolution<CommitId> {
|
) -> PrefixResolution<CommitId> {
|
||||||
if let Some(indexes) = self.disambiguation_indexes(repo) {
|
if let Some(indexes) = self.disambiguation_indexes(repo) {
|
||||||
let resolution = indexes.commit_index.resolve_prefix_to_values(prefix);
|
let resolution = indexes.commit_index.resolve_prefix_to_key(prefix);
|
||||||
if let PrefixResolution::SingleMatch(mut ids) = resolution {
|
if let PrefixResolution::SingleMatch(id) = resolution {
|
||||||
assert_eq!(ids.len(), 1);
|
return PrefixResolution::SingleMatch(id.clone());
|
||||||
return PrefixResolution::SingleMatch(ids.pop().unwrap());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repo.index().resolve_prefix(prefix)
|
repo.index().resolve_prefix(prefix)
|
||||||
|
|
Loading…
Reference in a new issue