|
1 | 1 | use super::buffer::Buffer; |
2 | 2 | use super::chunk::{Chunk, Markers}; |
3 | 3 | use super::oids::GraphOids; |
4 | | -use super::{ |
5 | | - to_lane_idx, ConnectionType, GraphRow, LaneIdx, MAX_LANE_COLORS, |
6 | | -}; |
| 4 | +use super::{AliasId, ConnectionType, GraphRow, LaneIndex, MAX_LANE_COLORS}; |
7 | 5 | use crate::sync::CommitId; |
8 | 6 | use std::collections::{HashMap, HashSet}; |
9 | 7 |
|
10 | 8 | /// Get the lanes color index, which cycles through the ste palette. |
11 | | -fn lane_color(lane: usize) -> LaneIdx { |
12 | | - to_lane_idx(lane % MAX_LANE_COLORS) |
| 9 | +fn lane_color(lane: usize) -> LaneIndex { |
| 10 | + LaneIndex::from(lane % MAX_LANE_COLORS) |
13 | 11 | } |
14 | 12 |
|
15 | 13 | use bitflags::bitflags; |
@@ -103,9 +101,9 @@ const fn dirs_conn(dirs: Dirs, dotted: bool) -> ConnectionType { |
103 | 101 | /// The line with a vertical component is the chosen way with color |
104 | 102 | /// ensuring lanes stay visually continuous |
105 | 103 | fn overlay_cell( |
106 | | - cell: &mut Option<(ConnectionType, LaneIdx)>, |
| 104 | + cell: &mut Option<(ConnectionType, LaneIndex)>, |
107 | 105 | add: Dirs, |
108 | | - color: LaneIdx, |
| 106 | + color: LaneIndex, |
109 | 107 | ) { |
110 | 108 | if let Some((conn, existing_color)) = cell { |
111 | 109 | if let Some(existing) = conn_dirs(*conn) { |
@@ -135,7 +133,7 @@ pub struct GraphWalker { |
135 | 133 | pub branch_lane_map: HashMap<CommitId, usize>, |
136 | 134 |
|
137 | 135 | /// Maps a merge commit's alias to the alias of its second parent. |
138 | | - pub merge_parents: HashMap<usize, usize>, |
| 136 | + pub merge_parents: HashMap<AliasId, AliasId>, |
139 | 137 | } |
140 | 138 |
|
141 | 139 | impl Default for GraphWalker { |
@@ -236,7 +234,7 @@ impl GraphWalker { |
236 | 234 | } |
237 | 235 |
|
238 | 236 | fn draw_merge_bridge( |
239 | | - lanes: &mut [Option<(ConnectionType, LaneIdx)>], |
| 237 | + lanes: &mut [Option<(ConnectionType, LaneIndex)>], |
240 | 238 | merge_bridge: Option<(usize, usize)>, |
241 | 239 | commit_lane: usize, |
242 | 240 | current: &[Option<Chunk>], |
@@ -287,15 +285,15 @@ impl GraphWalker { |
287 | 285 | } |
288 | 286 |
|
289 | 287 | fn draw_branching_lanes( |
290 | | - lanes: &mut Vec<Option<(ConnectionType, LaneIdx)>>, |
| 288 | + lanes: &mut Vec<Option<(ConnectionType, LaneIndex)>>, |
291 | 289 | branching_lanes: &[usize], |
292 | 290 | commit_lane: usize, |
293 | | - ) -> Vec<(LaneIdx, LaneIdx)> { |
| 291 | + ) -> Vec<(LaneIndex, LaneIndex)> { |
294 | 292 | let mut branches = Vec::new(); |
295 | 293 | for &branch_lane in branching_lanes { |
296 | 294 | let from = std::cmp::min(branch_lane, commit_lane); |
297 | 295 | let to = std::cmp::max(branch_lane, commit_lane); |
298 | | - branches.push((to_lane_idx(from), to_lane_idx(to))); |
| 296 | + branches.push((LaneIndex::from(from), LaneIndex::from(to))); |
299 | 297 |
|
300 | 298 | if lanes.len() <= to { |
301 | 299 | lanes.resize(to + 1, None); |
@@ -403,24 +401,24 @@ impl GraphWalker { |
403 | 401 | ); |
404 | 402 |
|
405 | 403 | GraphRow { |
406 | | - lane_count: to_lane_idx(current.iter().flatten().count()), |
407 | | - commit_lane: to_lane_idx(commit_lane), |
| 404 | + lane_count: LaneIndex::from(current.iter().flatten().count()), |
| 405 | + commit_lane: LaneIndex::from(commit_lane), |
408 | 406 | is_merge, |
409 | 407 | is_branch_tip, |
410 | 408 | is_stash, |
411 | 409 | lanes, |
412 | 410 | merge_bridge: merge_bridge |
413 | | - .map(|(f, t)| (to_lane_idx(f), to_lane_idx(t))), |
| 411 | + .map(|(f, t)| (LaneIndex::from(f), LaneIndex::from(t))), |
414 | 412 | branches, |
415 | 413 | } |
416 | 414 | } |
417 | 415 |
|
418 | 416 | #[allow(clippy::too_many_arguments)] |
419 | 417 | fn fill_lanes( |
420 | 418 | &self, |
421 | | - lanes: &mut [Option<(ConnectionType, LaneIdx)>], |
| 419 | + lanes: &mut [Option<(ConnectionType, LaneIndex)>], |
422 | 420 | curr: &[Option<Chunk>], |
423 | | - alias: Option<usize>, |
| 421 | + alias: Option<AliasId>, |
424 | 422 | head_id: Option<&CommitId>, |
425 | 423 | is_stash: bool, |
426 | 424 | is_merge: bool, |
@@ -473,10 +471,10 @@ impl GraphWalker { |
473 | 471 | /// between its two ends, merging with whatever each cell already |
474 | 472 | /// shows. |
475 | 473 | fn draw_bridge_span( |
476 | | - lanes: &mut [Option<(ConnectionType, LaneIdx)>], |
| 474 | + lanes: &mut [Option<(ConnectionType, LaneIndex)>], |
477 | 475 | from: usize, |
478 | 476 | to: usize, |
479 | | - color: LaneIdx, |
| 477 | + color: LaneIndex, |
480 | 478 | ) { |
481 | 479 | for lane in lanes.iter_mut().take(to).skip(from + 1) { |
482 | 480 | overlay_cell(lane, Dirs::LEFT | Dirs::RIGHT, color); |
|
0 commit comments