[oe-commits] [bitbake] 01/03: data_smart: Preserve history when renaming variables

git at git.openembedded.org git at git.openembedded.org
Tue Oct 16 16:28:46 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository bitbake.

commit 11722c989077a8751a5d0653c523760bf91e6efa
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Sun Oct 14 16:04:35 2018 +0100

    data_smart: Preserve history when renaming variables
    
    Currently when a variable is renamed, all the variable history is lost.
    This makes it hard for users to understand/debug where values came from.
    
    Improve the code so that history is preserved across renamed variables.
    
    (Expanded variable key names are a special case of variable renaming)
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/data_smart.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 7b09af5..4434142 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -267,6 +267,16 @@ class VariableHistory(object):
             return
         self.variables[var].append(loginfo.copy())
 
+    def rename_variable_hist(self, oldvar, newvar):
+        if not self.dataroot._tracking:
+            return
+        if oldvar not in self.variables:
+            return
+        if newvar not in self.variables:
+            self.variables[newvar] = []
+        for i in self.variables[oldvar]:
+            self.variables[newvar].append(i.copy())
+
     def variable(self, var):
         remote_connector = self.dataroot.getVar('_remote_data', False)
         if remote_connector:
@@ -619,6 +629,7 @@ class DataSmart(MutableMapping):
 
         val = self.getVar(key, 0, parsing=True)
         if val is not None:
+            self.varhistory.rename_variable_hist(key, newkey)
             loginfo['variable'] = newkey
             loginfo['op'] = 'rename from %s' % key
             loginfo['detail'] = val

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list