Record a Git SHA → Atomic change mapping in the GIT_SHA_INDEX. Called after each commit is imported to enable O(1) incremental lookups. The `change_hash` is the Atomic Blake3 hash returned by write_import_*.
(&self, git_sha: &str, change_hash: &Hash)
| 3684 | /// Called after each commit is imported to enable O(1) incremental lookups. |
| 3685 | /// The `change_hash` is the Atomic Blake3 hash returned by write_import_*. |
| 3686 | pub fn index_git_sha(&self, git_sha: &str, change_hash: &Hash) -> Result<(), RepositoryError> { |
| 3687 | use atomic_core::pristine::GitShaIndexMutTxnT; |
| 3688 | |
| 3689 | let mut txn = self |
| 3690 | .pristine |
| 3691 | .write_txn() |
| 3692 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3693 | |
| 3694 | // Get the entity_id for this change hash |
| 3695 | let entity_id = txn |
| 3696 | .get_internal(change_hash) |
| 3697 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 3698 | .ok_or_else(|| { |
| 3699 | RepositoryError::Database(format!( |
| 3700 | "Change hash not found in INTERNAL: {}", |
| 3701 | change_hash.to_base32() |
| 3702 | )) |
| 3703 | })?; |
| 3704 | |
| 3705 | txn.put_git_sha(git_sha, entity_id) |
| 3706 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3707 | |
| 3708 | txn.commit() |
| 3709 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3710 | |
| 3711 | Ok(()) |
| 3712 | } |
| 3713 | |
| 3714 | /// Record missing Git SHA → Atomic change mappings in one transaction. |
| 3715 | /// |