MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / seed_file_from_graph_content

Method seed_file_from_graph_content

atomic-cli/src/commands/git/parallel.rs:629–701  ·  view source on GitHub ↗
(
        &mut self,
        repo: &Repository,
        path: &str,
        content: &[u8],
        imported_commits_hint: usize,
    )

Source from the content-addressed store, hash-verified

627 }
628
629 fn seed_file_from_graph_content(
630 &mut self,
631 repo: &Repository,
632 path: &str,
633 content: &[u8],
634 imported_commits_hint: usize,
635 ) -> bool {
636 let line_contents: Vec<Vec<u8>> =
637 if Encoding::detect(content) == Encoding::Binary || is_generated_diff_skip_path(path) {
638 if content.is_empty() {
639 Vec::new()
640 } else {
641 vec![content.to_vec()]
642 }
643 } else {
644 split_graph_first_lines(content)
645 .into_iter()
646 .map(|line| line.to_vec())
647 .collect()
648 };
649
650 let seed = match repo.import_line_index_seed(path) {
651 Ok(Some(seed)) => seed,
652 Ok(None) => return false,
653 Err(err) => {
654 trace_git_import(format!(
655 "could not reseed line index for {} after fallback: {}",
656 path, err
657 ));
658 return false;
659 }
660 };
661
662 if seed.lines.len() != line_contents.len() {
663 trace_git_import(format!(
664 "not reseeding line index for {} after fallback: graph lines={} content lines={}",
665 path,
666 seed.lines.len(),
667 line_contents.len()
668 ));
669 return false;
670 }
671
672 let mut imported_changes = HashSet::new();
673 let lines = seed
674 .lines
675 .iter()
676 .zip(line_contents)
677 .map(|(line, content)| {
678 imported_changes.insert(line.incoming_by);
679 ImportLine {
680 change: line.change,
681 start: line.start,
682 end: line.end,
683 incoming_by: line.incoming_by,
684 content,
685 }
686 })

Callers 1

Calls 9

split_graph_first_linesFunction · 0.85
trace_git_importFunction · 0.85
is_emptyMethod · 0.45
into_iterMethod · 0.45
lenMethod · 0.45
iterMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected