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

Source from the content-addressed store, hash-verified

2461 }
2462
2463 fn seed_file_from_graph_content(
2464 &mut self,
2465 repo: &Repository,
2466 path: &str,
2467 content: &[u8],
2468 imported_commits_hint: usize,
2469 ) -> bool {
2470 let line_contents: Vec<Vec<u8>> =
2471 if Encoding::detect(content) == Encoding::Binary || is_generated_diff_skip_path(path) {
2472 if content.is_empty() {
2473 Vec::new()
2474 } else {
2475 vec![content.to_vec()]
2476 }
2477 } else {
2478 split_graph_first_lines(content)
2479 .into_iter()
2480 .map(|line| line.to_vec())
2481 .collect()
2482 };
2483
2484 let seed = match repo.import_line_index_seed(path) {
2485 Ok(Some(seed)) => seed,
2486 Ok(None) => return false,
2487 Err(err) => {
2488 trace_git_import(format!(
2489 "could not reseed line index for {} after fallback: {}",
2490 path, err
2491 ));
2492 return false;
2493 }
2494 };
2495
2496 if seed.lines.len() != line_contents.len() {
2497 trace_git_import(format!(
2498 "not reseeding line index for {} after fallback: graph lines={} content lines={}",
2499 path,
2500 seed.lines.len(),
2501 line_contents.len()
2502 ));
2503 return false;
2504 }
2505
2506 let mut imported_changes = HashSet::new();
2507 let lines = seed
2508 .lines
2509 .iter()
2510 .zip(line_contents)
2511 .enumerate()
2512 .map(|(index, (line, content))| {
2513 imported_changes.insert(line.incoming_by);
2514 ImportLine {
2515 change: line.change,
2516 start: line.start,
2517 end: line.end,
2518 incoming_by: line.incoming_by,
2519 incoming_from: if index == 0 {
2520 Position {

Callers 1

Calls 10

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

Tested by

no test coverage detected