diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2005-05-17 18:15:25 +0000 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2005-05-17 18:15:25 +0000 |
commit | 150d9f2341f546392d26992b2adac7e3d1344ea4 (patch) | |
tree | 862fd0f8d4fa38dd39b4d79f98cc6d18c691d40d /lib | |
parent | c7f7cfd506f504f658088bc0c7ee9f487d8a3d3f (diff) | |
download | bitbake-150d9f2341f546392d26992b2adac7e3d1344ea4.tar.gz |
createCopy:
-Move a createCopy method into data.py
-Make code creating deepcopies of the data instance
use this new createCopy
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bb/build.py | 3 | ||||
-rw-r--r-- | lib/bb/data.py | 19 | ||||
-rw-r--r-- | lib/bb/data_dict.py | 5 | ||||
-rw-r--r-- | lib/bb/fetch.py | 9 | ||||
-rw-r--r-- | lib/bb/make.py | 2 | ||||
-rw-r--r-- | lib/bb/parse/BBHandler.py | 2 |
6 files changed, 25 insertions, 15 deletions
diff --git a/lib/bb/build.py b/lib/bb/build.py index a77f6e614..3674f9574 100644 --- a/lib/bb/build.py +++ b/lib/bb/build.py @@ -288,8 +288,7 @@ def exec_task(task, d): try: debug(1, "Executing task %s" % item) old_overrides = data.getVar('OVERRIDES', d, 0) - from copy import deepcopy - localdata = deepcopy(d) + localdata = data.createCopy(d) data.setVar('OVERRIDES', 'task_%s:%s' % (item, old_overrides), localdata) data.update_data(localdata) event.fire(TaskStarted(item, localdata)) diff --git a/lib/bb/data.py b/lib/bb/data.py index b7c28b26b..149f86a18 100644 --- a/lib/bb/data.py +++ b/lib/bb/data.py @@ -43,6 +43,16 @@ def init(): _data_dict = init() +def createCopy(source): + """Link the source set to the destination + If one does not find the value in the destination set, + search will go on to the source set to get the value. + Value from source are copy-on-write. i.e. any try to + modify one of them will end up putting the modified value + in the destination set. + """ + return source.createCopy() + def initVar(var, d = _data_dict): """Non-destructive var init for data structure""" d.initVar(var) @@ -142,11 +152,12 @@ def delVarFlags(var, d = _data_dict): """Removes a variable's flags Example: - >>> setVarFlag('TEST', 'testflag', 1) - >>> print getVarFlag('TEST', 'testflag') + >>> data = init() + >>> setVarFlag('TEST', 'testflag', 1, data) + >>> print getVarFlag('TEST', 'testflag', data) 1 - >>> delVarFlags('TEST') - >>> print getVarFlags('TEST') + >>> delVarFlags('TEST', data) + >>> print getVarFlags('TEST', data) None """ diff --git a/lib/bb/data_dict.py b/lib/bb/data_dict.py index 8c6f3d836..22dfdf2fe 100644 --- a/lib/bb/data_dict.py +++ b/lib/bb/data_dict.py @@ -25,7 +25,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA. Based on functions from the base bb module, Copyright 2003 Holger Schurig """ -import os, re, sys, types +import os, re, sys, types, copy from bb import note, debug, fatal __setvar_regexp__ = {} @@ -152,6 +152,9 @@ class DataDict: if var in self.dict and "flags" in self.dict[var]: del self.dict[var]["flags"] + def createCopy(self): + return copy.deepcopy(self) + # Dictionary Methods def keys(self): return self.dict.keys() diff --git a/lib/bb/fetch.py b/lib/bb/fetch.py index 4cbad736a..a29ee2a04 100644 --- a/lib/bb/fetch.py +++ b/lib/bb/fetch.py @@ -202,8 +202,7 @@ class Wget(Fetch): if not urls: urls = self.urls - from copy import deepcopy - localdata = deepcopy(d) + localdata = bb.data.createCopy(d) bb.data.setVar('OVERRIDES', "wget:" + bb.data.getVar('OVERRIDES', localdata), localdata) bb.data.update_data(localdata) @@ -290,8 +289,7 @@ class Cvs(Fetch): if not urls: urls = self.urls - from copy import deepcopy - localdata = deepcopy(d) + localdata = bb.data.createCopy(d) bb.data.setVar('OVERRIDES', "cvs:%s" % bb.data.getVar('OVERRIDES', localdata), localdata) bb.data.update_data(localdata) @@ -512,8 +510,7 @@ class Svn(Fetch): if not urls: urls = self.urls - from copy import deepcopy - localdata = deepcopy(d) + localdata = bb.data.createCopy(d) bb.data.setVar('OVERRIDES', "svn:%s" % bb.data.getVar('OVERRIDES', localdata), localdata) bb.data.update_data(localdata) diff --git a/lib/bb/make.py b/lib/bb/make.py index df59bf0bb..fc790bb3b 100644 --- a/lib/bb/make.py +++ b/lib/bb/make.py @@ -108,7 +108,7 @@ def load_bbfile( bbfile ): # go there oldpath = os.path.abspath(os.getcwd()) os.chdir(topdir) - bb = copy.deepcopy(cfg) + bb = data.createCopy(cfg) try: parse.handle(bbfile, bb) # read .bb data if not cache in [None, '']: pickle_bb( cache_bbfile, bb) # write cache diff --git a/lib/bb/parse/BBHandler.py b/lib/bb/parse/BBHandler.py index 7ff3909ad..8e7f9c0c5 100644 --- a/lib/bb/parse/BBHandler.py +++ b/lib/bb/parse/BBHandler.py @@ -64,7 +64,7 @@ def inherit(files, d): data.setVar('__inherit_cache', __inherit_cache, d) -def handle(fn, d = data.init(), include = 0): +def handle(fn, d, include = 0): global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __bbpath_found__, __residue__ __body__ = [] __bbpath_found__ = 0 |