##// END OF EJS Templates
revlog: use set instead of dict
Benoit Boissinot -
r8464:7af92e70 default
parent child Browse files
Show More
@@ -503,7 +503,7 b' def bundle(ui, repo, fname, dest=None, *'
503 # create the right base
503 # create the right base
504 # XXX: nodesbetween / changegroup* should be "fixed" instead
504 # XXX: nodesbetween / changegroup* should be "fixed" instead
505 o = []
505 o = []
506 has = {nullid: None}
506 has = set((nullid,))
507 for n in base:
507 for n in base:
508 has.update(repo.changelog.reachable(n))
508 has.update(repo.changelog.reachable(n))
509 if revs:
509 if revs:
@@ -556,11 +556,10 b' class revlog(object):'
556 """
556 """
557
557
558 def reachable(self, node, stop=None):
558 def reachable(self, node, stop=None):
559 """return a hash of all nodes ancestral to a given node, including
559 """return the set of all nodes ancestral to a given node, including
560 the node itself, stopping when stop is matched"""
560 the node itself, stopping when stop is matched"""
561 reachable = {}
561 reachable = set((node,))
562 visit = [node]
562 visit = [node]
563 reachable[node] = 1
564 if stop:
563 if stop:
565 stopn = self.rev(stop)
564 stopn = self.rev(stop)
566 else:
565 else:
@@ -575,7 +574,7 b' class revlog(object):'
575 if self.rev(p) < stopn:
574 if self.rev(p) < stopn:
576 continue
575 continue
577 if p not in reachable:
576 if p not in reachable:
578 reachable[p] = 1
577 reachable.add(p)
579 visit.append(p)
578 visit.append(p)
580 return reachable
579 return reachable
581
580
@@ -678,7 +677,7 b' class revlog(object):'
678 heads = list(heads)
677 heads = list(heads)
679 if not heads:
678 if not heads:
680 return nonodes
679 return nonodes
681 ancestors = {}
680 ancestors = set()
682 # Turn heads into a dictionary so we can remove 'fake' heads.
681 # Turn heads into a dictionary so we can remove 'fake' heads.
683 # Also, later we will be using it to filter out the heads we can't
682 # Also, later we will be using it to filter out the heads we can't
684 # find from roots.
683 # find from roots.
@@ -700,7 +699,7 b' class revlog(object):'
700 if n not in ancestors:
699 if n not in ancestors:
701 # If we are possibly a descendent of one of the roots
700 # If we are possibly a descendent of one of the roots
702 # and we haven't already been marked as an ancestor
701 # and we haven't already been marked as an ancestor
703 ancestors[n] = 1 # Mark as ancestor
702 ancestors.add(n) # Mark as ancestor
704 # Add non-nullid parents to list of nodes to tag.
703 # Add non-nullid parents to list of nodes to tag.
705 nodestotag.update([p for p in self.parents(n) if
704 nodestotag.update([p for p in self.parents(n) if
706 p != nullid])
705 p != nullid])
@@ -813,18 +812,18 b' class revlog(object):'
813 stop = []
812 stop = []
814 stoprevs = set([self.rev(n) for n in stop])
813 stoprevs = set([self.rev(n) for n in stop])
815 startrev = self.rev(start)
814 startrev = self.rev(start)
816 reachable = {startrev: 1}
815 reachable = set((startrev,))
817 heads = {startrev: 1}
816 heads = set((startrev,))
818
817
819 parentrevs = self.parentrevs
818 parentrevs = self.parentrevs
820 for r in xrange(startrev + 1, len(self)):
819 for r in xrange(startrev + 1, len(self)):
821 for p in parentrevs(r):
820 for p in parentrevs(r):
822 if p in reachable:
821 if p in reachable:
823 if r not in stoprevs:
822 if r not in stoprevs:
824 reachable[r] = 1
823 reachable.add(r)
825 heads[r] = 1
824 heads.add(r)
826 if p in heads and p not in stoprevs:
825 if p in heads and p not in stoprevs:
827 del heads[p]
826 heads.remove(p)
828
827
829 return [self.node(r) for r in heads]
828 return [self.node(r) for r in heads]
830
829
General Comments 0
You need to be logged in to leave comments. Login now