comparison mercurial/revlog.py @ 16834:cafd8a8fb713

util: subclass deque for Python 2.4 backwards compatibility It turns out that Python 2.4's deque type is lacking a remove method. We can't implement remove in terms of find, because it doesn't have find either.
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 01 Jun 2012 17:05:31 -0700
parents 107a3270a24a
children 91f3ac205816 5e3a1b96dbb0
comparison
equal deleted inserted replaced
16833:7b460b49bf7b 16834:cafd8a8fb713
13 13
14 # import stuff from node for others to import from revlog 14 # import stuff from node for others to import from revlog
15 from node import bin, hex, nullid, nullrev 15 from node import bin, hex, nullid, nullrev
16 from i18n import _ 16 from i18n import _
17 import ancestor, mdiff, parsers, error, util, dagutil 17 import ancestor, mdiff, parsers, error, util, dagutil
18 import struct, zlib, errno, collections 18 import struct, zlib, errno
19 19
20 _pack = struct.pack 20 _pack = struct.pack
21 _unpack = struct.unpack 21 _unpack = struct.unpack
22 _compress = zlib.compress 22 _compress = zlib.compress
23 _decompress = zlib.decompress 23 _decompress = zlib.decompress
360 360
361 def reachable(self, node, stop=None): 361 def reachable(self, node, stop=None):
362 """return the set of all nodes ancestral to a given node, including 362 """return the set of all nodes ancestral to a given node, including
363 the node itself, stopping when stop is matched""" 363 the node itself, stopping when stop is matched"""
364 reachable = set((node,)) 364 reachable = set((node,))
365 visit = collections.deque([node]) 365 visit = util.deque([node])
366 if stop: 366 if stop:
367 stopn = self.rev(stop) 367 stopn = self.rev(stop)
368 else: 368 else:
369 stopn = 0 369 stopn = 0
370 while visit: 370 while visit:
387 Yield a sequence of revision numbers starting with the parents 387 Yield a sequence of revision numbers starting with the parents
388 of each revision in revs, i.e., each revision is *not* considered 388 of each revision in revs, i.e., each revision is *not* considered
389 an ancestor of itself. Results are in breadth-first order: 389 an ancestor of itself. Results are in breadth-first order:
390 parents of each rev in revs, then parents of those, etc. Result 390 parents of each rev in revs, then parents of those, etc. Result
391 does not include the null revision.""" 391 does not include the null revision."""
392 visit = collections.deque(revs) 392 visit = util.deque(revs)
393 seen = set([nullrev]) 393 seen = set([nullrev])
394 while visit: 394 while visit:
395 for parent in self.parentrevs(visit.popleft()): 395 for parent in self.parentrevs(visit.popleft()):
396 if parent not in seen: 396 if parent not in seen:
397 visit.append(parent) 397 visit.append(parent)
445 has.add(nullrev) 445 has.add(nullrev)
446 has.update(common) 446 has.update(common)
447 447
448 # take all ancestors from heads that aren't in has 448 # take all ancestors from heads that aren't in has
449 missing = set() 449 missing = set()
450 visit = collections.deque(r for r in heads if r not in has) 450 visit = util.deque(r for r in heads if r not in has)
451 while visit: 451 while visit:
452 r = visit.popleft() 452 r = visit.popleft()
453 if r in missing: 453 if r in missing:
454 continue 454 continue
455 else: 455 else: