From dc16450fa37c715a81b61213ade807734b404914 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 7 Jul 2014 13:12:00 +0000 Subject: Make MorphologyFinder use file paths We want to use file paths to locate morphologies now, so the old model of get a list of names and hand it those back to get the contents doesn't really make sense any more. This abstraction initially came about as one idea I had for moving morphologies out of the source tree was to put them in something like git notes, where it's possible to look up information for one commit in another ref in the repository, at which point this abstraction would have been flexible enough to handle that as well as in the However, moving the chunk morphologies into the definitions repository has other benefits too, so it makes more sense to be honest about using filenames in the API. It remains as a single point where we can put the logic for knowing which files in a repository look like morphologies, but if we need to remove any further functionality, it should be replaced by a single function. --- morphlib/plugins/deploy_plugin.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'morphlib/plugins/deploy_plugin.py') diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py index 6fc0998c..7c009071 100644 --- a/morphlib/plugins/deploy_plugin.py +++ b/morphlib/plugins/deploy_plugin.py @@ -292,11 +292,10 @@ class DeployPlugin(cliapp.Plugin): name = morphlib.git.get_user_name(self.app.runcmd) email = morphlib.git.get_user_email(self.app.runcmd) build_ref_prefix = self.app.settings['build-ref-prefix'] - root_repo_dir = morphlib.gitdir.GitDirectory( sb.get_git_directory_name(sb.root_repository_url)) - mf = morphlib.morphologyfinder.MorphologyFinder(root_repo_dir) - cluster_text, cluster_filename = mf.read_morphology(cluster_name) + cluster_filename = cluster_name + '.morph' + cluster_text = root_repo_dir.read_file(cluster_filename) cluster_morphology = loader.load_from_string(cluster_text, filename=cluster_filename) -- cgit v1.2.1 From 3dc83847b8f17793bdab5e978d13d394b48987b0 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Tue, 17 Jun 2014 16:36:07 +0000 Subject: Use exact filenames to refer to morphology files Rather than repeatedly stripping and appending an optional .morph extension morphology names, instead always use the file path of the morphology relative to the definitions repository. This is an inversion of the previous logic, which would strip the .morph extension and use the "name" internally. The exception to this rule of always using the filename, is that `morph edit CHUNK` uses the name of the morphology as-defined in the stratum. This is based off Adam Coldrick's inital patch, but this version will allow the old style of providing the "name" by converting it into a path if it does not have either a / or a . in it. An unfortunate consequence of this change is that the show-dependencies command's output changed, so the test needed updating. --- morphlib/plugins/deploy_plugin.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'morphlib/plugins/deploy_plugin.py') diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py index 7c009071..9384c422 100644 --- a/morphlib/plugins/deploy_plugin.py +++ b/morphlib/plugins/deploy_plugin.py @@ -99,7 +99,7 @@ class DeployPlugin(cliapp.Plugin): name: cluster-foo kind: cluster systems: - - morph: devel-system-x86_64-generic + - morph: devel-system-x86_64-generic.morph deploy: cluster-foo-x86_64-1: type: kvm @@ -278,7 +278,7 @@ class DeployPlugin(cliapp.Plugin): '/', 0) self.app.settings['no-git-update'] = True - cluster_name = morphlib.util.strip_morph_extension(args[0]) + cluster_filename = morphlib.util.sanitise_morphology_path(args[0]) ws = morphlib.workspace.open('.') sb = morphlib.sysbranchdir.open_from_within('.') @@ -294,7 +294,6 @@ class DeployPlugin(cliapp.Plugin): build_ref_prefix = self.app.settings['build-ref-prefix'] root_repo_dir = morphlib.gitdir.GitDirectory( sb.get_git_directory_name(sb.root_repository_url)) - cluster_filename = cluster_name + '.morph' cluster_text = root_repo_dir.read_file(cluster_filename) cluster_morphology = loader.load_from_string(cluster_text, filename=cluster_filename) @@ -387,9 +386,8 @@ class DeployPlugin(cliapp.Plugin): self.app.status_prefix = system_status_prefix try: # Find the artifact to build - morph = system['morph'] - srcpool = build_command.create_source_pool(build_repo, ref, - morph + '.morph') + morph = morphlib.util.sanitise_morphology_path(system['morph']) + srcpool = build_command.create_source_pool(build_repo, ref, morph) artifact = build_command.resolve_artifacts(srcpool) -- cgit v1.2.1