bisect-kit: handle git repo merging
src/buildtools moved into src/, changes in bisect-kit needed
1. We cannot simply rmtree src/buildtools because its children are
moved to src/ as well. This CL handles by removing and adding all
its children repos.
2. Because of above removing and adding, we need to runhook again.
This CL do runhook for every switch. This is more correct behavior
with cost about half minutes per switch.
BUG=chromium:930047,b:126633034
TEST=switch_cros_cr_localbuild_internal.py works well between 74.0.3690.0 and 74.0.3700.0
Change-Id: Ie081b04dffbdf4b74c96e1260b124b7d2b64b352
Reviewed-on: https://chromium-review.googlesource.com/1530375
Commit-Ready: Kuang-che Wu <kcwu@chromium.org>
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Reviewed-by: Chi-Ngai Wan <cnwan@google.com>
diff --git a/bisect_kit/codechange.py b/bisect_kit/codechange.py
index 132415a..172544e 100644
--- a/bisect_kit/codechange.py
+++ b/bisect_kit/codechange.py
@@ -650,8 +650,18 @@
# At next_float.timestamp.
if path not in next_float:
# remove repo
- actions.append(GitRemoveRepo(next_float.timestamp, path))
next_at = None
+ sub_repos = [p for p in prev_float.entries if p.startswith(path + '/')]
+ group = ActionGroup(next_float.timestamp, comment='remove %s' % path)
+ # Remove deeper repo first
+ for path2 in sorted(sub_repos, reverse=True):
+ group.add(GitRemoveRepo(next_float.timestamp, path2))
+ group.add(GitRemoveRepo(next_float.timestamp, path))
+ for path2 in sorted(set(sub_repos) & set(next_float.entries)):
+ group.add(
+ GitAddRepo(next_float.timestamp, path2,
+ next_float[path2].repo_url, prev_float[path2].at))
+ actions.append(group)
elif next_float[path].is_static():
# pinned to certain commit on different branch
@@ -705,7 +715,7 @@
"""Reorder and cluster actions.
Args:
- actions: list of Action objects
+ actions: list of Action or ActionGroup objects
Returns:
list of ActionGroup objects
@@ -714,8 +724,11 @@
actions.sort(key=lambda x: x.timestamp)
result = []
for action in actions:
- group = ActionGroup(action.timestamp)
- group.add(action)
+ if isinstance(action, ActionGroup):
+ group = action
+ else:
+ group = ActionGroup(action.timestamp)
+ group.add(action)
result.append(group)
return result