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

Method unrecord_last

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

Unrecord the last change from the current view. This is a convenience method for unrecording the most recent change. # Arguments `options` - Options controlling the unrecord behavior # Returns An `UnrecordOutcome` with details about what was unrecorded. # Example ```rust,ignore // Undo the last change let outcome = repo.unrecord_last(UnrecordOptions::default())?; ```

(
        &self,
        options: UnrecordOptions,
    )

Source from the content-addressed store, hash-verified

394 /// let outcome = repo.unrecord_last(UnrecordOptions::default())?;
395 /// ```
396 pub fn unrecord_last(
397 &self,
398 options: UnrecordOptions,
399 ) -> Result<UnrecordOutcome, RepositoryError> {
400 // Get the last change hash
401 let txn = self
402 .pristine
403 .read_txn()
404 .map_err(|e| RepositoryError::Database(e.to_string()))?;
405
406 let view_name = options.view.as_deref().unwrap_or(&self.current_view);
407 let view = txn
408 .get_view(view_name)
409 .map_err(|e| RepositoryError::Database(e.to_string()))?
410 .ok_or_else(|| RepositoryError::ViewNotFound {
411 name: view_name.to_string(),
412 })?;
413
414 let last_hash = crate::unrecord::get_last_change(&txn, &view)
415 .map_err(|e| RepositoryError::Unrecord(e.to_string()))?
416 .ok_or_else(|| RepositoryError::Unrecord("View is empty".to_string()))?;
417
418 drop(txn);
419
420 self.unrecord(&last_hash, options)
421 }
422
423 /// Reinsert a previously unrecorded change at a specific position.
424 ///

Callers 2

runMethod · 0.80
execute_reviseMethod · 0.80

Calls 5

get_last_changeFunction · 0.85
UnrecordClass · 0.85
read_txnMethod · 0.80
unrecordMethod · 0.80
get_viewMethod · 0.45

Tested by

no test coverage detected