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)
| 3762 | /// Called after each commit is imported to enable O(1) incremental lookups. |
| 3763 | /// The `change_hash` is the Atomic Blake3 hash returned by write_import_*. |
| 3764 | pub fn index_git_sha(&self, git_sha: &str, change_hash: &Hash) -> Result<(), RepositoryError> { |
| 3765 | use atomic_core::pristine::GitShaIndexMutTxnT; |
| 3766 | |
| 3767 | let mut txn = self |
| 3768 | .pristine |
| 3769 | .write_txn() |
| 3770 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3771 | |
| 3772 | // Get the entity_id for this change hash |
| 3773 | let entity_id = txn |
| 3774 | .get_internal(change_hash) |
| 3775 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 3776 | .ok_or_else(|| { |
| 3777 | RepositoryError::Database(format!( |
| 3778 | "Change hash not found in INTERNAL: {}", |
| 3779 | change_hash.to_base32() |
| 3780 | )) |
| 3781 | })?; |
| 3782 | |
| 3783 | txn.put_git_sha(git_sha, entity_id) |
| 3784 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3785 | |
| 3786 | txn.commit() |
| 3787 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3788 | |
| 3789 | Ok(()) |
| 3790 | } |
| 3791 | |
| 3792 | /// Record missing Git SHA → Atomic change mappings in one transaction. |
| 3793 | /// |