From 6513aaa1202602873ad00f0b13ed341e21ca8f25 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Fri, 23 May 2014 09:57:54 +0000 Subject: Don't validate when loading all morphologies Currently, all morphologies in the definitions repo are validated when we create a build branch, and when we load all of the morphologies for traversal to change refs when using morph edit. This commit stops the morphologies from being validated on load, and instead validates only the morphologies that have been affected by whatever was happening. --- morphlib/buildbranch.py | 6 +++++- morphlib/plugins/branch_and_merge_new_plugin.py | 4 ++++ morphlib/sysbranchdir.py | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/morphlib/buildbranch.py b/morphlib/buildbranch.py index d415e7e1..1b028cc3 100644 --- a/morphlib/buildbranch.py +++ b/morphlib/buildbranch.py @@ -140,7 +140,11 @@ class BuildBranch(object): morphs.traverse_specs(process, filter) - if any(m.dirty for m in morphs.morphologies): + dirtied = [m for m in morphs.morphologies if m.dirty] + + if dirtied: + for morph in dirtied: + loader.validate(morph) yield self._root self._root_index.add_files_from_index_info( diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py b/morphlib/plugins/branch_and_merge_new_plugin.py index 5ac8353a..4dd7cf6a 100644 --- a/morphlib/plugins/branch_and_merge_new_plugin.py +++ b/morphlib/plugins/branch_and_merge_new_plugin.py @@ -265,6 +265,10 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin): logging.debug('Saving dirty morphologies: start') for morph in morphs: if morph.dirty: + logging.debug( + 'Validating morphology: %s %s %s' % + (morph.repo_url, morph.ref, morph.filename)) + loader.validate(morph) logging.debug( 'Saving morphology: %s %s %s' % (morph.repo_url, morph.ref, morph.filename)) diff --git a/morphlib/sysbranchdir.py b/morphlib/sysbranchdir.py index 9d96e974..23b54eb9 100644 --- a/morphlib/sysbranchdir.py +++ b/morphlib/sysbranchdir.py @@ -178,7 +178,9 @@ class SystemBranchDirectory(object): mf = morphlib.morphologyfinder.MorphologyFinder(gd) for morph in mf.list_morphologies(): text, filename = mf.read_morphology(morph) - m = loader.load_from_string(text, filename=filename) + m = loader.parse_morphology_text(text, filename) + loader.set_defaults(m) + m.filename = filename m.repo_url = self.root_repository_url m.ref = self.system_branch_name yield m -- cgit v1.2.1