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