comparison rust/hg-core/src/copy_tracing.rs @ 45964:46a16b2c082d

copies-rust: pre-indent some code to clarify the next changeset The next changeset will massively rewrite the next function. However having a clear diff on the core semantic of the function will help making the next changesets clearer. So we do most of the churn beforehand. Differential Revision: https://phab.mercurial-scm.org/D9301
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 02 Nov 2020 19:25:26 +0100
parents 0d99778af68a
children cc759d3db1e8
comparison
equal deleted inserted replaced
45963:0d99778af68a 45964:46a16b2c082d
201 ) -> TimeStampedPathCopies { 201 ) -> TimeStampedPathCopies {
202 let mut result = minor.clone(); 202 let mut result = minor.clone();
203 for (dest, src_major) in major { 203 for (dest, src_major) in major {
204 let overwrite; 204 let overwrite;
205 if let Some(src_minor) = minor.get(&dest) { 205 if let Some(src_minor) = minor.get(&dest) {
206 if src_major.path == src_minor.path { 206 {
207 // we have the same value, but from other source; 207 if src_major.path == src_minor.path {
208 if src_major.rev == src_minor.rev { 208 // we have the same value, no need to battle;
209 // If the two entry are identical, no need to do anything 209 if src_major.rev == src_minor.rev {
210 overwrite = false; 210 // If the two entry are identical, no need to do
211 // anything
212 overwrite = false;
213 } else if is_ancestor(src_major.rev, src_minor.rev) {
214 overwrite = false;
215 } else {
216 overwrite = true;
217 }
218 } else if src_major.rev == src_minor.rev {
219 // We cannot get copy information for both p1 and p2 in the
220 // same rev. So this is the same value.
221 overwrite = false;
222 } else if src_major.path.is_none()
223 && changes.salvaged.contains(&dest)
224 {
225 // If the file is "deleted" in the major side but was
226 // salvaged by the merge, we keep the minor side alive
227 overwrite = false;
228 } else if src_minor.path.is_none()
229 && changes.salvaged.contains(&dest)
230 {
231 // If the file is "deleted" in the minor side but was
232 // salvaged by the merge, unconditionnaly preserve the
233 // major side.
234 overwrite = true;
235 } else if changes.merged.contains(&dest) {
236 // If the file was actively merged, copy information from
237 // each side might conflict. The major side will win such
238 // conflict.
239 overwrite = true;
211 } else if is_ancestor(src_major.rev, src_minor.rev) { 240 } else if is_ancestor(src_major.rev, src_minor.rev) {
212 overwrite = false; 241 // If the minor side is strictly newer than the major side,
242 // it should be kept.
243 overwrite = false;
244 } else if src_major.path.is_some() {
245 // without any special case, the "major" value win other
246 // the "minor" one.
247 overwrite = true;
248 } else if is_ancestor(src_minor.rev, src_major.rev) {
249 // the "major" rev is a direct ancestors of "minor", any
250 // different value should overwrite
251 overwrite = true;
213 } else { 252 } else {
214 overwrite = true; 253 // major version is None (so the file was deleted on that
215 } 254 // branch) and that branch is independant (neither minor
216 } else if src_major.rev == src_minor.rev { 255 // nor major is an ancestors of the other one.) We preserve
217 // We cannot get copy information for both p1 and p2 in the 256 // the new information about the new file.
218 // same rev. So this is the same value. 257 overwrite = false;
219 overwrite = false; 258 }
220 } else if src_major.path.is_none()
221 && changes.salvaged.contains(&dest)
222 {
223 // If the file is "deleted" in the major side but was salvaged
224 // by the merge, we keep the minor side alive
225 overwrite = false;
226 } else if src_minor.path.is_none()
227 && changes.salvaged.contains(&dest)
228 {
229 // If the file is "deleted" in the minor side but was salvaged
230 // by the merge, unconditionnaly preserve the major side.
231 overwrite = true;
232 } else if changes.merged.contains(&dest) {
233 // If the file was actively merged, copy information from each
234 // side might conflict. The major side will win such conflict.
235 overwrite = true;
236 } else if is_ancestor(src_major.rev, src_minor.rev) {
237 // If the minor side is strictly newer than the major side, it
238 // should be kept.
239 overwrite = false;
240 } else if src_major.path.is_some() {
241 // without any special case, the "major" value win other the
242 // "minor" one.
243 overwrite = true;
244 } else if is_ancestor(src_minor.rev, src_major.rev) {
245 // the "major" rev is a direct ancestors of "minor", any
246 // different value should overwrite
247 overwrite = true;
248 } else {
249 // major version is None (so the file was deleted on that
250 // branch) annd that branch is independant (neither minor nor
251 // major is an ancestors of the other one.) We preserve the new
252 // information about the new file.
253 overwrite = false;
254 } 259 }
255 } else { 260 } else {
256 // minor had no value 261 // minor had no value
257 overwrite = true; 262 overwrite = true;
258 } 263 }