summaryrefslogtreecommitdiff
path: root/morphlib/sysbranchdir.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-11-22 13:44:15 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-11-29 16:11:32 +0000
commitb38e47f413c6651c8953d2bebd99ae0bb80c07f9 (patch)
tree4cf05a84653e4f4ee1f42a983e3f92d80a086425 /morphlib/sysbranchdir.py
parent21d7299e927696c2536e2170f77eef9b25f80172 (diff)
downloadmorph-b38e47f413c6651c8953d2bebd99ae0bb80c07f9.tar.gz
sysbranchdir: Move load_all_morphologies helper here
This was previously a private method of the branch and merge plugin, but it's useful to other plugins, so has been moved to the SystemBranchDirectory class, where everything else can get to it. It has an unpleasant amount of coupling to other classes, but in a *good* object oriented design it would either be a tiny module on its own, or not exist and leave all its users to re-implement the same logic multiple ways, so we've opted for a less clean, but more useful design. It is left un-covered by the unit tests, since it requires a great deal of instrumentation to test, at which point it may be best to leave it to integration tests.
Diffstat (limited to 'morphlib/sysbranchdir.py')
-rw-r--r--morphlib/sysbranchdir.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/morphlib/sysbranchdir.py b/morphlib/sysbranchdir.py
index 73a07d5e..1a8b898a 100644
--- a/morphlib/sysbranchdir.py
+++ b/morphlib/sysbranchdir.py
@@ -161,6 +161,20 @@ class SystemBranchDirectory(object):
for dirname in
morphlib.util.find_leaves(self.root_directory, '.git'))
+ # Not covered by unit tests, since testing the functionality spans
+ # multiple modules and only tests useful output with a full system
+ # branch, so it is instead covered by integration tests.
+ def load_all_morphologies(self, loader): # pragma: no cover
+ gd_name = self.get_git_directory_name(self.root_repository_url)
+ gd = morphlib.gitdir.GitDirectory(gd_name)
+ 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.repo_url = self.root_repository_url
+ m.ref = self.system_branch_name
+ yield m
+
def create(root_directory, root_repository_url, system_branch_name):
'''Create a new system branch directory on disk.