From: stevenknight Date: Thu, 1 Apr 2004 00:20:09 +0000 (+0000) Subject: Fix a bug in CVS checkouts when env.SourceCode() is called with a File, not a Directory. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2181fecb110fc63887560b438f900f445914f12f;p=scons.git Fix a bug in CVS checkouts when env.SourceCode() is called with a File, not a Directory. git-svn-id: http://scons.tigris.org/svn/scons/trunk@936 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 648e9103..1813fc30 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -37,6 +37,10 @@ RELEASE 0.96 - XXX - Fix a regression that prevented the Command() global function in 0.95 from working with command-line strings. + - Fix checking out a file from a source code management system when + the env.SourceCode() method was called with an individual file name + or node, not a directory name or node. + From Gary Oberbrunner: - Add a --debug=presub option to print actions prior to substitution. diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 3bf2ee4d..bb13afcf 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -187,7 +187,7 @@ def CachePushFunc(target, source, env): return if not fs.isdir(cachedir): - fs.mkdir(cachedir) + fs.makedirs(cachedir) tempfile = cachefile+'.tmp' try: @@ -515,6 +515,8 @@ class Base(SCons.Node.Node): def set_src_builder(self, builder): """Set the source code builder for this node.""" self.sbuilder = builder + if not self.has_builder(): + self.builder_set(builder) def src_builder(self): """Fetch the source code builder for this node. diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 94280f72..b1999e08 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1432,30 +1432,51 @@ class has_src_builderTestCase(unittest.TestCase): f4 = fs.File('f4', sub2) f5 = fs.File('f5', sub2) f6 = fs.File('f6', sub2) + f7 = fs.File('f7', sub2) h = f1.has_src_builder() assert not h, h + h = f1.has_builder() + assert not h, h b1 = Builder(fs.File) sub1.set_src_builder(b1) test.write(['sub1', 'f2'], "sub1/f2\n") - h = f1.has_src_builder() # cached from previous call + h = f1.has_src_builder() # cached from previous call + assert not h, h + h = f1.has_builder() # cached from previous call assert not h, h h = f2.has_src_builder() assert not h, h + h = f2.has_builder() + assert not h, h h = f3.has_src_builder() assert h, h + h = f3.has_builder() + assert h, h assert f3.builder is b1, f3.builder + f7.set_src_builder(b1) + test.write(['sub2', 'SCCS', 's.f5'], "sub2/SCCS/s.f5\n") test.write(['sub2', 'RCS', 'f6,v'], "sub2/RCS/f6,v\n") h = f4.has_src_builder() assert not h, h + h = f4.has_builder() + assert not h, h h = f5.has_src_builder() assert h, h + h = f5.has_builder() + assert h, h h = f6.has_src_builder() assert h, h + h = f6.has_builder() + assert h, h + h = f7.has_src_builder() + assert h, h + h = f7.has_builder() + assert h, h class prepareTestCase(unittest.TestCase): def runTest(self): diff --git a/test/CVS.py b/test/CVS.py index 2eed3d2f..25d87e51 100644 --- a/test/CVS.py +++ b/test/CVS.py @@ -234,19 +234,74 @@ test.fail_test(not is_writable(test.workpath('work2', 'ccc.in'))) test.fail_test(not is_writable(test.workpath('work2', 'sub', 'ddd.in'))) test.fail_test(not is_writable(test.workpath('work2', 'sub', 'fff.in'))) -# Test CVS checkouts from a remote server (SourceForge). +# Test checking out specific file name(s), and expanding +# the repository name with a variable. test.subdir(['work3']) test.write(['work3', 'SConstruct'], """\ import os +def cat(env, source, target): + target = str(target[0]) + source = map(str, source) + f = open(target, "wb") + for src in source: + f.write(open(src, "rb").read()) + f.close() +env = Environment(ENV = { 'PATH' : os.environ['PATH'] }, + BUILDERS={'Cat':Builder(action=cat)}, + CVSROOT=r'%s') +env.Prepend(CVSFLAGS='-q') +env.Cat('aaa.out', 'aaa.in') +env.Cat('bbb.out', 'bbb.in') +env.Cat('ccc.out', 'ccc.in') +env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +cvs = env.CVS('$CVSROOT', 'foo') +#env.SourceCode('.', cvs) +env.SourceCode('aaa.in', cvs) +env.SourceCode('bbb.in', cvs) +env.SourceCode('ccc.in', cvs) +""" % cvsroot) + +test.run(chdir = 'work3', + arguments = '.', + stdout = test.wrap_stdout(build_str = """\ +cvs -q -d %s co -d . foo/aaa.in +U ./aaa.in +cat("aaa.out", "aaa.in") +cvs -q -d %s co -d . foo/bbb.in +U ./bbb.in +cat("bbb.out", "bbb.in") +cvs -q -d %s co -d . foo/ccc.in +U ./ccc.in +cat("ccc.out", "ccc.in") +cat("all", ["aaa.out", "bbb.out", "ccc.out"]) +""" % (cvsroot, + cvsroot, + cvsroot))) + +test.must_match(['work3', 'aaa.out'], "import/aaa.in\n") +test.must_match(['work3', 'bbb.out'], "import/bbb.in\n") +test.must_match(['work3', 'ccc.out'], "import/ccc.in\n") +test.must_match(['work3', 'all'], "import/aaa.in\nimport/bbb.in\nimport/ccc.in\n") + +# Test CVS checkouts from a remote server (Tigris.org). +test.subdir(['work4']) + +test.write(['work4', 'SConstruct'], """\ +import os env = Environment(ENV = { 'PATH' : os.environ['PATH'] }) -env.SourceCode('.', env.CVS(':pserver:anonymous@cvs.sourceforge.net:/cvsroot/scons')) +# We used to use the SourceForge server, but SourceForge has restrictions +# that make them deny access on occasion. Leave the incantation here +# in case we need to use it again some day. +#cvs = env.CVS(':pserver:anonymous@cvs.sourceforge.net:/cvsroot/scons') +cvs = env.CVS(':pserver:anoncvs@cvs.tigris.org:/cvs') +env.SourceCode('.', cvs) env.Install('install', 'scons/SConstruct') """) -test.run(chdir = 'work3', arguments = '.') +test.run(chdir = 'work4', arguments = '.') -test.fail_test(not os.path.exists(test.workpath('work3', 'install', 'SConstruct'))) +test.fail_test(not os.path.exists(test.workpath('work4', 'install', 'SConstruct'))) test.pass_test()