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

Function process_deleted_file

atomic-repository/src/parallel_record/worker.rs:195–231  ·  view source on GitHub ↗

Process a deleted file: create deletion hunks.

(
    input: &FileRecordInput,
    options: &RecordingOptions,
)

Source from the content-addressed store, hash-verified

193
194/// Process a deleted file: create deletion hunks.
195fn process_deleted_file(
196 input: &FileRecordInput,
197 options: &RecordingOptions,
198) -> Result<FileRecordOutput, String> {
199 let mut detected = DetectedFile::deleted(&input.path);
200 detected.inode = input.inode;
201 detected.position = input.position;
202
203 match record_deleted_file(&detected, options) {
204 Ok(recorded) => {
205 let crdt_stats = recorded.crdt_stats();
206 let file_stats = FileRecordStats {
207 hunks_created: recorded.hunk_count(),
208 edges_modified: 1,
209 lines_added: crdt_stats.map_or(0, |s| s.lines_added),
210 lines_deleted: crdt_stats.map_or(0, |s| s.lines_deleted),
211 lines_modified: crdt_stats.map_or(0, |s| s.lines_modified),
212 tokens_added: crdt_stats.map_or(0, |s| s.tokens_added),
213 tokens_deleted: crdt_stats.map_or(0, |s| s.tokens_deleted),
214 tokens_replaced: crdt_stats.map_or(0, |s| s.tokens_replaced),
215 ..FileRecordStats::default()
216 };
217
218 Ok(FileRecordOutput {
219 path: input.path.clone(),
220 kind: FileRecordKind::Deleted,
221 recorded: Some(recorded),
222 skipped: false,
223 stats: file_stats,
224 })
225 }
226 Err(e) => Err(format!(
227 "Failed to record deletion of {}: {}",
228 input.path, e
229 )),
230 }
231}
232
233/// Process an added directory.
234fn process_directory_added(input: &FileRecordInput) -> Result<FileRecordOutput, String> {

Callers 1

process_single_fileFunction · 0.85

Calls 5

deletedFunction · 0.85
record_deleted_fileFunction · 0.85
crdt_statsMethod · 0.80
hunk_countMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected