Show More
@@ -49,6 +49,19 b" enum Action<'a> {" | |||||
49 | Copied(&'a HgPath, &'a HgPath), |
|
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 | impl ChangedFiles { |
|
65 | impl ChangedFiles { | |
53 | pub fn new( |
|
66 | pub fn new( | |
54 | removed: HashSet<HgPathBuf>, |
|
67 | removed: HashSet<HgPathBuf>, | |
@@ -88,6 +101,17 b' impl ChangedFiles {' | |||||
88 | let remove_iter = remove_iter.map(|x| Action::Removed(x)); |
|
101 | let remove_iter = remove_iter.map(|x| Action::Removed(x)); | |
89 | copies_iter.chain(remove_iter) |
|
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 | /// A struct responsible for answering "is X ancestors of Y" quickly |
|
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 | // same rev. So this is the same value. |
|
346 | // same rev. So this is the same value. | |
323 | unreachable!(); |
|
347 | unreachable!(); | |
324 | } else { |
|
348 | } else { | |
|
349 | let action = changes.get_merge_case(&dest); | |||
325 | if src_major.path.is_none() |
|
350 | if src_major.path.is_none() | |
326 |
&& |
|
351 | && action == MergeCase::Salvaged | |
327 | { |
|
352 | { | |
328 | // If the file is "deleted" in the major side but was |
|
353 | // If the file is "deleted" in the major side but was | |
329 | // salvaged by the merge, we keep the minor side alive |
|
354 | // salvaged by the merge, we keep the minor side alive | |
330 | pick_minor(); |
|
355 | pick_minor(); | |
331 | } else if src_minor.path.is_none() |
|
356 | } else if src_minor.path.is_none() | |
332 |
&& |
|
357 | && action == MergeCase::Salvaged | |
333 | { |
|
358 | { | |
334 | // If the file is "deleted" in the minor side but was |
|
359 | // If the file is "deleted" in the minor side but was | |
335 | // salvaged by the merge, unconditionnaly preserve the |
|
360 | // salvaged by the merge, unconditionnaly preserve the | |
336 | // major side. |
|
361 | // major side. | |
337 | pick_major(); |
|
362 | pick_major(); | |
338 |
} else if |
|
363 | } else if action == MergeCase::Merged { | |
339 | // If the file was actively merged, copy information |
|
364 | // If the file was actively merged, copy information | |
340 | // from each side might conflict. The major side will |
|
365 | // from each side might conflict. The major side will | |
341 | // win such conflict. |
|
366 | // win such conflict. |
General Comments 0
You need to be logged in to leave comments.
Login now