Change the way implicit deps are stored to make it easier to maintain backward compat...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 20 Jun 2002 19:28:44 +0000 (19:28 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 20 Jun 2002 19:28:44 +0000 (19:28 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@393 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Sig/SigTests.py
src/engine/SCons/Sig/__init__.py

index 365a0d6fcdba2bbd400501dd815f52a8e6fb3a4d..548b2e4df28ed12eb4d86bed637ff39c372f66c9 100644 (file)
@@ -481,46 +481,78 @@ class SConsignEntryTestCase(unittest.TestCase):
         assert e.get_implicit() == None
         assert e.render(m) == "- - - -"
 
+        # Check backward compatability with pre-0.07 format:
+        e = SCons.Sig.SConsignEntry(m, "- - - ")
+        assert e.timestamp == None
+        assert e.csig == None
+        assert e.bsig == None
+        assert e.get_implicit() == []
+        assert e.render(m) == "- - - \0\0\0\0"
+
+        # Check backward compatability with pre-0.07 format:
+        e = SCons.Sig.SConsignEntry(m, "- - -")
+        assert e.timestamp == None
+        assert e.csig == None
+        assert e.bsig == None
+        assert e.get_implicit() == None
+        assert e.render(m) == "- - - -"
+        
+        e = SCons.Sig.SConsignEntry(m, "- - - \0\0\0\0")
+        assert e.timestamp == None
+        assert e.csig == None
+        assert e.bsig == None
+        assert e.get_implicit() == []
+        assert e.render(m) == "- - - \0\0\0\0"
+
+        # Check backward compatability with pre-0.08 format:
         e = SCons.Sig.SConsignEntry(m, "- - - foo\0bar")
         assert e.timestamp == None
         assert e.csig == None
         assert e.bsig == None
         assert e.get_implicit() == ['foo', 'bar']
-        assert e.render(m) == "- - - foo\0bar"
+        assert e.render(m) == "- - - \0\0foo\0bar\0\0"
 
-        e = SCons.Sig.SConsignEntry(m, "123 456 789 foo bletch\0bar")
+        e = SCons.Sig.SConsignEntry(m, "- - - \0\0foo\0bar\0\0")
+        assert e.timestamp == None
+        assert e.csig == None
+        assert e.bsig == None
+        assert e.get_implicit() == ['foo', 'bar']
+        assert e.render(m) == "- - - \0\0foo\0bar\0\0"
+
+        e = SCons.Sig.SConsignEntry(m, "123 456 789 \0\0foo bletch\0bar\0\0")
         assert e.timestamp == 123
         assert e.bsig == 456
         assert e.csig == 789
         assert e.get_implicit() == ['foo bletch', 'bar']
-        assert e.render(m) == "123 456 789 foo bletch\0bar"
+        assert e.render(m) == "123 456 789 \0\0foo bletch\0bar\0\0"
 
+        # Check backward compatability with pre-0.07 format:
         e = SCons.Sig.SConsignEntry(m, "987 654 321")
         assert e.timestamp == 987
         assert e.bsig == 654
         assert e.csig == 321
-        assert e.get_implicit() == []
-        assert e.render(m) == "987 654 321 "   # note trailing space
+        assert e.get_implicit() == None
+        assert e.render(m) == "987 654 321 -"
 
-       e.set_implicit(None)
+        e.set_implicit(None)
         assert e.get_implicit() == None, e.get_implicit()
 
-       e.set_implicit('')
+        e.set_implicit('')
         assert e.get_implicit() == [], e.get_implicit()
 
-       e.set_implicit('foo')
+        e.set_implicit('foo')
         assert e.get_implicit() == ['foo'], e.get_implicit()
 
-       e.set_implicit('foo bar')
+        e.set_implicit('foo bar')
         assert e.get_implicit() == ['foo bar'], e.get_implicit()
 
-       e.set_implicit(['foo'])
+        e.set_implicit(['foo'])
         assert e.get_implicit() == ['foo'], e.get_implicit()
 
-       e.set_implicit(['foo bar'])
+        e.set_implicit(['foo bar'])
         assert e.get_implicit() == ['foo bar'], e.get_implicit()
 
-       e.set_implicit(['foo', 'bar'])
+        e.set_implicit(['foo', 'bar'])
         assert e.get_implicit() == ['foo', 'bar'], e.get_implicit()
 
 class SConsignFileTestCase(unittest.TestCase):
index c97f81e73ae43f6c8487e755bfcbff191933336f..553c9cea812dd432ac27aa1f53e2216501e83f15 100644 (file)
@@ -61,9 +61,10 @@ class SConsignEntry:
                 if arr[2] == '-': self.csig = None
                 else:             self.csig = module.from_string(arr[2])
 
-                if len(arr) < 4:    self.implicit = ''
-                elif arr[3] == '-': self.implicit = None
-                else:               self.implicit = arr[3]
+                if len(arr) < 4:        self.implicit = None # pre-0.07 format
+                elif arr[3] == '':      self.implicit = '' # pre-0.08 format
+                elif arr[3] == '-':     self.implicit = None
+                else:                   self.implicit = string.replace(arr[3], '\0\0', '')
             except IndexError:
                 pass
 
@@ -78,7 +79,7 @@ class SConsignEntry:
         else:                 csig = module.to_string(self.csig)
 
         if self.implicit is None: implicit = '-'
-        else:                     implicit = self.implicit
+        else:                     implicit = '\0\0%s\0\0'%self.implicit
 
         return '%s %s %s %s' % (timestamp, bsig, csig, implicit)
 
@@ -94,8 +95,8 @@ class SConsignEntry:
         if implicit is None:
             self.implicit = None
         else:
-           if SCons.Util.is_String(implicit):
-               implicit = [implicit]
+            if SCons.Util.is_String(implicit):
+                implicit = [implicit]
             self.implicit = string.join(map(str, implicit), '\0')