Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 8153:616f20e1004a
revlog: let nodestotag be a set instead of a list
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Wed, 22 Apr 2009 20:51:20 +0200 |
parents | 08e1baf924ca |
children | 62d7287fe6b0 |
comparison
equal
deleted
inserted
replaced
8152:08e1baf924ca | 8153:616f20e1004a |
---|---|
676 # Turn heads into a dictionary so we can remove 'fake' heads. | 676 # Turn heads into a dictionary so we can remove 'fake' heads. |
677 # Also, later we will be using it to filter out the heads we can't | 677 # Also, later we will be using it to filter out the heads we can't |
678 # find from roots. | 678 # find from roots. |
679 heads = dict.fromkeys(heads, 0) | 679 heads = dict.fromkeys(heads, 0) |
680 # Start at the top and keep marking parents until we're done. | 680 # Start at the top and keep marking parents until we're done. |
681 nodestotag = heads.keys() | 681 nodestotag = set(heads.keys()) |
682 # Remember where the top was so we can use it as a limit later. | 682 # Remember where the top was so we can use it as a limit later. |
683 highestrev = max([self.rev(n) for n in nodestotag]) | 683 highestrev = max([self.rev(n) for n in nodestotag]) |
684 while nodestotag: | 684 while nodestotag: |
685 # grab a node to tag | 685 # grab a node to tag |
686 n = nodestotag.pop() | 686 n = nodestotag.pop() |
694 if n not in ancestors: | 694 if n not in ancestors: |
695 # If we are possibly a descendent of one of the roots | 695 # If we are possibly a descendent of one of the roots |
696 # and we haven't already been marked as an ancestor | 696 # and we haven't already been marked as an ancestor |
697 ancestors[n] = 1 # Mark as ancestor | 697 ancestors[n] = 1 # Mark as ancestor |
698 # Add non-nullid parents to list of nodes to tag. | 698 # Add non-nullid parents to list of nodes to tag. |
699 nodestotag.extend([p for p in self.parents(n) if | 699 nodestotag.update([p for p in self.parents(n) if |
700 p != nullid]) | 700 p != nullid]) |
701 elif n in heads: # We've seen it before, is it a fake head? | 701 elif n in heads: # We've seen it before, is it a fake head? |
702 # So it is, real heads should not be the ancestors of | 702 # So it is, real heads should not be the ancestors of |
703 # any other heads. | 703 # any other heads. |
704 heads.pop(n) | 704 heads.pop(n) |