|
1 | | -use super::AliasId; |
| 1 | +use super::{CommitAlias, UnwalkedAlias}; |
2 | 2 |
|
| 3 | +/// A lane's occupant at one point in the walk. |
3 | 4 | #[derive(Clone, Debug, PartialEq, Eq)] |
4 | | -pub enum Markers { |
5 | | - Uncommitted, |
6 | | - Commit, |
| 5 | +pub enum LaneSlot { |
| 6 | + /// A walked commit flowing down to its first parent. |
| 7 | + Flowing { |
| 8 | + alias: CommitAlias, |
| 9 | + parent: UnwalkedAlias, |
| 10 | + }, |
| 11 | + |
| 12 | + /// A flowing lane that still owes a bridge to a second parent |
| 13 | + FlowingMerge { |
| 14 | + alias: CommitAlias, |
| 15 | + parent: UnwalkedAlias, |
| 16 | + second: UnwalkedAlias, |
| 17 | + }, |
| 18 | + |
| 19 | + /// A root commit: draws its node, nothing continues below. |
| 20 | + Settled { alias: CommitAlias }, |
| 21 | + |
| 22 | + /// Reserved for a merge's second parent that hasn't been reached |
| 23 | + /// by the walk yet. Once that parent is processed, the |
| 24 | + /// reservation is replaced by the parent's own slot. |
| 25 | + Reserved { parent: UnwalkedAlias }, |
7 | 26 | } |
8 | 27 |
|
9 | | -#[derive(Clone, Debug, PartialEq, Eq)] |
10 | | -pub struct Chunk { |
11 | | - pub alias: Option<AliasId>, |
12 | | - pub parent_a: Option<AliasId>, |
13 | | - pub parent_b: Option<AliasId>, |
14 | | - pub marker: Markers, |
| 28 | +impl LaneSlot { |
| 29 | + /// The commit this lane currently belongs to, `None` for a |
| 30 | + /// reserved placeholder. |
| 31 | + pub const fn alias(&self) -> Option<CommitAlias> { |
| 32 | + match self { |
| 33 | + Self::Flowing { alias, .. } |
| 34 | + | Self::FlowingMerge { alias, .. } |
| 35 | + | Self::Settled { alias } => Some(*alias), |
| 36 | + Self::Reserved { .. } => None, |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + /// The parent whose placement this lane waits on; the lane stays |
| 41 | + /// open (drawing a vertical line) until that commit is walked. |
| 42 | + pub const fn awaits(&self) -> Option<CommitAlias> { |
| 43 | + match self { |
| 44 | + Self::Flowing { parent, .. } |
| 45 | + | Self::FlowingMerge { parent, .. } |
| 46 | + | Self::Reserved { parent } => Some(parent.get()), |
| 47 | + Self::Settled { .. } => None, |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + /// The pending second parent of a merge that hasn't been given |
| 52 | + /// its own lane. |
| 53 | + pub const fn second(&self) -> Option<CommitAlias> { |
| 54 | + match self { |
| 55 | + Self::FlowingMerge { second, .. } => Some(second.get()), |
| 56 | + Self::Flowing { .. } |
| 57 | + | Self::Settled { .. } |
| 58 | + | Self::Reserved { .. } => None, |
| 59 | + } |
| 60 | + } |
15 | 61 | } |
0 commit comments