util: drop alias for collections.deque
authorMartin von Zweigbergk <martinvonz@google.com>
Sat, 16 May 2015 11:28:04 -0700
changeset 25175 0ca8410ea3455bcef5b9335ca6d9aa2de4adc2c9
parent 25174 3d14c1217117795e3b792369224ed7fa68e31123
child 25176 d1d69ca78883d05c6bb520c601e631123f002684
push id13
push usergszorc@mozilla.com
push dateTue, 26 May 2015 00:39:25 +0000
util: drop alias for collections.deque Now that util.deque is just an alias for collections.deque, let's just remove it.
hgext/shelve.py
mercurial/ancestor.py
mercurial/hbisect.py
mercurial/patch.py
mercurial/revlog.py
mercurial/setdiscovery.py
mercurial/treediscovery.py
mercurial/util.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -16,16 +16,17 @@ shelve". Changes can be restored even af
 parent, in which case Mercurial's merge machinery will resolve any
 conflicts if necessary.
 
 You can have more than one shelved change outstanding at a time; each
 shelved change has a distinct name. For details, see the help for "hg
 shelve".
 """
 
+import collections
 from mercurial.i18n import _
 from mercurial.node import nullid, nullrev, bin, hex
 from mercurial import changegroup, cmdutil, scmutil, phases, commands
 from mercurial import error, hg, mdiff, merge, patch, repair, util
 from mercurial import templatefilters, exchange, bundlerepo
 from mercurial import lock as lockmod
 from hgext import rebase
 import errno
@@ -138,17 +139,17 @@ class shelvedstate(object):
 def createcmd(ui, repo, pats, opts):
     """subcommand that creates a new shelve"""
 
     def publicancestors(ctx):
         """Compute the public ancestors of a commit.
 
         Much faster than the revset ancestors(ctx) & draft()"""
         seen = set([nullrev])
-        visit = util.deque()
+        visit = collections.deque()
         visit.append(ctx)
         while visit:
             ctx = visit.popleft()
             yield ctx.node()
             for parent in ctx.parents():
                 rev = parent.rev()
                 if rev not in seen:
                     seen.add(rev)
--- a/mercurial/ancestor.py
+++ b/mercurial/ancestor.py
@@ -1,17 +1,17 @@
 # ancestor.py - generic DAG ancestor algorithm for mercurial
 #
 # Copyright 2006 Matt Mackall <mpm@selenic.com>
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+import collections
 import heapq
-import util
 from node import nullrev
 
 def commonancestorsheads(pfunc, *nodes):
     """Returns a set with the heads of all common ancestors of all nodes,
     heads(::nodes[0] and ::nodes[1] and ...) .
 
     pfunc must return a list of parent vertices for a given vertex.
     """
@@ -309,17 +309,17 @@ class lazyancestors(object):
         revs = self._initrevs
         if self._inclusive:
             for rev in revs:
                 yield rev
             seen.update(revs)
 
         parentrevs = self._parentrevs
         stoprev = self._stoprev
-        visit = util.deque(revs)
+        visit = collections.deque(revs)
 
         while visit:
             for parent in parentrevs(visit.popleft()):
                 if parent >= stoprev and parent not in seen:
                     visit.append(parent)
                     seen.add(parent)
                     yield parent
 
--- a/mercurial/hbisect.py
+++ b/mercurial/hbisect.py
@@ -3,16 +3,17 @@
 # Copyright 2007 Matt Mackall
 # Copyright 2005, 2006 Benoit Boissinot <benoit.boissinot@ens-lyon.org>
 #
 # Inspired by git bisect, extension skeleton taken from mq.py.
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+import collections
 import os
 import error
 from i18n import _
 from node import short, hex
 import util
 
 def bisect(changelog, state):
     """find the next node (if any) for testing during a bisect search.
@@ -66,17 +67,17 @@ def bisect(changelog, state):
         if (len(state['bad']) == 1 and len(state['good']) == 1 and
             state['bad'] != state['good']):
             raise util.Abort(_("starting revisions are not directly related"))
         raise util.Abort(_("inconsistent state, %s:%s is good and bad")
                          % (badrev, short(bad)))
 
     # build children dict
     children = {}
-    visit = util.deque([badrev])
+    visit = collections.deque([badrev])
     candidates = []
     while visit:
         rev = visit.popleft()
         if ancestors[rev] == []:
             candidates.append(rev)
             for prev in clparents(rev):
                 if prev != -1:
                     if prev in children:
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1,16 +1,17 @@
 # patch.py - patch file parsing routines
 #
 # Copyright 2006 Brendan Cully <brendan@kublai.com>
 # Copyright 2007 Chris Mason <chris.mason@oracle.com>
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+import collections
 import cStringIO, email, os, errno, re, posixpath, copy
 import tempfile, zlib, shutil
 # On python2.4 you have to import these by name or they fail to
 # load. This was not a problem on Python 2.7.
 import email.Generator
 import email.Parser
 
 from i18n import _
