MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / unrecord

Method unrecord

atomic-repository/src/repository/history.rs:215–297  ·  view source on GitHub ↗

Unrecord a change from the current view. This removes the change from the view's change log without deleting the change itself. The change remains in the change store and graph, and can be re-applied later. This is similar to Gerrit's workflow where a patch can be removed from a change set, modified, and re-inserted. # Arguments `hash` - Hash of the change to unrecord `options` - Options contro

(
        &self,
        hash: &Hash,
        options: UnrecordOptions,
    )

Source from the content-addressed store, hash-verified

213 /// repo.reinsert_change(&hash, outcome.original_sequence)?;
214 /// ```
215 pub fn unrecord(
216 &self,
217 hash: &Hash,
218 options: UnrecordOptions,
219 ) -> Result<UnrecordOutcome, RepositoryError> {
220 // Get write transaction
221 let mut txn = self
222 .pristine
223 .write_txn()
224 .map_err(|e| RepositoryError::Database(e.to_string()))?;
225
226 // Determine which view to use
227 let view_name = options.view.as_deref().unwrap_or(&self.current_view);
228
229 // Get the view
230 let mut view = txn
231 .open_or_create_view(view_name)
232 .map_err(|e| RepositoryError::Database(e.to_string()))?;
233
234 // Get internal ID
235 let change_id = txn
236 .get_internal(hash)
237 .map_err(|e| RepositoryError::Database(e.to_string()))?
238 .ok_or_else(|| RepositoryError::ChangeNotFound {
239 hash: hash.to_base32(),
240 })?;
241
242 // Check if this is a dry run
243 if options.dry_run {
244 // Preview mode - just return what would happen
245 let preview = crate::unrecord::preview_unrecord(&txn, &view, &[*hash], &options)
246 .map_err(|e| RepositoryError::Unrecord(e.to_string()))?;
247 return Ok(preview);
248 }
249
250 // Remove the change from the view
251 let original_seq = txn
252 .del_change(&mut view, change_id, hash)
253 .map_err(|e| RepositoryError::Database(e.to_string()))?;
254
255 if original_seq.is_none() {
256 return Err(RepositoryError::Unrecord(format!(
257 "Change {} is not in view '{}'",
258 hash.to_base32(),
259 view_name
260 )));
261 }
262
263 // Update the view
264 txn.update_view(&view)
265 .map_err(|e| RepositoryError::Database(e.to_string()))?;
266
267 // Commit the transaction
268 txn.commit()
269 .map_err(|e| RepositoryError::Database(e.to_string()))?;
270
271 // ── Post-unrecord: invalidate file index for affected paths ───
272 //

Callers 1

unrecord_lastMethod · 0.80

Calls 14

preview_unrecordFunction · 0.85
UnrecordClass · 0.85
write_txnMethod · 0.80
open_or_create_viewMethod · 0.80
del_changeMethod · 0.80
is_noneMethod · 0.80
update_viewMethod · 0.80
commitMethod · 0.80
get_internalMethod · 0.45
to_base32Method · 0.45
load_changeMethod · 0.45
hunksMethod · 0.45

Tested by

no test coverage detected