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

Method rewrite

atomic-cli/src/commands/git/parallel.rs:9264–9307  ·  view source on GitHub ↗

Rewrite one delta into the shape Git itself reports for the collision; deltas not involved are returned untouched.

(&self, file: ParsedFile)

Source from the content-addressed store, hash-verified

9262 /// Rewrite one delta into the shape Git itself reports for the
9263 /// collision; deltas not involved are returned untouched.
9264 fn rewrite(&self, file: ParsedFile) -> ParsedFile {
9265 match file.operation {
9266 FileOperation::Renamed if self.onto_deleted.contains_key(&file.path) => ParsedFile {
9267 path: file.old_path.clone().unwrap_or_default(),
9268 operation: FileOperation::Deleted,
9269 new_content: None,
9270 old_content: file.old_content,
9271 diff_lines: None,
9272 old_path: None,
9273 new_mode: None,
9274 },
9275 FileOperation::Renamed
9276 if file
9277 .old_path
9278 .as_ref()
9279 .is_some_and(|old_path| self.reoccupied.contains_key(old_path)) =>
9280 {
9281 ParsedFile {
9282 operation: FileOperation::Added,
9283 old_content: None,
9284 diff_lines: None,
9285 old_path: None,
9286 ..file
9287 }
9288 }
9289 FileOperation::Added if self.reoccupied.contains_key(&file.path) => ParsedFile {
9290 operation: FileOperation::Modified,
9291 old_content: self.reoccupied[&file.path].clone(),
9292 diff_lines: None,
9293 ..file
9294 },
9295 FileOperation::Deleted if self.onto_deleted.contains_key(&file.path) => {
9296 let (new_content, new_mode) = self.onto_deleted[&file.path].clone();
9297 ParsedFile {
9298 operation: FileOperation::Modified,
9299 new_content,
9300 new_mode,
9301 diff_lines: None,
9302 ..file
9303 }
9304 }
9305 _ => file,
9306 }
9307 }
9308}
9309
9310/// Resolve a rename that collides with another delta of the same commit.

Callers 1

Calls 3

contains_keyMethod · 0.80
as_refMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected