Show More
@@ -360,46 +360,8 b' pub fn combine_changeset_copies<A: Fn(Re' | |||
|
360 | 360 | assert_eq!(rev, p2); |
|
361 | 361 | Parent::SecondParent |
|
362 | 362 | }; |
|
363 |
let |
|
|
364 | ||
|
365 | for action in changes.iter_actions(parent) { | |
|
366 | match action { | |
|
367 | Action::Copied(dest, source) => { | |
|
368 | let entry; | |
|
369 | if let Some(v) = copies.get(source) { | |
|
370 | entry = match &v.path { | |
|
371 | Some(path) => Some((*(path)).to_owned()), | |
|
372 | None => Some(source.to_owned()), | |
|
373 | } | |
|
374 | } else { | |
|
375 | entry = Some(source.to_owned()); | |
|
376 | } | |
|
377 | // Each new entry is introduced by the children, we | |
|
378 | // record this information as we will need it to take | |
|
379 | // the right decision when merging conflicting copy | |
|
380 | // information. See merge_copies_dict for details. | |
|
381 | let ttpc = TimeStampedPathCopy { | |
|
382 | rev: *child, | |
|
383 | path: entry, | |
|
384 | }; | |
|
385 | new_copies.insert(dest.to_owned(), ttpc); | |
|
386 | } | |
|
387 | Action::Removed(f) => { | |
|
388 | // We must drop copy information for removed file. | |
|
389 | // | |
|
390 | // We need to explicitly record them as dropped to | |
|
391 | // propagate this information when merging two | |
|
392 | // TimeStampedPathCopies object. | |
|
393 | if new_copies.contains_key(f.as_ref()) { | |
|
394 | let ttpc = TimeStampedPathCopy { | |
|
395 | rev: *child, | |
|
396 | path: None, | |
|
397 | }; | |
|
398 | new_copies.insert(f.to_owned(), ttpc); | |
|
399 | } | |
|
400 | } | |
|
401 | } | |
|
402 | } | |
|
363 | let new_copies = | |
|
364 | add_from_changes(&copies, &changes, parent, *child); | |
|
403 | 365 | |
|
404 | 366 | // Merge has two parents needs to combines their copy information. |
|
405 | 367 | // |
@@ -441,6 +403,56 b' pub fn combine_changeset_copies<A: Fn(Re' | |||
|
441 | 403 | result |
|
442 | 404 | } |
|
443 | 405 | |
|
406 | /// Combine ChangedFiles with some existing PathCopies information and return | |
|
407 | /// the result | |
|
408 | fn add_from_changes( | |
|
409 | base_copies: &TimeStampedPathCopies, | |
|
410 | changes: &ChangedFiles, | |
|
411 | parent: Parent, | |
|
412 | current_rev: Revision, | |
|
413 | ) -> TimeStampedPathCopies { | |
|
414 | let mut copies = base_copies.clone(); | |
|
415 | for action in changes.iter_actions(parent) { | |
|
416 | match action { | |
|
417 | Action::Copied(dest, source) => { | |
|
418 | let entry; | |
|
419 | if let Some(v) = base_copies.get(source) { | |
|
420 | entry = match &v.path { | |
|
421 | Some(path) => Some((*(path)).to_owned()), | |
|
422 | None => Some(source.to_owned()), | |
|
423 | } | |
|
424 | } else { | |
|
425 | entry = Some(source.to_owned()); | |
|
426 | } | |
|
427 | // Each new entry is introduced by the children, we | |
|
428 | // record this information as we will need it to take | |
|
429 | // the right decision when merging conflicting copy | |
|
430 | // information. See merge_copies_dict for details. | |
|
431 | let ttpc = TimeStampedPathCopy { | |
|
432 | rev: current_rev, | |
|
433 | path: entry, | |
|
434 | }; | |
|
435 | copies.insert(dest.to_owned(), ttpc); | |
|
436 | } | |
|
437 | Action::Removed(f) => { | |
|
438 | // We must drop copy information for removed file. | |
|
439 | // | |
|
440 | // We need to explicitly record them as dropped to | |
|
441 | // propagate this information when merging two | |
|
442 | // TimeStampedPathCopies object. | |
|
443 | if copies.contains_key(f.as_ref()) { | |
|
444 | let ttpc = TimeStampedPathCopy { | |
|
445 | rev: current_rev, | |
|
446 | path: None, | |
|
447 | }; | |
|
448 | copies.insert(f.to_owned(), ttpc); | |
|
449 | } | |
|
450 | } | |
|
451 | } | |
|
452 | } | |
|
453 | copies | |
|
454 | } | |
|
455 | ||
|
444 | 456 | /// merge two copies-mapping together, minor and major |
|
445 | 457 | /// |
|
446 | 458 | /// In case of conflict, value from "major" will be picked, unless in some |
General Comments 0
You need to be logged in to leave comments.
Login now