summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2014-06-18 16:08:01 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2014-07-07 09:21:22 +0000
commit839e5315f1e1111429af25cb05eeb250c00b86b8 (patch)
tree658dc78dca859442647165ccb0b52524c1fb706f
parent770a6cb434ac31238eb2eee526e235728ce07aff (diff)
downloadmorph-839e5315f1e1111429af25cb05eeb250c00b86b8.tar.gz
Remove code made vestigial from the `morph edit` rewrite
This was originally used by `morph edit`, but since we removed the need to run `morph edit system stratum` and could shorten it to `morph edit chunk`, this function is no longer used.
-rw-r--r--morphlib/morphset.py33
-rw-r--r--morphlib/morphset_tests.py23
-rw-r--r--morphlib/plugins/branch_and_merge_new_plugin.py64
3 files changed, 1 insertions, 119 deletions
diff --git a/morphlib/morphset.py b/morphlib/morphset.py
index dedbabd5..9f349db7 100644
--- a/morphlib/morphset.py
+++ b/morphlib/morphset.py
@@ -19,19 +19,6 @@
import morphlib
-class StratumNotInSystemError(morphlib.Error):
-
- def __init__(self, system_name, stratum_name):
- self.msg = (
- 'System %s does not contain %s' % (system_name, stratum_name))
-
-
-class StratumNotInSetError(morphlib.Error):
-
- def __init__(self, stratum_name):
- self.msg = 'Stratum %s is not in MorphologySet' % stratum_name
-
-
class ChunkNotInStratumError(morphlib.Error):
def __init__(self, stratum_name, chunk_name):
@@ -84,26 +71,6 @@ class MorphologySet(object):
return spec.get('repo'), spec.get('ref'), name
return None, None, None
- def get_stratum_in_system(self, system_morph, stratum_name):
- '''Return morphology for a stratum that is in a system.
-
- If the stratum is not in the system, raise StratumNotInSystemError.
- If the stratum morphology has not been added to the set,
- raise StratumNotInSetError.
-
- '''
-
- repo_url, ref, morph = self._find_spec(
- system_morph['strata'], stratum_name)
- if (repo_url, ref, morph) == (None, None, None):
- raise StratumNotInSystemError(system_morph['name'], stratum_name)
- m = self._get_morphology(repo_url or system_morph.repo_url,
- ref or system_morph.ref,
- '%s.morph' % morph)
- if m is None:
- raise StratumNotInSetError(stratum_name)
- return m
-
def get_chunk_triplet(self, stratum_morph, chunk_name):
'''Return the repo url, ref, morph name triplet for a chunk.
diff --git a/morphlib/morphset_tests.py b/morphlib/morphset_tests.py
index d6908844..03983419 100644
--- a/morphlib/morphset_tests.py
+++ b/morphlib/morphset_tests.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2013 Codethink Limited
+# Copyright (C) 2013, 2014 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -80,27 +80,6 @@ class MorphologySetTests(unittest.TestCase):
self.morphs.add_morphology(self.system)
self.assertEqual(self.morphs.morphologies, [self.system])
- def test_get_stratum_in_system(self):
- self.morphs.add_morphology(self.system)
- self.morphs.add_morphology(self.stratum)
- self.assertEqual(
- self.morphs.get_stratum_in_system(
- self.system, self.stratum['name']),
- self.stratum)
-
- def test_raises_stratum_not_in_system_error(self):
- self.morphs.add_morphology(self.system)
- self.morphs.add_morphology(self.stratum)
- self.assertRaises(
- morphlib.morphset.StratumNotInSystemError,
- self.morphs.get_stratum_in_system, self.system, 'unknown-stratum')
-
- def test_raises_stratum_not_in_set_error(self):
- self.morphs.add_morphology(self.system)
- self.assertRaises(
- morphlib.morphset.StratumNotInSetError,
- self.morphs.get_stratum_in_system, self.system, 'foo-stratum')
-
def test_get_chunk_triplet(self):
self.morphs.add_morphology(self.system)
self.morphs.add_morphology(self.stratum)
diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py b/morphlib/plugins/branch_and_merge_new_plugin.py
index 5ac8353a..d6556b7b 100644
--- a/morphlib/plugins/branch_and_merge_new_plugin.py
+++ b/morphlib/plugins/branch_and_merge_new_plugin.py
@@ -274,29 +274,6 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin):
morph.dirty = False
logging.debug('Saving dirty morphologies: done')
- def _get_stratum_triplets(self, morph):
- # Gather all references to other strata from a morphology. The
- # morphology must be either a system or a stratum one. In a
- # stratum one, the refs are all for build dependencies of the
- # stratum. In a system one, they're the list of strata in the
- # system.
-
- assert morph['kind'] in ('system', 'stratum')
- if morph['kind'] == 'system':
- specs = morph.get('strata', [])
- elif morph['kind'] == 'stratum':
- specs = morph.get('build-depends', [])
-
- # Given a list of dicts that reference strata, return a list
- # of triplets (repo url, ref, filename).
-
- return [
- (spec.get('repo') or morph.repo_url,
- spec.get('ref') or morph.ref,
- '%s.morph' % spec['morph'])
- for spec in specs
- ]
-
def _checkout(self, lrc, sb, repo_url, ref):
logging.debug(
'Checking out %s (%s) into %s' %
@@ -317,47 +294,6 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin):
text = gd.get_file_from_ref('origin/%s' % ref, filename)
return loader.load_from_string(text, filename)
- def _load_stratum_morphologies(self, loader, sb, system_morph):
- logging.debug('Starting to load strata for %s' % system_morph.filename)
- lrc, rrc = morphlib.util.new_repo_caches(self.app)
- morphset = morphlib.morphset.MorphologySet()
- queue = self._get_stratum_triplets(system_morph)
- while queue:
- repo_url, ref, filename = queue.pop()
- if not morphset.has(repo_url, ref, filename):
- logging.debug('Loading: %s %s %s' % (repo_url, ref, filename))
- dirname = sb.get_git_directory_name(repo_url)
-
- # Get the right morphology. The right ref might not be
- # checked out, in which case we get the file from git.
- # However, if it is checked out, we get it from the
- # filesystem directly, in case the user has made any
- # changes to it. If the entire repo hasn't been checked
- # out yet, do that first.
-
- if not os.path.exists(dirname):
- self._checkout(lrc, sb, repo_url, ref)
- m = self._load_morphology_from_file(
- loader, dirname, filename)
- else:
- gd = morphlib.gitdir.GitDirectory(dirname)
- if gd.is_currently_checked_out(ref):
- m = self._load_morphology_from_file(
- loader, dirname, filename)
- else:
- m = self._load_morphology_from_git(
- loader, gd, ref, filename)
-
- m.repo_url = repo_url
- m.ref = ref
- m.filename = filename
-
- morphset.add_morphology(m)
- queue.extend(self._get_stratum_triplets(m))
-
- logging.debug('All strata loaded')
- return morphset
-
def edit(self, args):
'''Edit or checkout a component in a system branch.