@@ -2097,17 +2098,17 @@ def diff(repo, node1=None, node2=None, m
     if opts is None:
         opts = mdiff.defaultopts
 
     if not node1 and not node2:
         node1 = repo.dirstate.p1()
 
     def lrugetfilectx():
         cache = {}
-        order = util.deque()
+        order = collections.deque()
         def getfilectx(f, ctx):
             fctx = ctx.filectx(f, filelog=cache.get(f))
             if f not in cache:
                 if len(cache) > 20:
                     del cache[order.popleft()]
                 cache[f] = fctx.filelog()
             else:
                 order.remove(f)
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -7,16 +7,17 @@
 
 """Storage back-end for Mercurial.
 
 This provides efficient delta storage with O(1) retrieve and append
 and O(changes) merge between branches.
 """
 
 # import stuff from node for others to import from revlog
+import collections
 from node import bin, hex, nullid, nullrev
 from i18n import _
 import ancestor, mdiff, parsers, error, util, templatefilters
 import struct, zlib, errno
 
 _pack = struct.pack
 _unpack = struct.unpack
 _compress = zlib.compress
@@ -480,17 +481,17 @@ class revlog(object):
                 self.addedvalues.update(values)
 
         has = lazyset(self.ancestors(common))
         has.add(nullrev)
         has.update(common)
 
         # take all ancestors from heads that aren't in has
         missing = set()
-        visit = util.deque(r for r in heads if r not in has)
+        visit = collections.deque(r for r in heads if r not in has)
         while visit:
             r = visit.popleft()
             if r in missing:
                 continue
             else:
                 missing.add(r)
                 for p in self.parentrevs(r):
                     if p not in has:
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -35,16 +35,17 @@ sample of missing, start by sending all 
 repo is a subset, you computed the answer in one round trip.
 
 Then you can do something similar to the bisecting strategy used when
 finding faulty changesets. Instead of random samples, you can try picking
 nodes that will maximize the number of nodes that will be
 classified with it (since all ancestors or descendants will be marked as well).
 """
 
+import collections
 from node import nullid, nullrev
 from i18n import _
 import random
 import util, dagutil
 
 def _updatesample(dag, nodes, sample, quicksamplesize=0):
     """update an existing sample to match the expected size
 
@@ -60,17 +61,17 @@ def _updatesample(dag, nodes, sample, qu
     :sample: a sample to update
     :quicksamplesize: optional target size of the sample"""
     # if nodes is empty we scan the entire graph
     if nodes:
         heads = dag.headsetofconnecteds(nodes)
     else:
         heads = dag.heads()
     dist = {}
-    visit = util.deque(heads)
+    visit = collections.deque(heads)
     seen = set()
     factor = 1
     while visit:
         curr = visit.popleft()
         if curr in seen:
             continue
         d = dist.setdefault(curr, 1)
         if d > factor:
--- a/mercurial/treediscovery.py
+++ b/mercurial/treediscovery.py
@@ -1,15 +1,16 @@
 # discovery.py - protocol changeset discovery functions
 #
 # Copyright 2010 Matt Mackall <mpm@selenic.com>
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+import collections
 from node import nullid, short
 from i18n import _
 import util, error
 
 def findcommonincoming(repo, remote, heads=None, force=False):
     """Return a tuple (common, fetch, heads) used to identify the common
     subset of nodes between repo and remote.
 
@@ -51,17 +52,17 @@ def findcommonincoming(repo, remote, hea
 
     req = set(unknown)
     reqcnt = 0
 
     # search through remote branches
     # a 'branch' here is a linear segment of history, with four parts:
     # head, root, first parent, second parent
     # (a branch always has two parents (or none) by definition)
-    unknown = util.deque(remote.branches(unknown))
+    unknown = collections.deque(remote.branches(unknown))
     while unknown:
         r = []
         while unknown:
             n = unknown.popleft()
             if n[0] in seen:
                 continue
 
             repo.ui.debug("examining %s:%s\n"
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -329,18 +329,16 @@ def cachefunc(func):
     else:
         def f(*args):
             if args not in cache:
                 cache[args] = func(*args)
             return cache[args]
 
     return f
 
-deque = collections.deque
-
 class sortdict(dict):
     '''a simple sorted dictionary'''
     def __init__(self, data=None):
         self._list = []
         if data:
             self.update(data)
     def copy(self):
         return sortdict(self)
@@ -381,17 +379,17 @@ class sortdict(dict):
         self._list.insert(index, key)
         dict.__setitem__(self, key, val)
 
 class lrucachedict(object):
     '''cache most recent gets from or sets to this dictionary'''
     def __init__(self, maxsize):
         self._cache = {}
         self._maxsize = maxsize
-        self._order = deque()
+        self._order = collections.deque()
 
     def __getitem__(self, key):
         value = self._cache[key]
         self._order.remove(key)
         self._order.append(key)
         return value
 
     def __setitem__(self, key, value):
@@ -403,22 +401,22 @@ class lrucachedict(object):
         self._cache[key] = value
         self._order.append(key)
 
     def __contains__(self, key):
         return key in self._cache
 
     def clear(self):
         self._cache.clear()
-        self._order = deque()
+        self._order = collections.deque()
 
 def lrucachefunc(func):
     '''cache most recent results of function calls'''
     cache = {}
-    order = deque()
+    order = collections.deque()
     if func.func_code.co_argcount == 1:
         def f(arg):
             if arg not in cache:
                 if len(cache) > 20:
                     del cache[order.popleft()]
                 cache[arg] = func(arg)
             else:
                 order.remove(arg)
@@ -1186,17 +1184,17 @@ class chunkbuffer(object):
                     pos = 0
                     while pos < len(chunk):
                         end = pos + 2 ** 18
                         yield chunk[pos:end]
                         pos = end
                 else:
                     yield chunk
         self.iter = splitbig(in_iter)
-        self._queue = deque()
+        self._queue = collections.deque()
 
     def read(self, l=None):
         """Read L bytes of data from the iterator of chunks of data.
         Returns less than L bytes if the iterator runs dry.
 
         If size parameter is omitted, read everything"""
         left = l
         buf = []