mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-06 03:22:59 +00:00
id_prefix: rename IdIndex::resolve_prefix() to resolve_prefix_to_values()
I'll add a key resolution method.
This commit is contained in:
parent
e7f83e7681
commit
e93ff5815c
1 changed files with 11 additions and 11 deletions
|
@ -99,7 +99,7 @@ impl IdPrefixContext {
|
|||
prefix: &HexPrefix,
|
||||
) -> PrefixResolution<CommitId> {
|
||||
if let Some(indexes) = self.disambiguation_indexes(repo) {
|
||||
let resolution = indexes.commit_index.resolve_prefix(prefix);
|
||||
let resolution = indexes.commit_index.resolve_prefix_to_values(prefix);
|
||||
if let PrefixResolution::SingleMatch(mut ids) = resolution {
|
||||
assert_eq!(ids.len(), 1);
|
||||
return PrefixResolution::SingleMatch(ids.pop().unwrap());
|
||||
|
@ -127,7 +127,7 @@ impl IdPrefixContext {
|
|||
prefix: &HexPrefix,
|
||||
) -> PrefixResolution<Vec<CommitId>> {
|
||||
if let Some(indexes) = self.disambiguation_indexes(repo) {
|
||||
let resolution = indexes.change_index.resolve_prefix(prefix);
|
||||
let resolution = indexes.change_index.resolve_prefix_to_values(prefix);
|
||||
if let PrefixResolution::SingleMatch(ids) = resolution {
|
||||
return PrefixResolution::SingleMatch(ids);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ where
|
|||
|
||||
/// Looks up entries with the given prefix, and collects values if matched
|
||||
/// entries have unambiguous keys.
|
||||
pub fn resolve_prefix(&self, prefix: &HexPrefix) -> PrefixResolution<Vec<V>>
|
||||
pub fn resolve_prefix_to_values(&self, prefix: &HexPrefix) -> PrefixResolution<Vec<V>>
|
||||
where
|
||||
V: Clone,
|
||||
{
|
||||
|
@ -262,35 +262,35 @@ mod tests {
|
|||
(ChangeId::from_hex("0aab"), 4),
|
||||
]);
|
||||
assert_eq!(
|
||||
id_index.resolve_prefix(&HexPrefix::new("0").unwrap()),
|
||||
id_index.resolve_prefix_to_values(&HexPrefix::new("0").unwrap()),
|
||||
PrefixResolution::AmbiguousMatch,
|
||||
);
|
||||
assert_eq!(
|
||||
id_index.resolve_prefix(&HexPrefix::new("00").unwrap()),
|
||||
id_index.resolve_prefix_to_values(&HexPrefix::new("00").unwrap()),
|
||||
PrefixResolution::AmbiguousMatch,
|
||||
);
|
||||
assert_eq!(
|
||||
id_index.resolve_prefix(&HexPrefix::new("000").unwrap()),
|
||||
id_index.resolve_prefix_to_values(&HexPrefix::new("000").unwrap()),
|
||||
PrefixResolution::SingleMatch(vec![0]),
|
||||
);
|
||||
assert_eq!(
|
||||
id_index.resolve_prefix(&HexPrefix::new("0001").unwrap()),
|
||||
id_index.resolve_prefix_to_values(&HexPrefix::new("0001").unwrap()),
|
||||
PrefixResolution::NoMatch,
|
||||
);
|
||||
assert_eq!(
|
||||
sorted(id_index.resolve_prefix(&HexPrefix::new("009").unwrap())),
|
||||
sorted(id_index.resolve_prefix_to_values(&HexPrefix::new("009").unwrap())),
|
||||
PrefixResolution::SingleMatch(vec![1, 2]),
|
||||
);
|
||||
assert_eq!(
|
||||
id_index.resolve_prefix(&HexPrefix::new("0aa").unwrap()),
|
||||
id_index.resolve_prefix_to_values(&HexPrefix::new("0aa").unwrap()),
|
||||
PrefixResolution::AmbiguousMatch,
|
||||
);
|
||||
assert_eq!(
|
||||
id_index.resolve_prefix(&HexPrefix::new("0aab").unwrap()),
|
||||
id_index.resolve_prefix_to_values(&HexPrefix::new("0aab").unwrap()),
|
||||
PrefixResolution::SingleMatch(vec![4]),
|
||||
);
|
||||
assert_eq!(
|
||||
id_index.resolve_prefix(&HexPrefix::new("f").unwrap()),
|
||||
id_index.resolve_prefix_to_values(&HexPrefix::new("f").unwrap()),
|
||||
PrefixResolution::NoMatch,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue