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,
)
| 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 | /// |
no test coverage detected