mercurial/revset.py
changeset 16803 107a3270a24a
parent 16778 2ac08d8b21aa
child 16819 5260a9e93113
equal deleted inserted replaced
16802:7e5d94381cd1 16803:107a3270a24a
     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
     8 import re, collections
     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 = list(revs)
    20     visit = collections.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.pop(0))[: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)
    26                 seen.add(parent)
    26                 seen.add(parent)
    27                 yield parent
    27                 yield parent
    28 
    28