Mercurial > public > mercurial-scm > hg
diff mercurial/streamclone.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 | 97b734fb9c6f |
children | a58d415b272e |
line wrap: on
line diff
--- a/mercurial/streamclone.py Fri Oct 05 23:40:33 2007 +0200 +++ b/mercurial/streamclone.py Fri Oct 05 15:01:06 2007 -0700 @@ -6,7 +6,7 @@ # of the GNU General Public License, incorporated herein by reference. from i18n import _ -import os, stat, util, lock +import os, osutil, stat, util, lock # if server supports streaming clone, it advertises "stream" # capability with value that is version+flags of repo it is serving. @@ -19,17 +19,14 @@ strip_count = len(root) + len(os.sep) def walk(path, recurse): - ents = os.listdir(path) - ents.sort() - for e in ents: + for e, kind, st in osutil.listdir(path, stat=True): pe = os.path.join(path, e) - st = os.lstat(pe) - if stat.S_ISDIR(st.st_mode): + if kind == stat.S_IFDIR: if recurse: for x in walk(pe, True): yield x else: - if not stat.S_ISREG(st.st_mode) or len(e) < 2: + if kind != stat.S_IFREG or len(e) < 2: continue sfx = e[-2:] if sfx in ('.d', '.i'):