bisect-kit: revise ActionGroup serialization
Currently, chromeos local build bisector may fail when manifest glitch
occurs because
1. ActionGroup comment was not serialized
2. Multiple Actions in single ActionGroup was not supported
BUG=chromium:827092
TEST=after init, run './bisect_cros_repo.py view'
Change-Id: Ibefe5a38583ebf5601ee478da8b858368cc6c160
Reviewed-on: https://chromium-review.googlesource.com/1161844
Commit-Ready: Kuang-che Wu <kcwu@chromium.org>
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Reviewed-by: Kuang-che Wu <kcwu@chromium.org>
diff --git a/bisect_kit/codechange.py b/bisect_kit/codechange.py
index a25bf8c..c50407f 100644
--- a/bisect_kit/codechange.py
+++ b/bisect_kit/codechange.py
@@ -292,20 +292,28 @@
self.actions.append(action)
def serialize(self):
- return (self.timestamp, self.name, [a.serialize() for a in self.actions])
+ return dict(
+ timestamp=self.timestamp,
+ name=self.name,
+ comment=self.comment,
+ actions=[a.serialize() for a in self.actions])
def summary(self, code_storage):
if self.comment:
return self.comment
- # TODO(kcwu): support multiple Actions
- assert len(self.actions) == 1
- return self.actions[0].summary(code_storage)
+ assert self.actions
+ if len(self.actions) > 1:
+ # TODO(kcwu): show details for multiple Actions
+ return '(%d actions)' % len(self.actions)
+ else:
+ return self.actions[0].summary(code_storage)
@staticmethod
def unserialize(data):
- ag = ActionGroup(data[0])
- ag.name = data[1]
- for x in data[2]:
+ ag = ActionGroup(data['timestamp'])
+ ag.name = data['name']
+ ag.comment = data['comment']
+ for x in data['actions']:
ag.add(unserialize_action(x))
return ag