SConsign.py (scons-4.2.0) | : | SConsign.py (SCons-4.3.0) | ||
---|---|---|---|---|
skipping to change at line 60 | skipping to change at line 60 | |||
# "DataBase" is a dictionary that maps top-level SConstruct directories | # "DataBase" is a dictionary that maps top-level SConstruct directories | |||
# to open database handles. | # to open database handles. | |||
# "DB_Module" is the Python database module to create the handles. | # "DB_Module" is the Python database module to create the handles. | |||
# "DB_Name" is the base name of the database file (minus any | # "DB_Name" is the base name of the database file (minus any | |||
# extension the underlying DB module will add). | # extension the underlying DB module will add). | |||
DataBase = {} | DataBase = {} | |||
DB_Module = SCons.dblite | DB_Module = SCons.dblite | |||
DB_Name = None | DB_Name = None | |||
DB_sync_list = [] | DB_sync_list = [] | |||
def current_sconsign_filename(): | ||||
hash_format = SCons.Util.get_hash_format() | ||||
current_hash_algorithm = SCons.Util.get_current_hash_algorithm_used() | ||||
# if the user left the options defaulted AND the default algorithm set by | ||||
# SCons is md5, then set the database name to be the special default name | ||||
# | ||||
# otherwise, if it defaults to something like 'sha1' or the user explicitly | ||||
# set 'md5' as the hash format, set the database name to .sconsign_<algorith | ||||
m> | ||||
# eg .sconsign_sha1, etc. | ||||
if hash_format is None and current_hash_algorithm == 'md5': | ||||
return ".sconsign" | ||||
else: | ||||
return ".sconsign_" + current_hash_algorithm | ||||
def Get_DataBase(dir): | def Get_DataBase(dir): | |||
global DataBase, DB_Module, DB_Name | global DataBase, DB_Module, DB_Name | |||
if DB_Name is None: | if DB_Name is None: | |||
hash_format = SCons.Util.get_hash_format() | DB_Name = current_sconsign_filename() | |||
if hash_format is None: | ||||
DB_Name = ".sconsign" | ||||
else: | ||||
DB_Name = ".sconsign_%s" % hash_format | ||||
top = dir.fs.Top | top = dir.fs.Top | |||
if not os.path.isabs(DB_Name) and top.repositories: | if not os.path.isabs(DB_Name) and top.repositories: | |||
mode = "c" | mode = "c" | |||
for d in [top] + top.repositories: | for d in [top] + top.repositories: | |||
if dir.is_under(d): | if dir.is_under(d): | |||
try: | try: | |||
return DataBase[d], mode | return DataBase[d], mode | |||
except KeyError: | except KeyError: | |||
path = d.entry_abspath(DB_Name) | path = d.entry_abspath(DB_Name) | |||
skipping to change at line 329 | skipping to change at line 339 | |||
class DirFile(Dir): | class DirFile(Dir): | |||
""" | """ | |||
Encapsulates reading and writing a per-directory .sconsign file. | Encapsulates reading and writing a per-directory .sconsign file. | |||
""" | """ | |||
def __init__(self, dir): | def __init__(self, dir): | |||
""" | """ | |||
dir - the directory for the file | dir - the directory for the file | |||
""" | """ | |||
self.dir = dir | self.dir = dir | |||
self.sconsign = os.path.join(dir.get_internal_path(), '.sconsign') | self.sconsign = os.path.join(dir.get_internal_path(), current_sconsign_f ilename()) | |||
try: | try: | |||
fp = open(self.sconsign, 'rb') | fp = open(self.sconsign, 'rb') | |||
except IOError: | except IOError: | |||
fp = None | fp = None | |||
try: | try: | |||
Dir.__init__(self, fp, dir) | Dir.__init__(self, fp, dir) | |||
except KeyboardInterrupt: | except KeyboardInterrupt: | |||
raise | raise | |||
End of changes. 3 change blocks. | ||||
6 lines changed or deleted | 17 lines changed or added |