Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.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 | b6ef1395d77f |
children | d37d221334be |
comparison
equal
deleted
inserted
replaced
16833:7b460b49bf7b | 16834:cafd8a8fb713 |
---|---|
3 # Copyright 2010 Matt Mackall <mpm@selenic.com> | 3 # Copyright 2010 Matt Mackall <mpm@selenic.com> |
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 import re, collections | 8 import re |
9 import parser, util, error, discovery, hbisect, phases | 9 import parser, util, error, discovery, hbisect, phases |
10 import node | 10 import node |
11 import bookmarks as bookmarksmod | 11 import bookmarks as bookmarksmod |
12 import match as matchmod | 12 import match as matchmod |
13 from i18n import _ | 13 from i18n import _ |
15 | 15 |
16 def _revancestors(repo, revs, followfirst): | 16 def _revancestors(repo, revs, followfirst): |
17 """Like revlog.ancestors(), but supports followfirst.""" | 17 """Like revlog.ancestors(), but supports followfirst.""" |
18 cut = followfirst and 1 or None | 18 cut = followfirst and 1 or None |
19 cl = repo.changelog | 19 cl = repo.changelog |
20 visit = collections.deque(revs) | 20 visit = util.deque(revs) |
21 seen = set([node.nullrev]) | 21 seen = set([node.nullrev]) |
22 while visit: | 22 while visit: |
23 for parent in cl.parentrevs(visit.popleft())[:cut]: | 23 for parent in cl.parentrevs(visit.popleft())[:cut]: |
24 if parent not in seen: | 24 if parent not in seen: |
25 visit.append(parent) | 25 visit.append(parent) |