##// END OF EJS Templates
util: subclass deque for Python 2.4 backwards compatibility...
Bryan O'Sullivan -
r16834:cafd8a8f default
parent child Browse files
Show More
@@ -11,7 +11,7 b''
11 11 import os, error
12 12 from i18n import _
13 13 from node import short, hex
14 import collections, util
14 import util
15 15
16 16 def bisect(changelog, state):
17 17 """find the next node (if any) for testing during a bisect search.
@@ -69,7 +69,7 b' def bisect(changelog, state):'
69 69
70 70 # build children dict
71 71 children = {}
72 visit = collections.deque([badrev])
72 visit = util.deque([badrev])
73 73 candidates = []
74 74 while visit:
75 75 rev = visit.popleft()
@@ -12,7 +12,7 b' import tempfile, zlib, shutil'
12 12 from i18n import _
13 13 from node import hex, nullid, short
14 14 import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error
15 import collections, context
15 import context
16 16
17 17 gitre = re.compile('diff --git a/(.*) b/(.*)')
18 18
@@ -1597,7 +1597,7 b' def diff(repo, node1=None, node2=None, m'
1597 1597
1598 1598 def lrugetfilectx():
1599 1599 cache = {}
1600 order = collections.deque()
1600 order = util.deque()
1601 1601 def getfilectx(f, ctx):
1602 1602 fctx = ctx.filectx(f, filelog=cache.get(f))
1603 1603 if f not in cache:
@@ -15,7 +15,7 b' and O(changes) merge between branches.'
15 15 from node import bin, hex, nullid, nullrev
16 16 from i18n import _
17 17 import ancestor, mdiff, parsers, error, util, dagutil
18 import struct, zlib, errno, collections
18 import struct, zlib, errno
19 19
20 20 _pack = struct.pack
21 21 _unpack = struct.unpack
@@ -362,7 +362,7 b' class revlog(object):'
362 362 """return the set of all nodes ancestral to a given node, including
363 363 the node itself, stopping when stop is matched"""
364 364 reachable = set((node,))
365 visit = collections.deque([node])
365 visit = util.deque([node])
366 366 if stop:
367 367 stopn = self.rev(stop)
368 368 else:
@@ -389,7 +389,7 b' class revlog(object):'
389 389 an ancestor of itself. Results are in breadth-first order:
390 390 parents of each rev in revs, then parents of those, etc. Result
391 391 does not include the null revision."""
392 visit = collections.deque(revs)
392 visit = util.deque(revs)
393 393 seen = set([nullrev])
394 394 while visit:
395 395 for parent in self.parentrevs(visit.popleft()):
@@ -447,7 +447,7 b' class revlog(object):'
447 447
448 448 # take all ancestors from heads that aren't in has
449 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 451 while visit:
452 452 r = visit.popleft()
453 453 if r in missing:
@@ -5,7 +5,7 b''
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 import re, collections
8 import re
9 9 import parser, util, error, discovery, hbisect, phases
10 10 import node
11 11 import bookmarks as bookmarksmod
@@ -17,7 +17,7 b' def _revancestors(repo, revs, followfirs'
17 17 """Like revlog.ancestors(), but supports followfirst."""
18 18 cut = followfirst and 1 or None
19 19 cl = repo.changelog
20 visit = collections.deque(revs)
20 visit = util.deque(revs)
21 21 seen = set([node.nullrev])
22 22 while visit:
23 23 for parent in cl.parentrevs(visit.popleft())[:cut]:
@@ -8,7 +8,7 b''
8 8
9 9 from node import nullid
10 10 from i18n import _
11 import random, collections, util, dagutil
11 import random, util, dagutil
12 12 import phases
13 13
14 14 def _updatesample(dag, nodes, sample, always, quicksamplesize=0):
@@ -18,7 +18,7 b' def _updatesample(dag, nodes, sample, al'
18 18 else:
19 19 heads = dag.heads()
20 20 dist = {}
21 visit = collections.deque(heads)
21 visit = util.deque(heads)
22 22 seen = set()
23 23 factor = 1
24 24 while visit:
@@ -7,7 +7,7 b''
7 7
8 8 from node import nullid, short
9 9 from i18n import _
10 import util, error, collections
10 import util, error
11 11
12 12 def findcommonincoming(repo, remote, heads=None, force=False):
13 13 """Return a tuple (common, fetch, heads) used to identify the common
@@ -56,7 +56,7 b' def findcommonincoming(repo, remote, hea'
56 56 # a 'branch' here is a linear segment of history, with four parts:
57 57 # head, root, first parent, second parent
58 58 # (a branch always has two parents (or none) by definition)
59 unknown = collections.deque(remote.branches(unknown))
59 unknown = util.deque(remote.branches(unknown))
60 60 while unknown:
61 61 r = []
62 62 while unknown:
@@ -202,10 +202,22 b' def cachefunc(func):'
202 202
203 203 return f
204 204
205 try:
206 collections.deque.remove
207 deque = collections.deque
208 except AttributeError:
209 # python 2.4 lacks deque.remove
210 class deque(collections.deque):
211 def remove(self, val):
212 for i, v in enumerate(self):
213 if v == val:
214 del self[i]
215 break
216
205 217 def lrucachefunc(func):
206 218 '''cache most recent results of function calls'''
207 219 cache = {}
208 order = collections.deque()
220 order = deque()
209 221 if func.func_code.co_argcount == 1:
210 222 def f(arg):
211 223 if arg not in cache:
@@ -865,7 +877,7 b' class chunkbuffer(object):'
865 877 Returns less than L bytes if the iterator runs dry."""
866 878 left = l
867 879 buf = ''
868 queue = collections.deque(self._queue)
880 queue = deque(self._queue)
869 881 while left > 0:
870 882 # refill the queue
871 883 if not queue:
General Comments 0
You need to be logged in to leave comments. Login now