Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master

ObjectStoreGraphWalker.ack: use non-recursive implementation

We were recursively removing from self.heads; rewrite this such we try
removing heads this in a loop.

This gives a nice performance boost.

Changeset ec50052c65f6

Parent c7c54e8b4386

committed by Jelmer Vernooij

authored by Tay Ray Chuan

Changes to one file · Browse files at ec50052c65f6 Showing diff from parent c7c54e8b4386 Diff from another changeset...

 
706
707
708
709
710
711
712
713
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
714
715
716
 
706
707
708
 
 
 
 
 
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
@@ -706,11 +706,25 @@
    def ack(self, sha):   """Ack that a revision and its ancestors are present in the source.""" - if sha in self.heads: - self.heads.remove(sha) - if sha in self.parents: - for p in self.parents[sha]: - self.ack(p) + ancestors = set([sha]) + + # stop if we run out of heads to remove + while self.heads: + for a in ancestors: + if a in self.heads: + self.heads.remove(a) + + # collect all ancestors + new_ancestors = set() + for a in ancestors: + if a in self.parents: + new_ancestors.update(self.parents[a]) + + # no more ancestors; stop + if not new_ancestors: + break + + ancestors = new_ancestors     def next(self):   """Iterate over ancestors of heads in the target."""