summaryrefslogtreecommitdiffstats
path: root/src/engine
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)
commit83d2c54302835180d4f130d75cd69a92b2d7fd9b (patch)
tree861e5eba3a6f3cf19861c6b267b2c4fb136fa0e7 /src/engine
parent5faa4cdcada0914e06d5a3329960b6b13c7d51b5 (diff)
downloadSCons-83d2c54302835180d4f130d75cd69a92b2d7fd9b.zip
SCons-83d2c54302835180d4f130d75cd69a92b2d7fd9b.tar.gz
SCons-83d2c54302835180d4f130d75cd69a92b2d7fd9b.tar.bz2
More efficient checking for on-disk file entries.
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Node/FS.py40
-rw-r--r--src/engine/SCons/Node/FSTests.py8
2 files changed, 31 insertions, 17 deletions
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)