rust/hg-core/src/ancestors.rs
changeset 41133 55dc1da8df2f
parent 41132 486908e691be
child 41134 a1b3800c8a19
equal deleted inserted replaced
41132:486908e691be 41133:55dc1da8df2f
   343             // thisvisit and othervisit, we'll differentiate with a boolean
   343             // thisvisit and othervisit, we'll differentiate with a boolean
   344             let this_visit_is_revs;
   344             let this_visit_is_revs;
   345             if revs_visit.remove(&curr) {
   345             if revs_visit.remove(&curr) {
   346                 missing.push(curr);
   346                 missing.push(curr);
   347                 this_visit_is_revs = true;
   347                 this_visit_is_revs = true;
   348             } else if bases_visit.contains(&curr) {
       
   349                 this_visit_is_revs = false;
       
   350             } else {
       
   351                 // not an ancestor of revs or bases: ignore
       
   352                 continue;
       
   353             }
       
   354 
       
   355             {
       
   356                 for p in self.graph.parents(curr)?.iter().cloned() {
   348                 for p in self.graph.parents(curr)?.iter().cloned() {
   357                     if p == NULL_REVISION {
   349                     if p == NULL_REVISION {
   358                         continue;
   350                         continue;
   359                     }
   351                     }
   360                     let in_other_visit = if this_visit_is_revs {
   352                     let in_other_visit = if this_visit_is_revs {
   376                         } else {
   368                         } else {
   377                             bases_visit.insert(p);
   369                             bases_visit.insert(p);
   378                         }
   370                         }
   379                     }
   371                     }
   380                 }
   372                 }
       
   373             } else if bases_visit.contains(&curr) {
       
   374                 this_visit_is_revs = false;
       
   375                 for p in self.graph.parents(curr)?.iter().cloned() {
       
   376                     if p == NULL_REVISION {
       
   377                         continue;
       
   378                     }
       
   379                     let in_other_visit = if this_visit_is_revs {
       
   380                         bases_visit.contains(&p)
       
   381                     } else {
       
   382                         revs_visit.contains(&p)
       
   383                     };
       
   384                     if in_other_visit || both_visit.contains(&p) {
       
   385                         // p is implicitely in this_visit.
       
   386                         // This means p is or should be in bothvisit
       
   387                         // TODO optim: hence if bothvisit, we look up twice
       
   388                         revs_visit.remove(&p);
       
   389                         bases_visit.insert(p);
       
   390                         both_visit.insert(p);
       
   391                     } else {
       
   392                         // visit later
       
   393                         if this_visit_is_revs {
       
   394                             revs_visit.insert(p);
       
   395                         } else {
       
   396                             bases_visit.insert(p);
       
   397                         }
       
   398                     }
       
   399                 }
       
   400             } else {
       
   401                 // not an ancestor of revs or bases: ignore
   381             }
   402             }
   382         }
   403         }
   383         missing.reverse();
   404         missing.reverse();
   384         Ok(missing)
   405         Ok(missing)
   385     }
   406     }