diff options
author | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2015-01-14 16:06:53 +0000 |
---|---|---|
committer | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2015-01-14 16:06:53 +0000 |
commit | 8f32749511f4cab0ac1c6d74025fc1b21578996c (patch) | |
tree | f6cc78d83f1a7b5c330b8a54732c2ee84191f34a /baserockimport/mainloop.py | |
parent | b092a66c21cb977a872d2b45d8edec31d96eeb28 (diff) | |
parent | 8d0448d044f20a148f98700a691a83c95308a8e8 (diff) | |
download | import-8f32749511f4cab0ac1c6d74025fc1b21578996c.tar.gz |
Merge branch 'baserock/richardipsum/fix-lorry-bug-3'
Reviewed by:
Sam Thursfield <sam.thursfield@codethink.co.uk>
Diffstat (limited to 'baserockimport/mainloop.py')
-rw-r--r-- | baserockimport/mainloop.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/baserockimport/mainloop.py b/baserockimport/mainloop.py index 057ab98..8a7ae26 100644 --- a/baserockimport/mainloop.py +++ b/baserockimport/mainloop.py @@ -202,7 +202,7 @@ class ImportLoop(object): # 1. Make the source code available. - lorry = self._find_or_create_lorry_file(kind, name) + lorry = self._find_or_create_lorry_file(kind, name, version) source_repo, url = self._fetch_or_update_source(lorry) checked_out_version, ref = self._checkout_source_version_for_package( @@ -288,15 +288,22 @@ class ImportLoop(object): dep_package.set_is_build_dep(True) processed.add_edge(dep_package, current_item) - def _find_or_create_lorry_file(self, kind, name): + def _find_or_create_lorry_file(self, kind, name, version): # Note that the lorry file may already exist for 'name', but lorry # files are named for project name rather than package name. In this # case we will generate the lorry, and try to add it to the set, at # which point LorrySet will notice the existing one and merge the two. - lorry = self.lorry_set.find_lorry_for_package(kind, name) + comp = None + + if 'package_comp_callback' in self.importers[kind]['kwargs']: + comp = self.importers[kind]['kwargs']['package_comp_callback'] + else: + comp = lambda x, y: x == y + + lorry = self.lorry_set.find_lorry_for_package(kind, name, comp) if lorry is None: - lorry = self._generate_lorry_for_package(kind, name) + lorry = self._generate_lorry_for_package(kind, name, version) if len(lorry) != 1: raise Exception( @@ -323,14 +330,18 @@ class ImportLoop(object): return lorry - def _generate_lorry_for_package(self, kind, name): + def _generate_lorry_for_package(self, kind, name, version): tool = '%s.to_lorry' % kind if kind not in self.importers: raise Exception('Importer for %s was not enabled.' % kind) extra_args = self.importers[kind]['extra_args'] self.app.status( '%s: calling %s to generate lorry', name, tool) - lorry_text = run_extension(tool, extra_args + [name]) + + args = extra_args + [name] + if version != 'master': + args.append(version) + lorry_text = run_extension(tool, args) try: lorry = json.loads(lorry_text) except ValueError: |