Commits

Anonymous committed aafb75f

Add version ID's to the classes stored in a .sconsign file, for easier
future conversion as we change schemas.

Comments (0)

Files changed (9)

src/engine/SCons/Node/Alias.py

             return None
 
 class AliasNodeInfo(SCons.Node.NodeInfoBase):
+    current_version_id = 1
     field_list = ['csig']
     def str_to_node(self, s):
         return default_ans.Alias(s)
 
 class AliasBuildInfo(SCons.Node.BuildInfoBase):
-    pass
+    current_version_id = 1
 
 class Alias(SCons.Node.Node):
 

src/engine/SCons/Node/FS.py

 
 class DirNodeInfo(SCons.Node.NodeInfoBase):
     # This should get reset by the FS initialization.
+    current_version_id = 1
+
     top = None
 
     def str_to_node(self, s):
         return n
 
 class DirBuildInfo(SCons.Node.BuildInfoBase):
-    pass
+    current_version_id = 1
 
 class Dir(Base):
     """A class for directories in a file system.
         return _null
 
 class FileNodeInfo(SCons.Node.NodeInfoBase):
+    current_version_id = 1
+
     field_list = ['csig', 'timestamp', 'size']
 
     # This should get reset by the FS initialization.
             n = top.root._lookup_abs(s, Entry)
         return n
 
-    def get_csig(self):
-        return self.csig
-
-    def get_size(self):
-        return self.size
-
-    def get_timestamp(self):
-        return self.timestamp
-
 class FileBuildInfo(SCons.Node.BuildInfoBase):
+    current_version_id = 1
+
     def convert_to_sconsign(self):
         """
         Converts this FileBuildInfo object for writing to a .sconsign file

src/engine/SCons/Node/NodeTests.py

         ni2.a3 = 333
 
         ni1.merge(ni2)
-        assert ni1.__dict__ == {'a1':1, 'a2':222, 'a3':333}, ni1.__dict__
+        expect = {'a1':1, 'a2':222, 'a3':333, '_version_id':1}
+        assert ni1.__dict__ == expect, ni1.__dict__
 
     def test_update(self):
         """Test the update() method"""
         ni1.zzz = 'z'
 
         f = ni1.format()
-        assert f == ['x', 'y', 'z'], f
+        assert f == ['1', 'x', 'y', 'z'], f
 
         ni1.field_list = ['xxx', 'zzz', 'aaa']
 

src/engine/SCons/Node/Python.py

 import SCons.Node
 
 class ValueNodeInfo(SCons.Node.NodeInfoBase):
+    current_version_id = 1
+
     field_list = ['csig']
 
     def str_to_node(self, s):
         return Value(s)
 
 class ValueBuildInfo(SCons.Node.BuildInfoBase):
-    pass
+    current_version_id = 1
 
 class Value(SCons.Node.Node):
     """A class for Python variables, typically passed on the command line 

src/engine/SCons/Node/__init__.py

 from SCons.Debug import logInstanceCreation
 import SCons.Executor
 import SCons.Memoize
-import SCons.SConsign
 import SCons.Util
 
 from SCons.Debug import Trace
     Node subclasses should subclass NodeInfoBase to provide their own
     logic for dealing with their own Node-specific signature information.
     """
+    current_version_id = 1
     def __init__(self, node):
-        """A null initializer so that subclasses have a superclass
-        initialization method to call for future use.
-        """
-        pass
+        # Create an object attribute from the class attribute so it ends up
+        # in the pickled data in the .sconsign file.
+        self._version_id = self.current_version_id
     def update(self, node):
         try:
             field_list = self.field_list
                 delattr(self, f)
             except AttributeError:
                 pass
-            func = getattr(node, 'get_' + f)
-            setattr(self, f, func())
+            try:
+                func = getattr(node, 'get_' + f)
+            except AttributeError:
+                pass
+            else:
+                setattr(self, f, func())
     def convert(self, node, val):
         pass
     def merge(self, other):
     generic build stuff we have to track:  sources, explicit dependencies,
     implicit dependencies, and action information.
     """
+    current_version_id = 1
     def __init__(self, node):
+        # Create an object attribute from the class attribute so it ends up
+        # in the pickled data in the .sconsign file.
+        self._version_id = self.current_version_id
         self.bsourcesigs = []
         self.bdependsigs = []
         self.bimplicitsigs = []

src/engine/SCons/SConsign.py

     XXX As coded below, we do expect a '.binfo' attribute to be added,
     but we'll probably generalize this in the next refactorings.
     """
+    current_version_id = 1
+    def __init__(self):
+        # Create an object attribute from the class attribute so it ends up
+        # in the pickled data in the .sconsign file.
+        _version_id = self.current_version_id
     def convert_to_sconsign(self):
         self.binfo.convert_to_sconsign()
     def convert_from_sconsign(self, dir, name):

src/script/sconsign.py

     # to do, except that we want the keys sorted for deterministic output.
     d = ninfo.__dict__
     try:
-        keys = ninfo.field_list
+        keys = ninfo.field_list + ['_version_id']
     except AttributeError:
         keys = d.keys()
         keys.sort()

test/sconsign/script/SConsignFile.py

 
 test.run_sconsign(arguments = "--raw .sconsign",
          stdout = r"""=== .:
-SConstruct: {'csig': None, 'timestamp': \d+, 'size': \d+L?}
+SConstruct: {'csig': None, 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
 === %(CC_dir)s:
-%(CC_file)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
+%(CC_file)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
 === sub1:
-hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(LINK)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
+hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(LINK)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
         %(sig_re)s \[.*\]
-hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(CC)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
+hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(CC)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
         %(sig_re)s \[.*\]
 === sub2:
-hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(sub2_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(LINK)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
+hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(sub2_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(LINK)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
         %(sig_re)s \[.*\]
-hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(sub2_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(sub2_inc1_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(sub2_inc2_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(CC)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
+hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(sub2_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(sub2_inc1_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(sub2_inc2_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(CC)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
         %(sig_re)s \[.*\]
-inc1.h: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-inc2.h: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
+inc1.h: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+inc2.h: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
 """ % locals())
 
 expect = r"""=== .:

test/sconsign/script/no-SConsignFile.py

 #print test.stdout()
 
 test.run_sconsign(arguments = "--raw sub1/.sconsign",
-         stdout = r"""hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(LINK)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
+         stdout = r"""hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(LINK)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
         %(sig_re)s \[.*\]
-hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
-        %(CC)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?}
+hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+        %(CC)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
         %(sig_re)s \[.*\]
 """ % locals())