Mercurial > public > mercurial-scm > hg-stable
diff mercurial/dirstate.py @ 5396:5105b119edd2
Add osutil module, containing a listdir function.
This is similar to os.listdir, only it returns a sorted list of tuples.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Fri, 05 Oct 2007 15:01:06 -0700 |
parents | f46ab9cacd3c |
children | 7a64931e2d76 |
line wrap: on
line diff
--- a/mercurial/dirstate.py Fri Oct 05 23:40:33 2007 +0200 +++ b/mercurial/dirstate.py Fri Oct 05 15:01:06 2007 -0700 @@ -10,7 +10,7 @@ from node import * from i18n import _ import struct, os, time, bisect, stat, strutil, util, re, errno, ignore -import cStringIO +import cStringIO, osutil _unknown = ('?', 0, 0, 0) _format = ">cllll" @@ -389,7 +389,7 @@ common_prefix_len += 1 normpath = util.normpath - listdir = os.listdir + listdir = osutil.listdir lstat = os.lstat bisect_left = bisect.bisect_left isdir = os.path.isdir @@ -410,8 +410,7 @@ add((normpath(s[common_prefix_len:]), 'd', lstat(s))) while work: top = work.pop() - names = listdir(top) - names.sort() + entries = listdir(top, stat=True) # nd is the top of the repository dir tree nd = normpath(top[common_prefix_len:]) if nd == '.': @@ -420,19 +419,19 @@ # do not recurse into a repo contained in this # one. use bisect to find .hg directory so speed # is good on big directory. + names = [e[0] for e in entries] hg = bisect_left(names, '.hg') if hg < len(names) and names[hg] == '.hg': if isdir(join(top, '.hg')): continue - for f in names: + for f, kind, st in entries: np = pconvert(join(nd, f)) if np in known: continue known[np] = 1 p = join(top, f) # don't trip over symlinks - st = lstat(p) - if s_isdir(st.st_mode): + if kind == stat.S_IFDIR: if not ignore(np): wadd(p) if directories: