##// END OF EJS Templates
copies-rust: encapsulate internal sets on `changes`...
marmoute -
r46589:23679379 default
parent child Browse files
Show More
@@ -49,6 +49,19 b" enum Action<'a> {"
49 49 Copied(&'a HgPath, &'a HgPath),
50 50 }
51 51
52 /// This express the possible "special" case we can get in a merge
53 ///
54 /// See mercurial/metadata.py for details on these values.
55 #[derive(PartialEq)]
56 enum MergeCase {
57 /// Merged: file had history on both side that needed to be merged
58 Merged,
59 /// Salvaged: file was candidate for deletion, but survived the merge
60 Salvaged,
61 /// Normal: Not one of the two cases above
62 Normal,
63 }
64
52 65 impl ChangedFiles {
53 66 pub fn new(
54 67 removed: HashSet<HgPathBuf>,
@@ -88,6 +101,17 b' impl ChangedFiles {'
88 101 let remove_iter = remove_iter.map(|x| Action::Removed(x));
89 102 copies_iter.chain(remove_iter)
90 103 }
104
105 /// return the MergeCase value associated with a filename
106 fn get_merge_case(&self, path: &HgPath) -> MergeCase {
107 if self.salvaged.contains(path) {
108 return MergeCase::Salvaged;
109 } else if self.merged.contains(path) {
110 return MergeCase::Merged;
111 } else {
112 return MergeCase::Normal;
113 }
114 }
91 115 }
92 116
93 117 /// A struct responsible for answering "is X ancestors of Y" quickly
@@ -322,20 +346,21 b' fn merge_copies_dict<A: Fn(Revision, Rev'
322 346 // same rev. So this is the same value.
323 347 unreachable!();
324 348 } else {
349 let action = changes.get_merge_case(&dest);
325 350 if src_major.path.is_none()
326 && changes.salvaged.contains(dest)
351 && action == MergeCase::Salvaged
327 352 {
328 353 // If the file is "deleted" in the major side but was
329 354 // salvaged by the merge, we keep the minor side alive
330 355 pick_minor();
331 356 } else if src_minor.path.is_none()
332 && changes.salvaged.contains(dest)
357 && action == MergeCase::Salvaged
333 358 {
334 359 // If the file is "deleted" in the minor side but was
335 360 // salvaged by the merge, unconditionnaly preserve the
336 361 // major side.
337 362 pick_major();
338 } else if changes.merged.contains(dest) {
363 } else if action == MergeCase::Merged {
339 364 // If the file was actively merged, copy information
340 365 // from each side might conflict. The major side will
341 366 // win such conflict.
General Comments 0
You need to be logged in to leave comments. Login now