(
&mut self,
repo: &Repository,
path: &str,
content: &[u8],
imported_commits_hint: usize,
)
| 575 | } |
| 576 | |
| 577 | fn seed_file_from_graph_content( |
| 578 | &mut self, |
| 579 | repo: &Repository, |
| 580 | path: &str, |
| 581 | content: &[u8], |
| 582 | imported_commits_hint: usize, |
| 583 | ) -> bool { |
| 584 | let line_contents: Vec<Vec<u8>> = |
| 585 | if Encoding::detect(content) == Encoding::Binary || is_generated_diff_skip_path(path) { |
| 586 | if content.is_empty() { |
| 587 | Vec::new() |
| 588 | } else { |
| 589 | vec![content.to_vec()] |
| 590 | } |
| 591 | } else { |
| 592 | split_graph_first_lines(content) |
| 593 | .into_iter() |
| 594 | .map(|line| line.to_vec()) |
| 595 | .collect() |
| 596 | }; |
| 597 | |
| 598 | let seed = match repo.import_line_index_seed(path) { |
| 599 | Ok(Some(seed)) => seed, |
| 600 | Ok(None) => return false, |
| 601 | Err(err) => { |
| 602 | trace_git_import(format!( |
| 603 | "could not reseed line index for {} after fallback: {}", |
| 604 | path, err |
| 605 | )); |
| 606 | return false; |
| 607 | } |
| 608 | }; |
| 609 | |
| 610 | if seed.lines.len() != line_contents.len() { |
| 611 | trace_git_import(format!( |
| 612 | "not reseeding line index for {} after fallback: graph lines={} content lines={}", |
| 613 | path, |
| 614 | seed.lines.len(), |
| 615 | line_contents.len() |
| 616 | )); |
| 617 | return false; |
| 618 | } |
| 619 | |
| 620 | let mut imported_changes = HashSet::new(); |
| 621 | let lines = seed |
| 622 | .lines |
| 623 | .iter() |
| 624 | .zip(line_contents) |
| 625 | .map(|(line, content)| { |
| 626 | imported_changes.insert(line.incoming_by); |
| 627 | ImportLine { |
| 628 | change: line.change, |
| 629 | start: line.start, |
| 630 | end: line.end, |
| 631 | incoming_by: line.incoming_by, |
| 632 | content, |
| 633 | } |
| 634 | }) |
no test coverage detected