From 517511d60b2b6f90ffcf54a47e98fe4d20259977 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Thu, 20 Jun 2002 19:28:44 +0000 Subject: [PATCH] Change the way implicit deps are stored to make it easier to maintain backward compatibility of the .sconsign file format. (Anthony Roach) git-svn-id: http://scons.tigris.org/svn/scons/trunk@393 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Sig/SigTests.py | 56 +++++++++++++++++++++++++------- src/engine/SCons/Sig/__init__.py | 13 ++++---- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/src/engine/SCons/Sig/SigTests.py b/src/engine/SCons/Sig/SigTests.py index 365a0d6f..548b2e4d 100644 --- a/src/engine/SCons/Sig/SigTests.py +++ b/src/engine/SCons/Sig/SigTests.py @@ -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): diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py index c97f81e7..553c9cea 100644 --- a/src/engine/SCons/Sig/__init__.py +++ b/src/engine/SCons/Sig/__init__.py @@ -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') -- 2.26.2