From a47c35f84688ea90f8ee50bc8f40b811c6b887c2 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Tue, 27 Nov 2012 14:18:00 +0000 Subject: Fix and simplify skipping modules --- (limited to 'devbot') diff --git a/devbot/build.py b/devbot/build.py index 09580a2..d80ae14 100644 --- a/devbot/build.py +++ b/devbot/build.py @@ -96,12 +96,6 @@ def build_module(module): state.touch_built_commit_id(module) -def clear_built_modules(modules, index): - if index < len(modules) - 1: - for module in modules[index + 1:]: - if state.get_built_commit_id(module) is not None: - state.remove_built_commit_id(module) - def rmtree(dir): print "Deleting %s" % dir shutil.rmtree(dir, ignore_errors=True) @@ -130,16 +124,27 @@ def build(): environ.setup() modules = config.load_modules() + skipped = [] - for i, module in enumerate(modules): + for module in modules[:]: old_commit_id = state.get_built_commit_id(module) new_commit_id = module.get_commit_id() - if old_commit_id is None or old_commit_id != new_commit_id: - clear_built_modules(modules, i) - build_module(module) + if old_commit_id == new_commit_id: + modules.pop(0) + skipped.append(module.name) else: - print "\n* Already built, skipping *" + break + + if skipped: + print "\n* Skipping unchanged modules *\n" + print "\n".join(skipped) + + for module in modules: + state.remove_built_commit_id(module) + + for module in modules: + build_module(module) def clean(): rmtree(config.install_dir) diff --git a/devbot/config.py b/devbot/config.py index 0170196..2b748e6 100644 --- a/devbot/config.py +++ b/devbot/config.py @@ -47,7 +47,7 @@ class Module: return os.path.join(get_build_dir(), self.name) def get_commit_id(self): - return utils.get_commit_id(get_source_dir()) + return utils.get_commit_id(self.get_source_dir()) def _ensure_dir(dir): if not os.path.exists(dir): diff --git a/devbot/state.py b/devbot/state.py index 1eaf3ac..9bca7d2 100644 --- a/devbot/state.py +++ b/devbot/state.py @@ -30,8 +30,11 @@ def touch_built_commit_id(module): _state_changed() def remove_built_commit_id(module): - del _get_state()["built_modules"][module.name] - _state_changed() + state = _get_state() + + if module.name in state["built_modules"]: + del state["built_modules"][module.name] + _state_changed() def get_built_commit_id(module): return _get_state()["built_modules"].get(module.name, None) -- cgit v0.9.1