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:516–588  ·  view source on GitHub ↗
(
        &mut self,
        repo: &Repository,
        path: &str,
        content: &[u8],
        imported_commits_hint: usize,
    )

Source from the content-addressed store, hash-verified

514 }
515
516 fn seed_file_from_graph_content(
517 &mut self,
518 repo: &Repository,
519 path: &str,
520 content: &[u8],
521 imported_commits_hint: usize,
522 ) -> bool {
523 let line_contents: Vec<Vec<u8>> =
524 if Encoding::detect(content) == Encoding::Binary || is_generated_diff_skip_path(path) {
525 if content.is_empty() {
526 Vec::new()
527 } else {
528 vec![content.to_vec()]
529 }
530 } else {
531 split_graph_first_lines(content)
532 .into_iter()
533 .map(|line| line.to_vec())
534 .collect()
535 };
536
537 let seed = match repo.import_line_index_seed(path) {
538 Ok(Some(seed)) => seed,
539 Ok(None) => return false,
540 Err(err) => {
541 trace_git_import(format!(
542 "could not reseed line index for {} after fallback: {}",
543 path, err
544 ));
545 return false;
546 }
547 };
548
549 if seed.lines.len() != line_contents.len() {
550 trace_git_import(format!(
551 "not reseeding line index for {} after fallback: graph lines={} content lines={}",
552 path,
553 seed.lines.len(),
554 line_contents.len()
555 ));
556 return false;
557 }
558
559 let mut imported_changes = HashSet::new();
560 let lines = seed
561 .lines
562 .iter()
563 .zip(line_contents)
564 .map(|(line, content)| {
565 imported_changes.insert(line.incoming_by);
566 ImportLine {
567 change: line.change,
568 start: line.start,
569 end: line.end,
570 incoming_by: line.incoming_by,
571 content,
572 }
573 })

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