summaryrefslogtreecommitdiff
path: root/morphlib/buildbranch.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-07-30 18:47:43 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-09-17 10:02:54 +0000
commitb548e0e5094b1bfdc6f9242c4f26ce191c7b8aad (patch)
tree916458a7c99570ba802329182f745663c05987a5 /morphlib/buildbranch.py
parent07df32fbd57477e5808cdbace965edcd0a81348f (diff)
downloadmorph-b548e0e5094b1bfdc6f9242c4f26ce191c7b8aad.tar.gz
Change how MorphologyLoader instances are created
Loading .morph files is becoming a bit more complicated, as we need to deal with the VERSION file, and possibly soon with a DEFAULTS file as well. The logic of loading and parsing .morph files is done either in the sourceresolver module, or the morphloader module. This change means that all users of the latter module can use the get hold of a MorphologyLoader instance with VERSION already parsed. If DEFAULTS is added then it is also simple to parse DEFAULTS. Change-Id: Ib33756e9dbd078e38f12dd7f776c89584b178959
Diffstat (limited to 'morphlib/buildbranch.py')
-rw-r--r--morphlib/buildbranch.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/morphlib/buildbranch.py b/morphlib/buildbranch.py
index e16bf2b4..6cec97fb 100644
--- a/morphlib/buildbranch.py
+++ b/morphlib/buildbranch.py
@@ -159,27 +159,31 @@ class BuildBranch(object):
sha1 = gd.store_blob(loader.save_to_string(morphology))
yield 0o100644, sha1, morphology.filename
+ def get_morphology_loader(self):
+ if self._sb:
+ return self._sb.get_morphology_loader()
+ else:
+ return self._root.get_morphology_loader()
+
def load_all_morphologies(self, loader):
if self._sb:
- return self._sb.load_all_morphologies(loader)
+ return self._sb.load_all_morphologies()
else:
- return self._root.load_all_morphologies(loader)
+ return self._root.load_all_morphologies()
- def inject_build_refs(self, loader, use_local_repos,
- inject_cb=lambda **kwargs: None):
+ def inject_build_refs(self, use_local_repos, inject_cb=lambda **kwargs:
+ None):
'''Update system and stratum morphologies to point to our branch.
For all edited repositories, this alter the temporary GitIndex
of the morphs repositories to point their temporary build branch
versions.
- `loader` is a MorphologyLoader that is used to convert morphology
- files into their in-memory representations and back again.
-
'''
root_repo = self._root.remote_url
root_ref = self._root.HEAD
morphs = morphlib.morphset.MorphologySet()
+ loader = self.get_morphology_loader()
for morph in self.load_all_morphologies(loader):
morphs.add_morphology(morph)
@@ -362,7 +366,7 @@ class BuildBranch(object):
@contextlib.contextmanager
-def pushed_build_branch(bb, loader, changes_need_pushing, name, email,
+def pushed_build_branch(bb, changes_need_pushing, name, email,
build_uuid, status):
with contextlib.closing(bb) as bb:
def report_add(gd, build_ref, changed):
@@ -385,8 +389,7 @@ def pushed_build_branch(bb, loader, changes_need_pushing, name, email,
status(msg='Injecting temporary build refs '\
'into morphologies in %(dirname)s',
dirname=gd.dirname, chatty=True)
- bb.inject_build_refs(loader=loader,
- use_local_repos=not changes_need_pushing,
+ bb.inject_build_refs(use_local_repos=not changes_need_pushing,
inject_cb=report_inject)
def report_commit(gd, build_ref):