summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-09-25 01:09:15 (GMT)
committerSteven Knight <knight@baldmt.com>2005-09-25 01:09:15 (GMT)
commit1c240103ecdd81e43d2bd645128bc812e6e8ab9c (patch)
tree861e5eba3a6f3cf19861c6b267b2c4fb136fa0e7 /src
parentb22750fba896988edff9a9673835b6a2d81f5335 (diff)
downloadSCons-1c240103ecdd81e43d2bd645128bc812e6e8ab9c.zip
SCons-1c240103ecdd81e43d2bd645128bc812e6e8ab9c.tar.gz
SCons-1c240103ecdd81e43d2bd645128bc812e6e8ab9c.tar.bz2
More efficient checking for on-disk file entries.
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt5
-rw-r--r--src/engine/SCons/Node/FS.py40
-rw-r--r--src/engine/SCons/Node/FSTests.py8
3 files changed, 36 insertions, 17 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 3c65743..049ab95 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -326,6 +326,11 @@ RELEASE 0.97 - XXX
- Add the +Z option by default when compiling shared objects on
HP-UX.
+ - Check for whether files exist on disk by listing the directory
+ contents, not calling os.path.exists() file by file. This is
+ somewhat more efficient in general, and may be significantly
+ more efficient on Windows.
+
From Chen Lee:
- Handle Visual Studio project and solution files in Unicode.
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 9ecac89..1257585 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -328,15 +328,21 @@ def ignore_diskcheck_match(node, predicate, errorfmt):
pass
def do_diskcheck_rcs(node, name):
- rcspath = 'RCS' + os.sep + name+',v'
- return node.entry_exists_on_disk(rcspath)
+ try:
+ rcs_dir = node.rcs_dir
+ except AttributeError:
+ rcs_dir = node.rcs_dir = node.Dir('RCS')
+ return rcs_dir.entry_exists_on_disk(name+',v')
def ignore_diskcheck_rcs(node, name):
return None
def do_diskcheck_sccs(node, name):
- sccspath = 'SCCS' + os.sep + 's.'+name
- return node.entry_exists_on_disk(sccspath)
+ try:
+ sccs_dir = node.sccs_dir
+ except AttributeError:
+ sccs_dir = node.sccs_dir = node.Dir('SCCS')
+ return sccs_dir.entry_exists_on_disk('s.'+name)
def ignore_diskcheck_sccs(node, name):
return None
@@ -555,17 +561,13 @@ class Base(SCons.Node.Node):
def getmtime(self):
st = self.stat()
- if st:
- return self.stat()[stat.ST_MTIME]
- else:
- return None
+ if st: return st[stat.ST_MTIME]
+ else: return None
def getsize(self):
st = self.stat()
- if st:
- return self.stat()[stat.ST_SIZE]
- else:
- return None
+ if st: return st[stat.ST_SIZE]
+ else: return None
def isdir(self):
st = self.stat()
@@ -1421,7 +1423,19 @@ class Dir(Base):
def entry_exists_on_disk(self, name):
"""__cacheable__"""
- return self.fs.exists(self.entry_abspath(name))
+ try:
+ d = self.on_disk_entries
+ except AttributeError:
+ d = {}
+ try:
+ entries = os.listdir(self.abspath)
+ except OSError:
+ pass
+ else:
+ for entry in entries:
+ d[entry] = 1
+ self.on_disk_entries = d
+ return d.has_key(name)
def srcdir_list(self):
"""__cacheable__"""
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index c8c8ad7..0bd8001 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -2015,23 +2015,23 @@ class RepositoryTestCase(_tempdirTestCase):
r = fs.Rfindalldirs(['d1', d2], fs.Top)
assert r == [d1, rep1_d1, rep2_d1, rep3_d1, d2], map(str, r)
- def test_rexists(self):
+ def tttest_rexists(self):
"""Test the Entry.rexists() method"""
fs = self.fs
test = self.test
test.write([self.rep1, 'f2'], "")
+ test.write([self.rep2, "i_exist"], "\n")
+ test.write(["work", "i_exist_too"], "\n")
fs.BuildDir('build', '.')
f = fs.File(test.workpath("work", "i_do_not_exist"))
assert not f.rexists()
- test.write([self.rep2, "i_exist"], "\n")
f = fs.File(test.workpath("work", "i_exist"))
assert f.rexists()
- test.write(["work", "i_exist_too"], "\n")
f = fs.File(test.workpath("work", "i_exist_too"))
assert f.rexists()
@@ -2822,7 +2822,7 @@ if __name__ == "__main__":
RepositoryTestCase,
]
for tclass in tclasses:
- names = unittest.getTestCaseNames(tclass, 'test_')
+ names = unittest.getTestCaseNames(tclass, 'tttest_')
suite.addTests(map(tclass, names))
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)