Skip to content

Commit ce5a320

Browse files
committed
adapt to changes in gix-revision
1 parent dfedf6a commit ce5a320

File tree

15 files changed

+96
-59
lines changed

15 files changed

+96
-59
lines changed

gix-negotiate/src/consecutive.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl Default for Algorithm {
1919

2020
impl Algorithm {
2121
/// Add `id` to our priority queue and *add* `flags` to it.
22-
fn add_to_queue(&mut self, id: ObjectId, mark: Flags, graph: &mut crate::Graph<'_>) -> Result<(), Error> {
22+
fn add_to_queue(&mut self, id: ObjectId, mark: Flags, graph: &mut crate::Graph<'_, '_>) -> Result<(), Error> {
2323
let mut is_common = false;
2424
let mut has_mark = false;
2525
if let Some(commit) = graph
@@ -43,7 +43,7 @@ impl Algorithm {
4343
id: ObjectId,
4444
mode: Mark,
4545
ancestors: Ancestors,
46-
graph: &mut crate::Graph<'_>,
46+
graph: &mut crate::Graph<'_, '_>,
4747
) -> Result<(), Error> {
4848
let mut is_common = false;
4949
if let Some(commit) = graph
@@ -89,7 +89,7 @@ impl Algorithm {
8989
}
9090

9191
impl Negotiator for Algorithm {
92-
fn known_common(&mut self, id: ObjectId, graph: &mut crate::Graph<'_>) -> Result<(), Error> {
92+
fn known_common(&mut self, id: ObjectId, graph: &mut crate::Graph<'_, '_>) -> Result<(), Error> {
9393
if graph
9494
.get(&id)
9595
.map_or(true, |commit| !commit.data.flags.contains(Flags::SEEN))
@@ -100,11 +100,11 @@ impl Negotiator for Algorithm {
100100
Ok(())
101101
}
102102

103-
fn add_tip(&mut self, id: ObjectId, graph: &mut crate::Graph<'_>) -> Result<(), Error> {
103+
fn add_tip(&mut self, id: ObjectId, graph: &mut crate::Graph<'_, '_>) -> Result<(), Error> {
104104
self.add_to_queue(id, Flags::SEEN, graph)
105105
}
106106

107-
fn next_have(&mut self, graph: &mut crate::Graph<'_>) -> Option<Result<ObjectId, Error>> {
107+
fn next_have(&mut self, graph: &mut crate::Graph<'_, '_>) -> Option<Result<ObjectId, Error>> {
108108
loop {
109109
let id = self.revs.pop_value().filter(|_| self.non_common_revs != 0)?;
110110
let commit = graph.get_mut(&id).expect("it was added to the graph by now");
@@ -145,7 +145,7 @@ impl Negotiator for Algorithm {
145145
}
146146
}
147147

148-
fn in_common_with_remote(&mut self, id: ObjectId, graph: &mut crate::Graph<'_>) -> Result<bool, Error> {
148+
fn in_common_with_remote(&mut self, id: ObjectId, graph: &mut crate::Graph<'_, '_>) -> Result<bool, Error> {
149149
let known_to_be_common = graph
150150
.get(&id)
151151
.map_or(false, |commit| commit.data.flags.contains(Flags::COMMON));

gix-negotiate/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub struct Metadata {
5858
}
5959

6060
/// The graph our callers use to store traversal information, for (re-)use in the negotiation implementation.
61-
pub type Graph<'find> = gix_revwalk::Graph<'find, gix_revwalk::graph::Commit<Metadata>>;
61+
pub type Graph<'find, 'cache> = gix_revwalk::Graph<'find, 'cache, gix_revwalk::graph::Commit<Metadata>>;
6262

6363
/// A map associating an object id with its commit-metadata.
6464
pub type IdMap = gix_revwalk::graph::IdMap<gix_revwalk::graph::Commit<Metadata>>;
@@ -125,22 +125,22 @@ pub trait Negotiator {
125125
/// Mark `id` as common between the remote and us.
126126
///
127127
/// These ids are typically the local tips of remote tracking branches.
128-
fn known_common(&mut self, id: gix_hash::ObjectId, graph: &mut Graph<'_>) -> Result<(), Error>;
128+
fn known_common(&mut self, id: gix_hash::ObjectId, graph: &mut Graph<'_, '_>) -> Result<(), Error>;
129129

130130
/// Add `id` as starting point of a traversal across commits that aren't necessarily common between the remote and us.
131131
///
132132
/// These tips are usually the commits of local references whose tips should lead to objects that we have in common with the remote.
133-
fn add_tip(&mut self, id: gix_hash::ObjectId, graph: &mut Graph<'_>) -> Result<(), Error>;
133+
fn add_tip(&mut self, id: gix_hash::ObjectId, graph: &mut Graph<'_, '_>) -> Result<(), Error>;
134134

135135
/// Produce the next id of an object that we want the server to know we have. It's an object we don't know we have in common or not.
136136
///
137137
/// Returns `None` if we have exhausted all options, which might mean we have traversed the entire commit graph.
138-
fn next_have(&mut self, graph: &mut Graph<'_>) -> Option<Result<gix_hash::ObjectId, Error>>;
138+
fn next_have(&mut self, graph: &mut Graph<'_, '_>) -> Option<Result<gix_hash::ObjectId, Error>>;
139139

140140
/// Mark `id` as being common with the remote (as informed by the remote itself) and return `true` if we knew it was common already.
141141
///
142142
/// We can assume to have already seen `id` as we were the one to inform the remote in a prior `have`.
143-
fn in_common_with_remote(&mut self, id: gix_hash::ObjectId, graph: &mut Graph<'_>) -> Result<bool, Error>;
143+
fn in_common_with_remote(&mut self, id: gix_hash::ObjectId, graph: &mut Graph<'_, '_>) -> Result<bool, Error>;
144144
}
145145

146146
/// An error that happened during any of the methods on a [`Negotiator`].

gix-negotiate/src/noop.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ use crate::{Error, Negotiator};
55
pub(crate) struct Noop;
66

77
impl Negotiator for Noop {
8-
fn known_common(&mut self, _id: ObjectId, _graph: &mut crate::Graph<'_>) -> Result<(), Error> {
8+
fn known_common(&mut self, _id: ObjectId, _graph: &mut crate::Graph<'_, '_>) -> Result<(), Error> {
99
Ok(())
1010
}
1111

12-
fn add_tip(&mut self, _id: ObjectId, _graph: &mut crate::Graph<'_>) -> Result<(), Error> {
12+
fn add_tip(&mut self, _id: ObjectId, _graph: &mut crate::Graph<'_, '_>) -> Result<(), Error> {
1313
Ok(())
1414
}
1515

16-
fn next_have(&mut self, _graph: &mut crate::Graph<'_>) -> Option<Result<ObjectId, Error>> {
16+
fn next_have(&mut self, _graph: &mut crate::Graph<'_, '_>) -> Option<Result<ObjectId, Error>> {
1717
None
1818
}
1919

20-
fn in_common_with_remote(&mut self, _id: ObjectId, _graph: &mut crate::Graph<'_>) -> Result<bool, Error> {
20+
fn in_common_with_remote(&mut self, _id: ObjectId, _graph: &mut crate::Graph<'_, '_>) -> Result<bool, Error> {
2121
Ok(false)
2222
}
2323
}

gix-negotiate/src/skipping.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl Default for Algorithm {
1919

2020
impl Algorithm {
2121
/// Add `id` to our priority queue and *add* `flags` to it.
22-
fn add_to_queue(&mut self, id: ObjectId, mark: Flags, graph: &mut crate::Graph<'_>) -> Result<(), Error> {
22+
fn add_to_queue(&mut self, id: ObjectId, mark: Flags, graph: &mut crate::Graph<'_, '_>) -> Result<(), Error> {
2323
let commit = graph.try_lookup_or_insert_commit(id, |entry| {
2424
entry.flags |= mark | Flags::SEEN;
2525
})?;
@@ -32,7 +32,7 @@ impl Algorithm {
3232
Ok(())
3333
}
3434

35-
fn mark_common(&mut self, id: ObjectId, graph: &mut crate::Graph<'_>) -> Result<(), Error> {
35+
fn mark_common(&mut self, id: ObjectId, graph: &mut crate::Graph<'_, '_>) -> Result<(), Error> {
3636
let mut is_common = false;
3737
if let Some(commit) = graph
3838
.try_lookup_or_insert_commit(id, |entry| {
@@ -76,7 +76,7 @@ impl Algorithm {
7676
&mut self,
7777
entry: Metadata,
7878
parent_id: ObjectId,
79-
graph: &mut crate::Graph<'_>,
79+
graph: &mut crate::Graph<'_, '_>,
8080
) -> Result<bool, Error> {
8181
let mut was_seen = false;
8282
if let Some(parent) = graph
@@ -113,7 +113,7 @@ impl Algorithm {
113113
}
114114

115115
impl Negotiator for Algorithm {
116-
fn known_common(&mut self, id: ObjectId, graph: &mut crate::Graph<'_>) -> Result<(), Error> {
116+
fn known_common(&mut self, id: ObjectId, graph: &mut crate::Graph<'_, '_>) -> Result<(), Error> {
117117
if graph
118118
.get(&id)
119119
.map_or(false, |commit| commit.data.flags.contains(Flags::SEEN))
@@ -123,7 +123,7 @@ impl Negotiator for Algorithm {
123123
self.add_to_queue(id, Flags::ADVERTISED, graph)
124124
}
125125

126-
fn add_tip(&mut self, id: ObjectId, graph: &mut crate::Graph<'_>) -> Result<(), Error> {
126+
fn add_tip(&mut self, id: ObjectId, graph: &mut crate::Graph<'_, '_>) -> Result<(), Error> {
127127
if graph
128128
.get(&id)
129129
.map_or(false, |commit| commit.data.flags.contains(Flags::SEEN))
@@ -133,7 +133,7 @@ impl Negotiator for Algorithm {
133133
self.add_to_queue(id, Flags::default(), graph)
134134
}
135135

136-
fn next_have(&mut self, graph: &mut crate::Graph<'_>) -> Option<Result<ObjectId, Error>> {
136+
fn next_have(&mut self, graph: &mut crate::Graph<'_, '_>) -> Option<Result<ObjectId, Error>> {
137137
loop {
138138
let id = self.revs.pop_value().filter(|_| self.non_common_revs != 0)?;
139139
let commit = graph.get_mut(&id).expect("it was added to the graph by now");
@@ -166,7 +166,7 @@ impl Negotiator for Algorithm {
166166
}
167167
}
168168

169-
fn in_common_with_remote(&mut self, id: ObjectId, graph: &mut crate::Graph<'_>) -> Result<bool, Error> {
169+
fn in_common_with_remote(&mut self, id: ObjectId, graph: &mut crate::Graph<'_, '_>) -> Result<bool, Error> {
170170
let mut was_seen = false;
171171
let known_to_be_common = graph.get(&id).map_or(false, |commit| {
172172
was_seen = commit.data.flags.contains(Flags::SEEN);

gix-negotiate/tests/baseline/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn run() -> crate::Result {
5757
let cache = use_cache
5858
.then(|| gix_commitgraph::at(store.store_ref().path().join("info")).ok())
5959
.flatten();
60-
let mut graph = gix_revwalk::Graph::new(&store, cache);
60+
let mut graph = gix_revwalk::Graph::new(&store, cache.as_ref());
6161
let mut negotiator = algo.into_negotiator();
6262
if debug {
6363
eprintln!("ALGO {algo_name} CASE {case}");

gix-revision/src/describe.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub(crate) mod function {
160160
/// candidate by setting `fallback_to_oid` to true.
161161
pub fn describe<'name>(
162162
commit: &oid,
163-
graph: &mut Graph<'_, Flags>,
163+
graph: &mut Graph<'_, '_, Flags>,
164164
Options {
165165
name_by_oid,
166166
mut max_candidates,
@@ -304,7 +304,7 @@ pub(crate) mod function {
304304
}
305305

306306
fn parents_by_date_onto_queue_and_track_names(
307-
graph: &mut Graph<'_, Flags>,
307+
graph: &mut Graph<'_, '_, Flags>,
308308
queue: &mut PriorityQueue<CommitTime, gix_hash::ObjectId>,
309309
commit: gix_hash::ObjectId,
310310
commit_flags: Flags,
@@ -326,7 +326,7 @@ pub(crate) mod function {
326326

327327
fn finish_depth_computation(
328328
mut queue: PriorityQueue<CommitTime, gix_hash::ObjectId>,
329-
graph: &mut Graph<'_, Flags>,
329+
graph: &mut Graph<'_, '_, Flags>,
330330
best_candidate: &mut Candidate<'_>,
331331
first_parent: bool,
332332
) -> Result<u32, Error> {

gix-revision/src/merge_base.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub(crate) mod function {
4242
pub fn merge_base(
4343
first: ObjectId,
4444
others: &[ObjectId],
45-
graph: &mut Graph<'_, Flags>,
45+
graph: &mut Graph<'_, '_, Flags>,
4646
) -> Result<Option<Vec<ObjectId>>, Error> {
4747
let _span = gix_trace::coarse!("gix_revision::merge_base()", ?first, ?others,);
4848
if others.is_empty() || others.contains(&first) {
@@ -60,7 +60,7 @@ pub(crate) mod function {
6060
/// That way, we return only the topologically most recent commits in `commits`.
6161
fn remove_redundant(
6262
commits: &[(ObjectId, GenThenTime)],
63-
graph: &mut Graph<'_, Flags>,
63+
graph: &mut Graph<'_, '_, Flags>,
6464
) -> Result<Vec<ObjectId>, Error> {
6565
if commits.is_empty() {
6666
return Ok(Vec::new());
@@ -151,7 +151,7 @@ pub(crate) mod function {
151151
fn paint_down_to_common(
152152
first: ObjectId,
153153
others: &[ObjectId],
154-
graph: &mut Graph<'_, Flags>,
154+
graph: &mut Graph<'_, '_, Flags>,
155155
) -> Result<Vec<(ObjectId, GenThenTime)>, Error> {
156156
let mut queue = PriorityQueue::<GenThenTime, ObjectId>::new();
157157
graph.insert_data(first, |commit| -> Result<_, Error> {
@@ -213,10 +213,10 @@ pub(crate) mod function {
213213
time: gix_date::SecondsSinceUnixEpoch,
214214
}
215215

216-
impl TryFrom<gix_revwalk::graph::LazyCommit<'_>> for GenThenTime {
216+
impl TryFrom<gix_revwalk::graph::LazyCommit<'_, '_>> for GenThenTime {
217217
type Error = gix_object::decode::Error;
218218

219-
fn try_from(commit: LazyCommit<'_>) -> Result<Self, Self::Error> {
219+
fn try_from(commit: LazyCommit<'_, '_>) -> Result<Self, Self::Error> {
220220
Ok(GenThenTime {
221221
generation: commit
222222
.generation()

gix-revision/tests/describe/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn run_test(
2222
let cache = use_commitgraph
2323
.then(|| gix_commitgraph::Graph::from_info_dir(&store.store_ref().path().join("info")).ok())
2424
.flatten();
25-
let mut graph = gix_revision::Graph::new(&store, cache);
25+
let mut graph = gix_revision::Graph::new(&store, cache.as_ref());
2626
run_assertions(
2727
gix_revision::describe(&commit_id, &mut graph, options(commit_id)),
2828
commit_id,

gix-revision/tests/merge_base/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ mod baseline {
1313
for baseline_path in expectation_paths(&root)? {
1414
count += 1;
1515
for use_commitgraph in [false, true] {
16+
let cache = use_commitgraph
17+
.then(|| gix_commitgraph::Graph::from_info_dir(&odb.store_ref().path().join("info")).unwrap());
1618
for expected in parse_expectations(&baseline_path)? {
17-
let cache = use_commitgraph
18-
.then(|| gix_commitgraph::Graph::from_info_dir(&odb.store_ref().path().join("info")).unwrap());
19-
let mut graph = gix_revision::Graph::new(&odb, cache);
19+
let mut graph = gix_revision::Graph::new(&odb, cache.as_ref());
2020

2121
let actual = merge_base(expected.first, &expected.others, &mut graph)?;
2222
assert_eq!(

gix-revwalk/src/graph/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl<'find, 'cache, T> Graph<'find, 'cache, T> {
207207
pub fn new(objects: impl gix_object::Find + 'find, cache: Option<&'cache gix_commitgraph::Graph>) -> Self {
208208
Graph {
209209
find: Box::new(objects),
210-
cache: cache.into(),
210+
cache,
211211
map: gix_hashtable::HashMap::default(),
212212
buf: Vec::new(),
213213
parent_buf: Vec::new(),

0 commit comments

Comments
 (0)