comparison mercurial/revlog.py @ 14219:c33427080671

revlog: use real Booleans instead of 0/1 in nodesbetween
author Martin Geisler <mg@aragost.com>
date Fri, 06 May 2011 12:09:20 +0200
parents d62d597b8974
children 258fbccf22f5
comparison
equal deleted inserted replaced
14218:202ff575d49b 14219:c33427080671
504 return nonodes 504 return nonodes
505 ancestors = set() 505 ancestors = set()
506 # Turn heads into a dictionary so we can remove 'fake' heads. 506 # Turn heads into a dictionary so we can remove 'fake' heads.
507 # Also, later we will be using it to filter out the heads we can't 507 # Also, later we will be using it to filter out the heads we can't
508 # find from roots. 508 # find from roots.
509 heads = dict.fromkeys(heads, 0) 509 heads = dict.fromkeys(heads, False)
510 # Start at the top and keep marking parents until we're done. 510 # Start at the top and keep marking parents until we're done.
511 nodestotag = set(heads) 511 nodestotag = set(heads)
512 # Remember where the top was so we can use it as a limit later. 512 # Remember where the top was so we can use it as a limit later.
513 highestrev = max([self.rev(n) for n in nodestotag]) 513 highestrev = max([self.rev(n) for n in nodestotag])
514 while nodestotag: 514 while nodestotag:
594 orderedout.append(n) 594 orderedout.append(n)
595 if (ancestors is not None) and (n in heads): 595 if (ancestors is not None) and (n in heads):
596 # We're trying to figure out which heads are reachable 596 # We're trying to figure out which heads are reachable
597 # from roots. 597 # from roots.
598 # Mark this head as having been reached 598 # Mark this head as having been reached
599 heads[n] = 1 599 heads[n] = True
600 elif ancestors is None: 600 elif ancestors is None:
601 # Otherwise, we're trying to discover the heads. 601 # Otherwise, we're trying to discover the heads.
602 # Assume this is a head because if it isn't, the next step 602 # Assume this is a head because if it isn't, the next step
603 # will eventually remove it. 603 # will eventually remove it.
604 heads[n] = 1 604 heads[n] = True
605 # But, obviously its parents aren't. 605 # But, obviously its parents aren't.
606 for p in self.parents(n): 606 for p in self.parents(n):
607 heads.pop(p, None) 607 heads.pop(p, None)
608 heads = [n for n in heads.iterkeys() if heads[n] != 0] 608 heads = [n for n, flag in heads.iteritems() if flag]
609 roots = list(roots) 609 roots = list(roots)
610 assert orderedout 610 assert orderedout
611 assert roots 611 assert roots
612 assert heads 612 assert heads
613 return (orderedout, roots, heads) 613 return (orderedout, roots, heads)