1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use crate::graph::GitGraph;
use std::cmp::max;
pub mod colors;
pub mod format;
pub mod svg;
pub mod unicode;
fn get_deviate_index(graph: &GitGraph, index: usize, par_index: usize) -> usize {
let info = &graph.commits[index];
let par_info = &graph.commits[par_index];
let par_branch = &graph.all_branches[par_info.branch_trace.unwrap()];
let mut min_split_idx = index;
for sibling_oid in &par_info.children {
if let Some(&sibling_index) = graph.indices.get(sibling_oid) {
if let Some(sibling) = graph.commits.get(sibling_index) {
if let Some(sibling_trace) = sibling.branch_trace {
let sibling_branch = &graph.all_branches[sibling_trace];
if sibling_oid != &info.oid
&& sibling_branch.visual.column == par_branch.visual.column
&& sibling_index > min_split_idx
{
min_split_idx = sibling_index;
}
}
}
}
}
if info.is_merge {
max(index, min_split_idx)
} else {
(par_index as i32 - 1) as usize
}
}