rust/hg-core/src/copy_tracing.rs
changeset 46154 ecbb2fc9418c
parent 46153 0a721fc457bf
child 46155 fce2f20a54ce
equal deleted inserted replaced
46153:0a721fc457bf 46154:ecbb2fc9418c
   242             pairs: HashMap::default(),
   242             pairs: HashMap::default(),
   243         }
   243         }
   244     }
   244     }
   245 
   245 
   246     /// returns `true` if `anc` is an ancestors of `desc`, `false` otherwise
   246     /// returns `true` if `anc` is an ancestors of `desc`, `false` otherwise
   247     fn is_ancestor(&mut self, anc: Revision, desc: Revision) -> bool {
   247     fn is_overwrite(&mut self, anc: Revision, desc: Revision) -> bool {
   248         if anc > desc {
   248         if anc > desc {
   249             false
   249             false
   250         } else if anc == desc {
   250         } else if anc == desc {
   251             true
   251             true
   252         } else {
   252         } else {
   703     if src_major.path == src_minor.path {
   703     if src_major.path == src_minor.path {
   704         // we have the same value, but from other source;
   704         // we have the same value, but from other source;
   705         if src_major.rev == src_minor.rev {
   705         if src_major.rev == src_minor.rev {
   706             // If the two entry are identical, they are both valid
   706             // If the two entry are identical, they are both valid
   707             MergePick::Any
   707             MergePick::Any
   708         } else if oracle.is_ancestor(src_major.rev, src_minor.rev) {
   708         } else if oracle.is_overwrite(src_major.rev, src_minor.rev) {
   709             MergePick::Minor
   709             MergePick::Minor
   710         } else {
   710         } else {
   711             MergePick::Major
   711             MergePick::Major
   712         }
   712         }
   713     } else if src_major.rev == src_minor.rev {
   713     } else if src_major.rev == src_minor.rev {
   731         } else if action == MergeCase::Merged {
   731         } else if action == MergeCase::Merged {
   732             // If the file was actively merged, copy information
   732             // If the file was actively merged, copy information
   733             // from each side might conflict.  The major side will
   733             // from each side might conflict.  The major side will
   734             // win such conflict.
   734             // win such conflict.
   735             MergePick::Major
   735             MergePick::Major
   736         } else if oracle.is_ancestor(src_major.rev, src_minor.rev) {
   736         } else if oracle.is_overwrite(src_major.rev, src_minor.rev) {
   737             // If the minor side is strictly newer than the major
   737             // If the minor side is strictly newer than the major
   738             // side, it should be kept.
   738             // side, it should be kept.
   739             MergePick::Minor
   739             MergePick::Minor
   740         } else if src_major.path.is_some() {
   740         } else if src_major.path.is_some() {
   741             // without any special case, the "major" value win
   741             // without any special case, the "major" value win
   742             // other the "minor" one.
   742             // other the "minor" one.
   743             MergePick::Major
   743             MergePick::Major
   744         } else if oracle.is_ancestor(src_minor.rev, src_major.rev) {
   744         } else if oracle.is_overwrite(src_minor.rev, src_major.rev) {
   745             // the "major" rev is a direct ancestors of "minor",
   745             // the "major" rev is a direct ancestors of "minor",
   746             // any different value should
   746             // any different value should
   747             // overwrite
   747             // overwrite
   748             MergePick::Major
   748             MergePick::Major
   749         } else {
   749         } else {