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

Method update_from_added_change

atomic-cli/src/commands/git/parallel.rs:451–505  ·  view source on GitHub ↗
(&mut self, change_hash: ContentHash, change: &Change)

Source from the content-addressed store, hash-verified

449
450impl ImportLineIndex {
451 fn update_from_added_change(&mut self, change_hash: ContentHash, change: &Change) {
452 for graph_op in change.hunks() {
453 match graph_op {
454 GraphOp::FileAdd {
455 add_inode,
456 contents,
457 path,
458 ..
459 } => {
460 let inode_pos = Position {
461 change: Some(change_hash),
462 pos: add_inode.start,
463 };
464 let mut lines = Vec::new();
465 if let Some(contents) = contents {
466 lines.push(ImportLine {
467 change: change_hash,
468 start: contents.start,
469 end: contents.end,
470 incoming_by: change_hash,
471 content: change.contents
472 [contents.start.as_usize()..contents.end.as_usize()]
473 .to_vec(),
474 });
475 }
476 self.files.insert(
477 path.clone(),
478 ImportIndexedFile {
479 inode_pos,
480 lines,
481 imported_commits: 1,
482 },
483 );
484 }
485 GraphOp::Edit {
486 change: Atom::Insertion(insertion),
487 local,
488 ..
489 } => {
490 if let Some(indexed) = self.files.get_mut(&local.path) {
491 indexed.lines.push(ImportLine {
492 change: change_hash,
493 start: insertion.start,
494 end: insertion.end,
495 incoming_by: change_hash,
496 content: change.contents
497 [insertion.start.as_usize()..insertion.end.as_usize()]
498 .to_vec(),
499 });
500 }
501 }
502 _ => {}
503 }
504 }
505 }
506
507 fn seed_missing_modified_files(&mut self, repo: &Repository, parsed: &ParsedCommit) {
508 for file in &parsed.files {

Callers

nothing calls this directly

Calls 6

as_usizeMethod · 0.80
get_mutMethod · 0.80
hunksMethod · 0.45
pushMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected