diff options
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/morph2.py | 3 | ||||
-rw-r--r-- | morphlib/source.py | 4 | ||||
-rw-r--r-- | morphlib/source_tests.py | 14 | ||||
-rw-r--r-- | morphlib/sourcepool.py | 10 | ||||
-rw-r--r-- | morphlib/sourcepool_tests.py | 5 |
5 files changed, 23 insertions, 13 deletions
diff --git a/morphlib/morph2.py b/morphlib/morph2.py index 717d855c..dbbf0c68 100644 --- a/morphlib/morph2.py +++ b/morphlib/morph2.py @@ -32,9 +32,10 @@ class Morphology(object): ('test-commands', []), ('install-commands', []), ('sources', []), + ('strata', []), ('max-jobs', None), ('description', ''), - ('build-depends', []), + ('build-depends', None), ('build-system', 'manual'), ] diff --git a/morphlib/source.py b/morphlib/source.py index 33549df4..cfcd320b 100644 --- a/morphlib/source.py +++ b/morphlib/source.py @@ -24,6 +24,7 @@ class Source(object): Has the following properties: * ``repo`` -- the git repository which contains the source + * ``original_ref`` -- the git ref provided by the user or a morphology * ``sha1`` -- the absolute git commit id for the revision we use * ``morphology`` -- the in-memory representation of the morphology we use * ``filename`` -- basename of the morphology filename @@ -35,9 +36,10 @@ class Source(object): ''' - def __init__(self, repo, sha1, morphology, filename): + def __init__(self, repo, original_ref, sha1, morphology, filename): assert type(morphology) == morphlib.morph2.Morphology self.repo = repo + self.original_ref = original_ref self.sha1 = sha1 self.morphology = morphology self.filename = filename diff --git a/morphlib/source_tests.py b/morphlib/source_tests.py index f9999ca0..3a396c63 100644 --- a/morphlib/source_tests.py +++ b/morphlib/source_tests.py @@ -30,17 +30,23 @@ class SourceTests(unittest.TestCase): def setUp(self): self.repo = 'foo.repo' + self.original_ref = 'original/ref' self.sha1 = 'CAFEF00D' self.morphology = morphlib.morph2.Morphology(self.morphology_text) self.filename = 'foo.morph' - self.source = morphlib.source.Source(self.repo, self.sha1, - self.morphology, self.filename) - self.other = morphlib.source.Source(self.repo, self.sha1, - self.morphology, self.filename) + self.source = morphlib.source.Source(self.repo, self.original_ref, + self.sha1, self.morphology, + self.filename) + self.other = morphlib.source.Source(self.repo, self.original_ref, + self.sha1, self.morphology, + self.filename) def test_sets_repo(self): self.assertEqual(self.source.repo, self.repo) + def test_sets_original_ref(self): + self.assertEqual(self.source.original_ref, self.original_ref) + def test_sets_sha1(self): self.assertEqual(self.source.sha1, self.sha1) diff --git a/morphlib/sourcepool.py b/morphlib/sourcepool.py index 449d7757..fe6bf9e9 100644 --- a/morphlib/sourcepool.py +++ b/morphlib/sourcepool.py @@ -22,23 +22,23 @@ class SourcePool(object): self._sources = {} self._order = [] - def _key(self, repo, sha1, filename): - return (repo, sha1, filename) + def _key(self, repo, original_ref, filename): + return (repo, original_ref, filename) def add(self, source): '''Add a source to the pool.''' - key = self._key(source.repo, source.sha1, source.filename) + key = self._key(source.repo, source.original_ref, source.filename) self._sources[key] = source self._order.append(source) - def lookup(self, repo, sha1, filename): + def lookup(self, repo, original_ref, filename): '''Find a source in the pool. Raise KeyError if it is not found. ''' - key = self._key(repo, sha1, filename) + key = self._key(repo, original_ref, filename) return self._sources[key] def __iter__(self): diff --git a/morphlib/sourcepool_tests.py b/morphlib/sourcepool_tests.py index 35a94b39..5ed5be4d 100644 --- a/morphlib/sourcepool_tests.py +++ b/morphlib/sourcepool_tests.py @@ -23,6 +23,7 @@ class DummySource(object): def __init__(self): self.repo = 'dummy.repo' + self.original_ref = 'original/ref' self.sha1 = 'dummy.sha1' self.filename = 'dummy.morph' self.morphology = {} @@ -46,13 +47,13 @@ class SourcePoolTests(unittest.TestCase): def test_looks_up_source(self): self.pool.add(self.source) - result = self.pool.lookup(self.source.repo, self.source.sha1, + result = self.pool.lookup(self.source.repo, self.source.original_ref, self.source.filename) self.assertEqual(result, self.source) def test_lookup_raises_keyerror_if_not_found(self): self.assertRaises(KeyError, self.pool.lookup, self.source.repo, - self.source.sha1, self.source.filename) + self.source.original_ref, self.source.filename) def test_iterates_in_add_order(self): sources = [] |