(
&mut self,
target: &Hash,
message: &str,
author: Option<Author>,
paths: Option<&[String]>,
)
| 60 | } |
| 61 | |
| 62 | fn revise_stack( |
| 63 | &mut self, |
| 64 | target: &Hash, |
| 65 | message: &str, |
| 66 | author: Option<Author>, |
| 67 | paths: Option<&[String]>, |
| 68 | ) -> Result<ReviseOutcome, crate::RepositoryError> { |
| 69 | use crate::{InsertOptions, RepositoryError, UnrecordOptions}; |
| 70 | |
| 71 | let working_copy = self.require_working_copy_id()?; |
| 72 | // Use the existing workspace lock hierarchy for the complete surgery, |
| 73 | // including rollback. Nested domain operations reuse this outer lease. |
| 74 | let _lease = self.try_lock_workspace_operation(working_copy)?; |
| 75 | let view = self.desired_view_name(working_copy)?; |
| 76 | let history = self.get_view_changes(Some(&view))?; |
| 77 | let target_index = history |
| 78 | .iter() |
| 79 | .position(|(_, hash)| hash == target) |
| 80 | .ok_or_else(|| RepositoryError::ChangeNotFound { |
| 81 | hash: target.to_base32(), |
| 82 | })?; |
| 83 | let original = self.load_change(target)?; |
| 84 | // Reinsertion keeps the existing publication gate. Check the complete |
| 85 | // suffix before removing it, including the target needed on rollback. |
| 86 | if self.get_view_info(&view)?.scope == atomic_core::pristine::ViewScope::Shared { |
| 87 | let roots: Vec<_> = history[target_index..] |
| 88 | .iter() |
| 89 | .map(|(_, hash)| *hash) |
| 90 | .collect(); |
| 91 | let closure = super::provenance_gate::reachable_closure(self, &roots)?; |
| 92 | let provider = super::provenance_gate::local_session_mac_key_provider(self); |
| 93 | let did_provider = super::provenance_gate::local_did_key_provider(self); |
| 94 | self.enforce_publication_gate( |
| 95 | "revise reinsertion", |
| 96 | &closure, |
| 97 | Some(&provider), |
| 98 | Some(&did_provider), |
| 99 | )?; |
| 100 | } |
| 101 | |
| 102 | let mut header = original.hashed.header.clone(); |
| 103 | header.message = message.to_string(); |
| 104 | if let Some(author) = author { |
| 105 | header.authors = vec![author]; |
| 106 | } |
| 107 | let plan = replay::plan(self, &view, &history[target_index..], header, paths)?; |
| 108 | // Persist only fully verified immutable replacement objects before any |
| 109 | // source membership changes. Import through the normal graph API. |
| 110 | for hash in &plan.hashes { |
| 111 | if !self.has_change(hash) { |
| 112 | let change = plan.repo.load_change(hash)?; |
| 113 | let bytes = std::fs::read(plan.repo.change_store.change_path(hash))?; |
| 114 | self.save_change_bytes(hash, &bytes, &change)?; |
| 115 | } |
| 116 | } |
| 117 | if self.get_view_info(&view)?.scope == atomic_core::pristine::ViewScope::Shared { |
| 118 | let closure = super::provenance_gate::reachable_closure(self, &plan.hashes)?; |
| 119 | let provider = super::provenance_gate::local_session_mac_key_provider(self); |
no test coverage detected