| 493 | |
| 494 | impl ImportLineIndex { |
| 495 | fn update_from_added_change(&mut self, change_hash: ContentHash, change: &Change) { |
| 496 | for graph_op in change.hunks() { |
| 497 | match graph_op { |
| 498 | GraphOp::FileAdd { |
| 499 | add_inode, |
| 500 | contents, |
| 501 | path, |
| 502 | .. |
| 503 | } => { |
| 504 | let inode_pos = Position { |
| 505 | change: Some(change_hash), |
| 506 | pos: add_inode.start, |
| 507 | }; |
| 508 | let mut lines = Vec::new(); |
| 509 | if let Some(contents) = contents { |
| 510 | lines.push(ImportLine { |
| 511 | change: change_hash, |
| 512 | start: contents.start, |
| 513 | end: contents.end, |
| 514 | incoming_by: change_hash, |
| 515 | content: change.contents |
| 516 | [contents.start.as_usize()..contents.end.as_usize()] |
| 517 | .to_vec(), |
| 518 | }); |
| 519 | } |
| 520 | self.files.insert( |
| 521 | path.clone(), |
| 522 | ImportIndexedFile { |
| 523 | inode_pos, |
| 524 | lines, |
| 525 | imported_commits: 1, |
| 526 | }, |
| 527 | ); |
| 528 | } |
| 529 | GraphOp::Edit { |
| 530 | change: Atom::Insertion(insertion), |
| 531 | local, |
| 532 | .. |
| 533 | } => { |
| 534 | if let Some(indexed) = self.files.get_mut(&local.path) { |
| 535 | indexed.lines.push(ImportLine { |
| 536 | change: change_hash, |
| 537 | start: insertion.start, |
| 538 | end: insertion.end, |
| 539 | incoming_by: change_hash, |
| 540 | content: change.contents |
| 541 | [insertion.start.as_usize()..insertion.end.as_usize()] |
| 542 | .to_vec(), |
| 543 | }); |
| 544 | } |
| 545 | } |
| 546 | _ => {} |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | fn seed_missing_modified_files(&mut self, repo: &Repository, parsed: &ParsedCommit) { |
| 552 | for file in &parsed.files { |