summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2014-05-23 09:57:54 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2014-06-11 12:49:25 +0000
commit6513aaa1202602873ad00f0b13ed341e21ca8f25 (patch)
tree7df88b046a398608348f28b2e68148c4781f8ffc
parent13edeabd929b094ab2ec7288840e62d31d9feb67 (diff)
downloadmorph-6513aaa1202602873ad00f0b13ed341e21ca8f25.tar.gz
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.
-rw-r--r--morphlib/buildbranch.py6
-rw-r--r--morphlib/plugins/branch_and_merge_new_plugin.py4
-rw-r--r--morphlib/sysbranchdir.py4
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
@@ -266,6 +266,10 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin):
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))
loader.unset_defaults(morph)
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