aboutsummaryrefslogtreecommitdiffstats
path: root/layerindex/update_layer.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-06-07 14:56:22 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2016-06-12 11:33:08 +1200
commit3919f74a2a60b18f730cf75cc8cedc194bc52e36 (patch)
tree504e14c696e5868a8c2826de14172389891d2cc3 /layerindex/update_layer.py
parenta6054920df0384b79c61eeaeceea1eda6c89c8d5 (diff)
downloadopenembedded-core-contrib-3919f74a2a60b18f730cf75cc8cedc194bc52e36.tar.gz
update_layer.py: fix handling of renames with newer GitPython
Newer versions of GitPython implement rename detection, which means that such changes don't show up as adds and deletes anymore and you get a bunch of ENOENT errors for renamed files. Add some code to explicitly look for renames and process them appropriately. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'layerindex/update_layer.py')
-rw-r--r--layerindex/update_layer.py78
1 files changed, 75 insertions, 3 deletions
diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py
index ac4ae1e6d1..bda79cbef0 100644
--- a/layerindex/update_layer.py
+++ b/layerindex/update_layer.py
@@ -17,6 +17,7 @@ import re
import tempfile
import shutil
from distutils.version import LooseVersion
+import itertools
import utils
import recipeparse
@@ -325,7 +326,79 @@ def main():
subdir_start = ""
updatedrecipes = set()
- for diffitem in diff.iter_change_type('D'):
+ dirtyrecipes = set()
+ other_deletes = []
+ other_adds = []
+ for diffitem in diff.iter_change_type('R'):
+ oldpath = diffitem.a_blob.path
+ newpath = diffitem.b_blob.path
+ skip = False
+ for removedir in removedirs:
+ # FIXME what about files moved into removedirs?
+ if oldpath.startswith(removedir):
+ skip = True
+ break
+ if skip:
+ continue
+ if oldpath.startswith(subdir_start):
+ (oldtypename, oldfilepath, oldfilename) = recipeparse.detect_file_type(oldpath, subdir_start)
+ (newtypename, newfilepath, newfilename) = recipeparse.detect_file_type(newpath, subdir_start)
+ if oldtypename != newtypename:
+ # This is most likely to be a .inc file renamed to a .bb - and since
+ # there may be another recipe deleted at the same time we probably want
+ # to consider that, so just treat it as a delete and an add
+ logger.debug("Treating rename of %s to %s as a delete and add (since type changed)" % (oldpath, newpath))
+ other_deletes.append(diffitem)
+ other_adds.append(diffitem)
+ elif oldtypename == 'recipe':
+ results = layerrecipes.filter(filepath=oldfilepath).filter(filename=oldfilename)
+ if len(results):
+ recipe = results[0]
+ logger.debug("Rename recipe %s to %s" % (recipe, newpath))
+ recipe.filepath = newfilepath
+ recipe.filename = newfilename
+ recipe.save()
+ update_recipe_file(config_data_copy, os.path.join(layerdir, newfilepath), recipe, layerdir_start, repodir)
+ updatedrecipes.add(os.path.join(oldfilepath, oldfilename))
+ updatedrecipes.add(os.path.join(newfilepath, newfilename))
+ else:
+ logger.warn("Renamed recipe %s could not be found" % oldpath)
+ other_adds.append(diffitem)
+ elif oldtypename == 'bbappend':
+ results = layerappends.filter(filepath=oldfilepath).filter(filename=oldfilename)
+ if len(results):
+ logger.debug("Rename bbappend %s to %s" % (results[0], newfilepath))
+ results[0].filepath = newfilepath
+ results[0].filename = newfilename
+ results[0].save()
+ else:
+ logger.warn("Renamed bbappend %s could not be found" % oldpath)
+ other_adds.append(diffitem)
+ elif oldtypename == 'machine':
+ results = layermachines.filter(name=oldfilename)
+ if len(results):
+ logger.debug("Rename machine %s to %s" % (results[0], newfilename))
+ results[0].name = newfilename
+ results[0].save()
+ else:
+ logger.warn("Renamed machine %s could not be found" % oldpath)
+ other_adds.append(diffitem)
+ elif oldtypename == 'bbclass':
+ results = layerclasses.filter(name=oldfilename)
+ if len(results):
+ logger.debug("Rename class %s to %s" % (results[0], newfilename))
+ results[0].name = newfilename
+ results[0].save()
+ else:
+ logger.warn("Renamed class %s could not be found" % oldpath)
+ other_adds.append(diffitem)
+
+ deps = RecipeFileDependency.objects.filter(layerbranch=layerbranch).filter(path=oldpath)
+ for dep in deps:
+ dirtyrecipes.add(dep.recipe)
+
+
+ for diffitem in itertools.chain(diff.iter_change_type('D'), other_deletes):
path = diffitem.a_blob.path
if path.startswith(subdir_start):
skip = False
@@ -351,7 +424,7 @@ def main():
elif typename == 'bbclass':
layerclasses.filter(name=filename).delete()
- for diffitem in diff.iter_change_type('A'):
+ for diffitem in itertools.chain(diff.iter_change_type('A'), other_adds):
path = diffitem.b_blob.path
if path.startswith(subdir_start):
skip = False
@@ -384,7 +457,6 @@ def main():
bbclass.name = filename
bbclass.save()
- dirtyrecipes = set()
for diffitem in diff.iter_change_type('M'):
path = diffitem.a_blob.path
if path.startswith(subdir_start):