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

Method unrecord

atomic-repository/src/repository/history.rs:294–376  ·  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

292 /// repo.reinsert_change(&hash, outcome.original_sequence)?;
293 /// ```
294 pub fn unrecord(
295 &self,
296 hash: &Hash,
297 options: UnrecordOptions,
298 ) -> Result<UnrecordOutcome, RepositoryError> {
299 // Get write transaction
300 let mut txn = self
301 .pristine
302 .write_txn()
303 .map_err(|e| RepositoryError::Database(e.to_string()))?;
304
305 // Determine which view to use
306 let view_name = options.view.as_deref().unwrap_or(&self.current_view);
307
308 // Get the view
309 let mut view = txn
310 .open_or_create_view(view_name)
311 .map_err(|e| RepositoryError::Database(e.to_string()))?;
312
313 // Get internal ID
314 let change_id = txn
315 .get_internal(hash)
316 .map_err(|e| RepositoryError::Database(e.to_string()))?
317 .ok_or_else(|| RepositoryError::ChangeNotFound {
318 hash: hash.to_base32(),
319 })?;
320
321 // Check if this is a dry run
322 if options.dry_run {
323 // Preview mode - just return what would happen
324 let preview = crate::unrecord::preview_unrecord(&txn, &view, &[*hash], &options)
325 .map_err(|e| RepositoryError::Unrecord(e.to_string()))?;
326 return Ok(preview);
327 }
328
329 // Remove the change from the view
330 let original_seq = txn
331 .del_change(&mut view, change_id, hash)
332 .map_err(|e| RepositoryError::Database(e.to_string()))?;
333
334 if original_seq.is_none() {
335 return Err(RepositoryError::Unrecord(format!(
336 "Change {} is not in view '{}'",
337 hash.to_base32(),
338 view_name
339 )));
340 }
341
342 // Update the view
343 txn.update_view(&view)
344 .map_err(|e| RepositoryError::Database(e.to_string()))?;
345
346 // Commit the transaction
347 txn.commit()
348 .map_err(|e| RepositoryError::Database(e.to_string()))?;
349
350 // ── Post-unrecord: invalidate file index for affected paths ───
351 //

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