diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-01-19 15:32:58 +0000 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-01-20 18:31:51 +0000 |
commit | c73ca82e0c67ba3d05f47f61766f8838d0e9d8d4 (patch) | |
tree | fb3fb2f063af4167da1c287d67e4ae2d818e7748 /morphlib/morphology.py | |
parent | 55751d6de5927c3bbcdd21321f7c3a6655e87a76 (diff) | |
download | morph-c73ca82e0c67ba3d05f47f61766f8838d0e9d8d4.tar.gz |
Port everything to using Treeish objects instead of (repo, ref).
This affects pretty much every part of morph, so this might not be fully
working and stable yet.
This commit also introduces the "update-gits" command that can be used
to update all cached repositories from the list of base URLs. The tree
walk when resolving the Treeish objects in Builder.get_cache_id() is a
bit similar to what we do in BuildDependencyGraph, maybe we can merge
that one day.
Diffstat (limited to 'morphlib/morphology.py')
-rw-r--r-- | morphlib/morphology.py | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/morphlib/morphology.py b/morphlib/morphology.py index c530824c..9f9fa06b 100644 --- a/morphlib/morphology.py +++ b/morphlib/morphology.py @@ -23,30 +23,28 @@ class Morphology(object): '''Represent a morphology: description of how to build binaries.''' - def __init__(self, repo, ref, fp, baseurl=None): - self.repo = repo - self.ref = ref + def __init__(self, treeish, fp): + self.treeish = treeish + self.filename = fp.name self._fp = fp - self._baseurl = baseurl or '' self._load() def _load(self): - logging.debug('Loading morphology %s' % self._fp.name) + logging.debug('Loading morphology %s from %s' % + (self._fp.name, self.treeish)) try: self._dict = json.load(self._fp) except ValueError: - logging.error('Failed to load morphology %s' % self._fp.name) + logging.error('Failed to load morphology %s from %s' % + (self._fp.name, self.treeish)) raise if self.kind == 'stratum': for source in self.sources: if 'repo' not in source: source[u'repo'] = source['name'] - repo = self._join_with_baseurl(source['repo']) - source[u'repo'] = unicode(repo) - - self.filename = self._fp.name + source[u'repo'] = unicode(source['repo']) @property def name(self): @@ -110,20 +108,7 @@ class Morphology(object): def test_stories(self): return self._dict.get('test-stories', []) - def _join_with_baseurl(self, url): - is_relative = (':' not in url or - '/' not in url or - url.find('/') < url.find(':')) - if is_relative: - if not url.endswith('/'): - url += '/' - baseurl = self._baseurl - if baseurl and not baseurl.endswith('/'): - baseurl += '/' - return baseurl + url - else: - return url - def __str__(self): # pragma: no cover - return '%s|%s|%s' % (os.path.basename(os.path.dirname(self.repo)), - self.ref, os.path.basename(self.filename)) + return '%s|%s|%s' % (self.treeish.original_repo, + self.treeish.ref, + os.path.basename(self.filename)) |