cob: Return correct clock value for multi-ops
We weren't accounting for batches ops in an entry. This change should account for it by adding N-1 to the clock value of an entry, where N is the number of entries. Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
parent
bdbf111163
commit
335fcbca89
|
|
@ -9,6 +9,7 @@ use git_ext::Oid;
|
||||||
use petgraph::{visit::EdgeRef, EdgeDirection};
|
use petgraph::{visit::EdgeRef, EdgeDirection};
|
||||||
|
|
||||||
use crate::history::entry::{EntryId, EntryWithClock};
|
use crate::history::entry::{EntryId, EntryWithClock};
|
||||||
|
use crate::history::Clock;
|
||||||
use crate::{change::Change, history, pruning_fold};
|
use crate::{change::Change, history, pruning_fold};
|
||||||
|
|
||||||
/// # Panics
|
/// # Panics
|
||||||
|
|
@ -39,7 +40,12 @@ pub fn evaluate<'b>(
|
||||||
let incoming = graph.edges_directed(c.idx, EdgeDirection::Incoming);
|
let incoming = graph.edges_directed(c.idx, EdgeDirection::Incoming);
|
||||||
let clock = incoming
|
let clock = incoming
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|e| entries[&graph[e.source()].id.into()].clock())
|
.map(|e| {
|
||||||
|
let entry = &entries[&graph[e.source()].id.into()];
|
||||||
|
let clock = entry.clock();
|
||||||
|
|
||||||
|
clock + entry.contents().len() as Clock - 1
|
||||||
|
})
|
||||||
.max()
|
.max()
|
||||||
.map(|n| n + 1)
|
.map(|n| n + 1)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,10 @@ impl History {
|
||||||
pub fn clock(&self) -> Clock {
|
pub fn clock(&self) -> Clock {
|
||||||
self.graph
|
self.graph
|
||||||
.externals(petgraph::Direction::Outgoing)
|
.externals(petgraph::Direction::Outgoing)
|
||||||
.map(|n| self.graph[n].clock)
|
.map(|n| {
|
||||||
|
let node = &self.graph[n];
|
||||||
|
node.clock + node.entry.contents.len() as Clock - 1
|
||||||
|
})
|
||||||
.max()
|
.max()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue