summaryrefslogtreecommitdiff
path: root/morphlib/plugins
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-11-06 17:06:38 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-11-12 16:48:18 +0000
commitcbaa45c1dccec5bc5e7fd1650a6a2f99638ee65e (patch)
treee7e89af59724bdc346861d8b764789e891dbe5bd /morphlib/plugins
parenta49db7757e2d2902989dc0601eda93557d1ee55c (diff)
downloadmorph-cbaa45c1dccec5bc5e7fd1650a6a2f99638ee65e.tar.gz
morph build: Use the user's own repos when building
This means that Morph no longer requires changes to be pushed in order to build them. The repos from the system branch are currently cached in the local repo cache as part of the build process, which is far from ideal. Tests for 'morph build' now test build without push. The build metadata now includes a repo path that is inside the TMPDIR, so the tests have been rewritten to avoid having any hardcoded cache keys because the cache keys are no longer static.
Diffstat (limited to 'morphlib/plugins')
-rw-r--r--morphlib/plugins/branch_and_merge_plugin.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py
index 97f49eb4..1e2f381d 100644
--- a/morphlib/plugins/branch_and_merge_plugin.py
+++ b/morphlib/plugins/branch_and_merge_plugin.py
@@ -1116,6 +1116,7 @@ class BranchAndMergePlugin(cliapp.Plugin):
'parameter: the system to build')
system_name = args[0]
+ push = False
# Deduce workspace and system branch and branch root repository.
workspace = self.deduce_workspace()
@@ -1143,21 +1144,25 @@ class BranchAndMergePlugin(cliapp.Plugin):
# Create the build refs for all these repositories and commit
# all uncommitted changes to them, updating all references
# to system branch refs to point to the build refs instead.
- self.update_build_refs(build_repos, branch, build_uuid)
+ self.update_build_refs(build_repos, branch, build_uuid, push)
- # Push the temporary build refs.
- self.push_build_refs(build_repos)
+ if push:
+ self.push_build_refs(build_repos)
+ build_branch_root = branch_root
+ else:
+ dirname = build_repos[branch_root]['dirname']
+ build_branch_root = urlparse.urljoin('file://', dirname)
# Run the build.
build_command = morphlib.buildcommand.BuildCommand(self.app)
build_command = self.app.hookmgr.call('new-build-command',
build_command)
- build_command.build([branch_root,
+ build_command.build([build_branch_root,
build_repos[branch_root]['build-ref'],
system_name])
- # Delete the temporary refs on the server.
- self.delete_remote_build_refs(build_repos)
+ if push:
+ self.delete_remote_build_refs(build_repos)
self.app.status(msg='Finished build %(uuid)s', uuid=build_uuid)
@@ -1212,7 +1217,7 @@ class BranchAndMergePlugin(cliapp.Plugin):
return build_repos
- def inject_build_refs(self, morphology, build_repos):
+ def inject_build_refs(self, morphology, build_repos, will_push):
# Starting from a system or stratum morphology, update all ref
# pointers of strata or chunks involved in a system build (represented
# by build_repos) to point to temporary build refs of the repos
@@ -1222,6 +1227,9 @@ class BranchAndMergePlugin(cliapp.Plugin):
info['morph'] in build_repos[info['repo']]['strata'] or
info['morph'] in build_repos[info['repo']]['chunks']):
info['ref'] = build_repos[info['repo']]['build-ref']
+ if not will_push:
+ dirname = build_repos[info['repo']]['dirname']
+ info['repo'] = urlparse.urljoin('file://', dirname)
if morphology['kind'] == 'system':
for info in morphology['strata']:
inject_build_ref(info)
@@ -1237,7 +1245,8 @@ class BranchAndMergePlugin(cliapp.Plugin):
branch_uuid, repo_uuid)
info['build-ref'] = build_ref
- def update_build_refs(self, build_repos, system_branch, build_uuid):
+ def update_build_refs(self, build_repos, system_branch, build_uuid,
+ will_push):
'''Update build branches for each repository with any local changes '''
# Define the committer.
@@ -1291,7 +1300,7 @@ class BranchAndMergePlugin(cliapp.Plugin):
for filename in filenames:
# Inject temporary refs in the right places in each morphology.
morphology = self.load_morphology(repo_dir, filename)
- self.inject_build_refs(morphology, build_repos)
+ self.inject_build_refs(morphology, build_repos, will_push)
handle, tmpfile = tempfile.mkstemp(suffix='.morph')
self.save_morphology(repo_dir, tmpfile, morphology)