From c486acc05402e4e9644d06030bc4263bfcb4f6d1 Mon Sep 17 00:00:00 2001 From: Gary Oberbrunner Date: Sat, 31 Jul 2010 19:34:57 +0000 Subject: Fix issue 2048: when morphing an Entry into a Dir, retain any existing executor action list. --- src/CHANGES.txt | 4 ++++ src/engine/SCons/Node/FS.py | 21 ++++++++++++++++++--- src/engine/SCons/Node/FSTests.py | 4 ++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index ddc70cf..cf28f38 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -7,6 +7,10 @@ RELEASE 2.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE + From Ken Deeter: + + - Fix a problem when FS Entries which are actually Dirs have builders. + From Luca Falavigna: - Support Fortran 03 diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 4aeaff7..967da26 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1083,7 +1083,10 @@ class FS(LocalFS): self.max_drift = max_drift def getcwd(self): - return self._cwd + if hasattr(self, "_cwd"): + return self._cwd + else: + return "" def chdir(self, dir, change_os_dir=0): """Change the current working directory for lookups. @@ -1353,8 +1356,20 @@ class Dir(Base): # Don't just reset the executor, replace its action list, # because it might have some pre-or post-actions that need to # be preserved. - self.builder = get_MkdirBuilder() - self.get_executor().set_action_list(self.builder.action) + # + # But don't reset the executor if there is a non-null executor + # attached already. The existing executor might have other + # targets, in which case replacing the action list with a + # Mkdir action is a big mistake. + if not hasattr(self, 'executor'): + self.builder = get_MkdirBuilder() + self.get_executor().set_action_list(self.builder.action) + else: + # Prepend MkdirBuilder action to existing action list + l = self.get_executor().action_list + a = get_MkdirBuilder().action + l.insert(0, a) + self.get_executor().set_action_list(l) def diskcheck_match(self): diskcheck_match(self, self.isfile, diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 9a393e2..b5c1448 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1676,8 +1676,8 @@ class DirTestCase(_tempdirTestCase): x.add_post_action('post') e.must_be_same(SCons.Node.FS.Dir) a = x.get_action_list() - assert a[0] == 'pre', a - assert a[2] == 'post', a + assert 'pre' in a, a + assert 'post' in a, a def test_subclass(self): """Test looking up subclass of Dir nodes""" -- cgit v0.12