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

Method remove

atomic-repository/src/repository/tracking.rs:559–635  ·  view source on GitHub ↗

Remove a file or directory from tracking. Only a **staged** path — one `add` tracked but `record` never recorded — is untracked here, by deleting the `TREE`/`REV_TREE` rows `add` created. Nothing is deleted from disk; that is the caller's decision. A **recorded** path cannot be untracked this way. Its name is durable in `PATH_CLAIMS` and its `INODES`/`REV_INODES` binding is derived from the chan

(
        &self,
        working_copy: WorkingCopyId,
        path: P,
        options: TrackingOptions,
    )

Source from the content-addressed store, hash-verified

557 /// assert!(stats.has_pending_deletions());
558 /// ```
559 pub fn remove<P: AsRef<Path>>(
560 &self,
561 working_copy: WorkingCopyId,
562 path: P,
563 options: TrackingOptions,
564 ) -> Result<TrackingStats, RepositoryError> {
565 self.validate_working_copy(working_copy)?;
566 let path = path.as_ref();
567 let mut stats = TrackingStats::new();
568 if options.dry_run {
569 let txn = self
570 .pristine
571 .read_txn()
572 .map_err(|e| RepositoryError::Database(e.to_string()))?;
573 // Preview reports the same split the mutation applies, so a dry run
574 // never promises an untrack that the recorder owns.
575 for (file_path, _inode, state) in removal_candidates(&txn, path, &options)? {
576 match state {
577 TrackedPathState::Staged => stats.files_removed += 1,
578 TrackedPathState::Recorded => {
579 if options.keep_recorded {
580 stats.pending_untracks.push(PathBuf::from(file_path));
581 } else {
582 stats.defer_deletion(PathBuf::from(file_path));
583 }
584 }
585 }
586 }
587 return Ok(stats);
588 }
589 let mut txn = self
590 .pristine
591 .write_txn()
592 .map_err(|e| RepositoryError::Database(e.to_string()))?;
593 let to_remove = removal_candidates(&txn, path, &options)?;
594 // Resolve the marked view once, and only when this request will mark
595 // something: `--keep` stages the untrack as per-view intent.
596 let mark_view = if options.keep_recorded
597 && to_remove
598 .iter()
599 .any(|(_, _, state)| matches!(state, TrackedPathState::Recorded))
600 {
601 Some(
602 txn.get_view(&self.current_view)
603 .map_err(|e| RepositoryError::Database(e.to_string()))?
604 .ok_or_else(|| RepositoryError::ViewNotFound {
605 name: self.current_view.clone(),
606 })?
607 .id,
608 )
609 } else {
610 None
611 };
612
613 for (file_path, _inode, state) in to_remove {
614 match state {
615 TrackedPathState::Staged => {
616 untrack_staged_path(&mut txn, &file_path)

Callers

nothing calls this directly

Calls 13

removal_candidatesFunction · 0.85
untrack_staged_pathFunction · 0.85
mark_pending_untrackFunction · 0.85
validate_working_copyMethod · 0.80
as_refMethod · 0.80
read_txnMethod · 0.80
defer_deletionMethod · 0.80
write_txnMethod · 0.80
pushMethod · 0.45
iterMethod · 0.45
get_viewMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected