##// 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 503 # create the right base
504 504 # XXX: nodesbetween / changegroup* should be "fixed" instead
505 505 o = []
506 has = {nullid: None}
506 has = set((nullid,))
507 507 for n in base:
508 508 has.update(repo.changelog.reachable(n))
509 509 if revs:
@@ -556,11 +556,10 b' class revlog(object):'
556 556 """
557 557
558 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 560 the node itself, stopping when stop is matched"""
561 reachable = {}
561 reachable = set((node,))
562 562 visit = [node]
563 reachable[node] = 1
564 563 if stop:
565 564 stopn = self.rev(stop)
566 565 else:
@@ -575,7 +574,7 b' class revlog(object):'
575 574 if self.rev(p) < stopn:
576 575 continue
577 576 if p not in reachable:
578 reachable[p] = 1
577 reachable.add(p)
579 578 visit.append(p)
580 579 return reachable
581 580
@@ -678,7 +677,7 b' class revlog(object):'
678 677 heads = list(heads)
679 678 if not heads:
680 679 return nonodes
681 ancestors = {}
680 ancestors = set()
682 681 # Turn heads into a dictionary so we can remove 'fake' heads.
683 682 # Also, later we will be using it to filter out the heads we can't
684 683 # find from roots.
@@ -700,7 +699,7 b' class revlog(object):'
700 699 if n not in ancestors:
701 700 # If we are possibly a descendent of one of the roots
702 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 703 # Add non-nullid parents to list of nodes to tag.
705 704 nodestotag.update([p for p in self.parents(n) if
706 705 p != nullid])
@@ -813,18 +812,18 b' class revlog(object):'
813 812 stop = []
814 813 stoprevs = set([self.rev(n) for n in stop])
815 814 startrev = self.rev(start)
816 reachable = {startrev: 1}
817 heads = {startrev: 1}
815 reachable = set((startrev,))
816 heads = set((startrev,))
818 817
819 818 parentrevs = self.parentrevs
820 819 for r in xrange(startrev + 1, len(self)):
821 820 for p in parentrevs(r):
822 821 if p in reachable:
823 822 if r not in stoprevs:
824 reachable[r] = 1
825 heads[r] = 1
823 reachable.add(r)
824 heads.add(r)
826 825 if p in heads and p not in stoprevs:
827 del heads[p]
826 heads.remove(p)
828 827
829 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