Rebuild ordered line vertex metadata for a tracked file from the current view's graph. Git import uses this as a conservative repair path when its in-memory line index is missing for a modified file.
(
&self,
path: &str,
)
| 552 | /// current view's graph. Git import uses this as a conservative repair |
| 553 | /// path when its in-memory line index is missing for a modified file. |
| 554 | pub fn import_line_index_seed( |
| 555 | &self, |
| 556 | path: &str, |
| 557 | ) -> Result<Option<ImportLineIndexSeed>, RepositoryError> { |
| 558 | let normalized = path.replace('\\', "/"); |
| 559 | let txn = self |
| 560 | .pristine |
| 561 | .read_txn() |
| 562 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 563 | |
| 564 | let view = txn |
| 565 | .get_view(&self.current_view) |
| 566 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 567 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 568 | name: self.current_view.clone(), |
| 569 | })?; |
| 570 | let visible = collect_visible_change_ids_with_deps(&txn, &view)?; |
| 571 | |
| 572 | let Some(inode) = txn |
| 573 | .get_inode(&normalized) |
| 574 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 575 | else { |
| 576 | return Ok(None); |
| 577 | }; |
| 578 | let Some(position) = txn |
| 579 | .inode_position(inode) |
| 580 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 581 | else { |
| 582 | return Ok(None); |
| 583 | }; |
| 584 | if !import_seed_node_visible(position.inode_node(), &visible) { |
| 585 | return Ok(None); |
| 586 | } |
| 587 | let Some(inode_change) = txn |
| 588 | .get_external(position.change) |
| 589 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 590 | else { |
| 591 | return Ok(None); |
| 592 | }; |
| 593 | |
| 594 | let mut current = position.inode_node(); |
| 595 | let mut visited = HashSet::new(); |
| 596 | let mut lines = Vec::new(); |
| 597 | |
| 598 | loop { |
| 599 | if !visited.insert(current) { |
| 600 | return Ok(None); |
| 601 | } |
| 602 | |
| 603 | let mut adj = txn |
| 604 | .init_inode_adj( |
| 605 | inode, |
| 606 | current, |
| 607 | EdgeFlags::BLOCK, |
| 608 | EdgeFlags::BLOCK | EdgeFlags::FOLDER, |
| 609 | ) |
| 610 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 611 |