Fix AppendUnique and PrependUnique concatenating strings to lists. (Patrick Mezard)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 6 Nov 2005 03:25:46 +0000 (03:25 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 6 Nov 2005 03:25:46 +0000 (03:25 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1380 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py

index de7bf8ecde571dbae27c79f05bee86f469327f1e..56881786cb0a681660ecb5c1b38206da610d8bc3 100644 (file)
@@ -417,6 +417,9 @@ RELEASE 0.97 - XXX
     one in the build directory, too, to avoid dangling files left
     over from previous runs when a source file is removed.
 
+  - Allow AppendUnique() and PrependUnique() to append strings (and
+    other atomic objects) to lists.
+
   From Georg Mischler:
 
   - Remove the space after the -o option when invoking the Borland
index ce8e37421d12a7fae9517194c815a9ca8f5df951..38346364f300dc0068e5b3ab830cfe5ff588bce8 100644 (file)
@@ -747,8 +747,10 @@ class Base(SubstitutionEnvironment):
             else:
                 dk = self._dict[key]
                 if SCons.Util.is_List(dk):
+                    # By elimination, val is not a list.  Since dk is a
+                    # list, wrap val in a list first.
                     if not val in dk:
-                        self._dict[key] = dk + val
+                        self._dict[key] = dk + [val]
                 else:
                     self._dict[key] = self._dict[key] + val
         self.scanner_map_delete(kw)
@@ -1044,8 +1046,10 @@ class Base(SubstitutionEnvironment):
             else:
                 dk = self._dict[key]
                 if SCons.Util.is_List(dk):
+                    # By elimination, val is not a list.  Since dk is a
+                    # list, wrap val in a list first.
                     if not val in dk:
-                        self._dict[key] = val + dk
+                        self._dict[key] = [val] + dk
                 else:
                     self._dict[key] = val + dk
         self.scanner_map_delete(kw)
index caf8b4a28b05500c0e760f62e2497418ac4d758c..a397d4fbec51f62a9c3b0ca87fdbe580a17bcb2f 100644 (file)
@@ -1187,26 +1187,38 @@ def exists(env):
         env = Environment(AAA1 = 'a1',
                           AAA2 = 'a2',
                           AAA3 = 'a3',
+                          AAA4 = 'a4',
+                          AAA5 = 'a5',
                           BBB1 = ['b1'],
                           BBB2 = ['b2'],
                           BBB3 = ['b3'],
+                          BBB4 = ['b4'],
+                          BBB5 = ['b5'],
                           CCC1 = '',
                           CCC2 = '')
         env.AppendUnique(AAA1 = 'a1',
                          AAA2 = ['a2'],
                          AAA3 = ['a3', 'b', 'c', 'a3'],
+                         AAA4 = 'a4.new',
+                         AAA5 = ['a5.new'],
                          BBB1 = 'b1',
                          BBB2 = ['b2'],
                          BBB3 = ['b3', 'c', 'd', 'b3'],
+                         BBB4 = 'b4.new',
+                         BBB5 = ['b5.new'],
                          CCC1 = 'c1',
                          CCC2 = ['c2'])
 
         assert env['AAA1'] == 'a1a1', env['AAA1']
         assert env['AAA2'] == ['a2'], env['AAA2']
         assert env['AAA3'] == ['a3', 'b', 'c'], env['AAA3']
+        assert env['AAA4'] == 'a4a4.new', env['AAA4']
+        assert env['AAA5'] == ['a5', 'a5.new'], env['AAA5']
         assert env['BBB1'] == ['b1'], env['BBB1']
         assert env['BBB2'] == ['b2'], env['BBB2']
         assert env['BBB3'] == ['b3', 'c', 'd'], env['BBB3']
+        assert env['BBB4'] == ['b4', 'b4.new'], env['BBB4']
+        assert env['BBB5'] == ['b5', 'b5.new'], env['BBB5']
         assert env['CCC1'] == 'c1', env['CCC1']
         assert env['CCC2'] == ['c2'], env['CCC2']
 
@@ -1720,25 +1732,37 @@ f5: \
         env = Environment(AAA1 = 'a1',
                           AAA2 = 'a2',
                           AAA3 = 'a3',
+                          AAA4 = 'a4',
+                          AAA5 = 'a5',
                           BBB1 = ['b1'],
                           BBB2 = ['b2'],
                           BBB3 = ['b3'],
+                          BBB4 = ['b4'],
+                          BBB5 = ['b5'],
                           CCC1 = '',
                           CCC2 = '')
         env.PrependUnique(AAA1 = 'a1',
                           AAA2 = ['a2'],
                           AAA3 = ['a3', 'b', 'c', 'a3'],
+                          AAA4 = 'a4.new',
+                          AAA5 = ['a5.new'],
                           BBB1 = 'b1',
                           BBB2 = ['b2'],
                           BBB3 = ['b3', 'b', 'c', 'b3'],
+                          BBB4 = 'b4.new',
+                          BBB5 = ['b5.new'],
                           CCC1 = 'c1',
                           CCC2 = ['c2'])
         assert env['AAA1'] == 'a1a1', env['AAA1']
         assert env['AAA2'] == ['a2'], env['AAA2']
         assert env['AAA3'] == ['b', 'c', 'a3'], env['AAA3']
+        assert env['AAA4'] == 'a4.newa4', env['AAA4']
+        assert env['AAA5'] == ['a5.new', 'a5'], env['AAA5']
         assert env['BBB1'] == ['b1'], env['BBB1']
         assert env['BBB2'] == ['b2'], env['BBB2']
         assert env['BBB3'] == ['b', 'c', 'b3'], env['BBB3']
+        assert env['BBB4'] == ['b4.new', 'b4'], env['BBB4']
+        assert env['BBB5'] == ['b5.new', 'b5'], env['BBB5']
         assert env['CCC1'] == 'c1', env['CCC1']
         assert env['CCC2'] == ['c2'], env['CCC2']