summaryrefslogtreecommitdiff
path: root/morphlib/sourcepool.py
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-04-11 13:15:31 +0100
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-04-11 13:42:57 +0100
commit5afd3d7ce64b762acb228f7f6b4f0326d030807b (patch)
tree75996c6ca35f742fdec74e300bce2662c3c7abcf /morphlib/sourcepool.py
parentd1f60363d74a579ee8eee22e0b03494d63dee830 (diff)
downloadmorph-5afd3d7ce64b762acb228f7f6b4f0326d030807b.tar.gz
Add original_ref member to Source. Default to None for build-depends.
We will almost always want to look up sources based on the data we find in morphologies (e.g. chunk sources found in a stratum or strata found in a system). For that we need to remember the original_ref in addition to the resolved SHA1 and look up sources using this original ref. The original ref is therefore also used as part of the hash key in SourcePool now.
Diffstat (limited to 'morphlib/sourcepool.py')
-rw-r--r--morphlib/sourcepool.py10
1 files changed, 5 insertions, 5 deletions
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):