| 380 | |
| 381 | impl ImportLineIndex { |
| 382 | fn update_from_added_change(&mut self, change_hash: ContentHash, change: &Change) { |
| 383 | for graph_op in change.hunks() { |
| 384 | match graph_op { |
| 385 | GraphOp::FileAdd { |
| 386 | add_inode, |
| 387 | contents, |
| 388 | path, |
| 389 | .. |
| 390 | } => { |
| 391 | let inode_pos = Position { |
| 392 | change: Some(change_hash), |
| 393 | pos: add_inode.start, |
| 394 | }; |
| 395 | let mut lines = Vec::new(); |
| 396 | if let Some(contents) = contents { |
| 397 | lines.push(ImportLine { |
| 398 | change: change_hash, |
| 399 | start: contents.start, |
| 400 | end: contents.end, |
| 401 | incoming_by: change_hash, |
| 402 | content: change.contents |
| 403 | [contents.start.as_usize()..contents.end.as_usize()] |
| 404 | .to_vec(), |
| 405 | }); |
| 406 | } |
| 407 | self.files.insert( |
| 408 | path.clone(), |
| 409 | ImportIndexedFile { |
| 410 | inode_pos, |
| 411 | lines, |
| 412 | imported_commits: 1, |
| 413 | }, |
| 414 | ); |
| 415 | } |
| 416 | GraphOp::Edit { |
| 417 | change: Atom::Insertion(insertion), |
| 418 | local, |
| 419 | .. |
| 420 | } => { |
| 421 | if let Some(indexed) = self.files.get_mut(&local.path) { |
| 422 | indexed.lines.push(ImportLine { |
| 423 | change: change_hash, |
| 424 | start: insertion.start, |
| 425 | end: insertion.end, |
| 426 | incoming_by: change_hash, |
| 427 | content: change.contents |
| 428 | [insertion.start.as_usize()..insertion.end.as_usize()] |
| 429 | .to_vec(), |
| 430 | }); |
| 431 | } |
| 432 | } |
| 433 | _ => {} |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | fn seed_missing_modified_files(&mut self, repo: &Repository, parsed: &ParsedCommit) { |
| 439 | for file in &parsed.files { |