From c05885057890a2971eb0aa544e9cbc99e7eeefe9 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Thu, 22 Aug 2019 11:46:10 +1200 Subject: [PATCH] RRS: fixup handling of upgrades where recipe moved to inc Sometimes in the past it has been desirable to create a shared .inc file from a recipe, e.g. d5a95dc8985a42bb7e50bc4e7dc6b012d711ff08 in OE-Core for tzdata. Git detects this type of change as a rename of the .bb to a .inc with some changes, and an addition of a new .bb with new content; however we want to treat it as a change to the .bb file and ignore the .inc, otherwise it can look like the recipe was renamed and the history becomes broken (it wasn't, the recipe name stayed the same). Detect this situation and handle it properly. Signed-off-by: Paul Eggleton --- rrs/tools/upgrade_history_internal.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/rrs/tools/upgrade_history_internal.py b/rrs/tools/upgrade_history_internal.py index 6949de1..38fee72 100644 --- a/rrs/tools/upgrade_history_internal.py +++ b/rrs/tools/upgrade_history_internal.py @@ -234,6 +234,7 @@ def _get_recipes_filenames(ct, repo, repodir, layersubdir_start, logger): ct_files = [] deleted = [] moved_files = [] + added_files = [] incdirs = [] commitobj = repo.commit(ct) @@ -254,7 +255,12 @@ def _get_recipes_filenames(ct, repo, repodir, layersubdir_start, logger): continue if typename == 'recipe': - ct_files.append(os.path.join(repodir, diffitem.b_path)) + (to_typename, _, _) = recipeparse.detect_file_type(diffitem.b_path, + layersubdir_start) + if to_typename == 'recipe': + ct_files.append(os.path.join(repodir, diffitem.b_path)) + if diffitem.a_path is None or diffitem.new_file: + added_files.append(diffitem.b_path) if diffitem.a_path != diffitem.b_path: moved_files.append((diffitem.a_path, diffitem.b_path)) elif typename == 'incfile': @@ -268,6 +274,16 @@ def _get_recipes_filenames(ct, repo, repodir, layersubdir_start, logger): if not f in ct_files: ct_files.append(f) + # Check moves for recipe -> inc with an added recipe + # (i.e. the move should really be to the newly added recipe) + # example: d5a95dc8985a42bb7e50bc4e7dc6b012d711ff08 in OE-Core + for i,(a,b) in enumerate(moved_files): + if b.endswith('.inc'): + for af in added_files: + # This is naive, but good enough + if af.rsplit('_')[0] == a.rsplit('_')[0]: + moved_files[i] = (a,af) + return ct_files, deleted, moved_files