pub fn overlaps_among(peers: &[Peer]) -> Vec<Overlap>Expand description
Every pair of claims that meet among an arbitrary set of peers, each pair once.
The listing side of the overlap question, and the only account of it: PeerBoard::overlaps
is this function over its own peers, and the repository-wide listing is this function
over the peers of every checkout’s board. They cannot drift into two answers, and a
collision between two worktrees is found by exactly the algorithm that found a
collision between two sessions of one — which is the whole point, because until the
board became repository-wide the second kind was the only kind anyone could see.
A pair is reported once, against the later peer of the two, naming the earlier one:
yours is the later peer’s path and theirs the earlier’s, and Overlap::peer
with Overlap::checkout says who and where the earlier one is. Peers are paired by
position, never by PeerId, because ids are unique to one board and a gathered list
holds a p1 per checkout.
use majordomus_cli::peers::{overlaps_among, PeerBoard, Transport};
let board = PeerBoard::new();
let a = board.attach(Transport::Stdio);
let b = board.attach(Transport::Http);
board.announce(&a, "the ordering rule", vec!["apps/majordomus-cli/src".into()]);
board.announce(&b, "the release model", vec!["apps/majordomus-cli/src/release".into()]);
let found = overlaps_among(&board.list());
assert_eq!(found.len(), 1);
assert_eq!(found[0].peer.as_str(), "p1", "reported against the later peer, naming the earlier");
assert_eq!(found[0].paths[0].yours, "apps/majordomus-cli/src/release");
assert_eq!(found[0].paths[0].theirs, "apps/majordomus-cli/src");
// and it is the same answer the board gives about itself
assert_eq!(board.overlaps(), found);