diff options
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/app.py | 33 | ||||
-rw-r--r-- | morphlib/artifactresolver.py | 8 | ||||
-rw-r--r-- | morphlib/buildcommand.py | 4 | ||||
-rw-r--r-- | morphlib/morph2.py | 3 | ||||
-rw-r--r-- | morphlib/morphset.py | 8 | ||||
-rw-r--r-- | morphlib/plugins/branch_and_merge_new_plugin.py | 7 |
6 files changed, 50 insertions, 13 deletions
diff --git a/morphlib/app.py b/morphlib/app.py index 0890a786..a0833d45 100644 --- a/morphlib/app.py +++ b/morphlib/app.py @@ -318,11 +318,15 @@ class Morph(cliapp.Application): visit(reponame, ref, filename, absref, tree, morphology) if morphology['kind'] == 'system': - queue.extend((s['repo'], s['ref'], '%s.morph' % s['morph']) + queue.extend((s['repo'] or reponame, + s['ref'] or ref, + '%s.morph' % s['morph']) for s in morphology['strata']) elif morphology['kind'] == 'stratum': if morphology['build-depends']: - queue.extend((s['repo'], s['ref'], '%s.morph' % s['morph']) + queue.extend((s['repo'] or reponame, + s['ref'] or ref, + '%s.morph' % s['morph']) for s in morphology['build-depends']) queue.extend((c['repo'], c['ref'], '%s.morph' % c['morph']) for c in morphology['chunks']) @@ -418,3 +422,28 @@ class Morph(cliapp.Application): # run the command line return cliapp.Application.runcmd(self, argv, *args, **kwargs) + + # FIXME: This overrides a private method in cliapp. We need + # get cliapp to provide the necessary hooks to do this cleanly. + # As it is, this is a copy of the method in cliapp, with the + # single change that for subcommand helps, the formatting is + # not used. + def _help_helper(self, args, show_all): # pragma: no cover + try: + width = int(os.environ.get('COLUMNS', '78')) + except ValueError: + width = 78 + + fmt = cliapp.TextFormat(width=width) + + if args: + usage = self._format_usage_for(args[0]) + description = self._format_subcommand_help(args[0]) + text = '%s\n\n%s' % (usage, description) + else: + usage = self._format_usage(all=show_all) + description = fmt.format(self._format_description(all=show_all)) + text = '%s\n\n%s' % (usage, description) + + text = self.settings.progname.join(text.split('%prog')) + self.output.write(text) diff --git a/morphlib/artifactresolver.py b/morphlib/artifactresolver.py index 186d5357..17f038a2 100644 --- a/morphlib/artifactresolver.py +++ b/morphlib/artifactresolver.py @@ -155,8 +155,8 @@ class ArtifactResolver(object): for info in source.morphology['strata']: stratum_source = self._source_pool.lookup( - info['repo'], - info['ref'], + info['repo'] or source.repo_name, + info['ref'] or source.original_ref, '%s.morph' % info['morph']) stratum_name = stratum_source.morphology.builds_artifacts[0] @@ -178,8 +178,8 @@ class ArtifactResolver(object): if stratum.source.morphology['build-depends']: for stratum_info in stratum.source.morphology['build-depends']: other_source = self._source_pool.lookup( - stratum_info['repo'], - stratum_info['ref'], + stratum_info['repo'] or stratum.source.repo_name, + stratum_info['ref'] or stratum.source.original_ref, '%s.morph' % stratum_info['morph']) other_stratum = self._get_artifact( diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py index d7007233..e76b7a14 100644 --- a/morphlib/buildcommand.py +++ b/morphlib/buildcommand.py @@ -163,8 +163,8 @@ class BuildCommand(object): def _validate_cross_refs_for_xxx(self, src, srcpool, specs, wanted): for spec in specs: - repo_name = spec['repo'] - ref = spec['ref'] + repo_name = spec['repo'] or src.repo_name + ref = spec['ref'] or src.original_ref filename = '%s.morph' % spec['morph'] logging.debug( 'Validating cross ref to %s:%s:%s' % diff --git a/morphlib/morph2.py b/morphlib/morph2.py index a733ce77..6975e699 100644 --- a/morphlib/morph2.py +++ b/morphlib/morph2.py @@ -252,7 +252,8 @@ class Morphology(object): continue value = self._apply_changes_for_key(key, live_dict, original_dict) - if value is not None: + # VILE HACK to preserve nulls in repo/ref fields + if value is not None or key in ('repo', 'ref'): output_dict[key] = value return output_dict diff --git a/morphlib/morphset.py b/morphlib/morphset.py index 3c07d58e..9ef1e804 100644 --- a/morphlib/morphset.py +++ b/morphlib/morphset.py @@ -95,9 +95,11 @@ class MorphologySet(object): repo_url, ref, morph = self._find_spec( system_morph['strata'], stratum_name) - if repo_url is None: + if (repo_url, ref, morph) == (None, None, None): raise StratumNotInSystemError(system_morph['name'], stratum_name) - m = self._get_morphology(repo_url, ref, '%s.morph' % morph) + 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 @@ -118,7 +120,7 @@ class MorphologySet(object): repo_url, ref, morph = self._find_spec( stratum_morph['chunks'], chunk_name) - if repo_url is None: + if (repo_url, ref, morph) == (None, None, None): raise ChunkNotInStratumError(stratum_morph['name'], chunk_name) return repo_url, ref, morph diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py b/morphlib/plugins/branch_and_merge_new_plugin.py index 809699eb..3d0a71a5 100644 --- a/morphlib/plugins/branch_and_merge_new_plugin.py +++ b/morphlib/plugins/branch_and_merge_new_plugin.py @@ -281,7 +281,9 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin): # of triplets (repo url, ref, filename). return [ - (spec['repo'], spec['ref'], '%s.morph' % spec['morph']) + (spec['repo'] or morph.repo_url, + spec['ref'] or morph.ref, + '%s.morph' % spec['morph']) for spec in specs ] @@ -694,6 +696,9 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin): #TODO: Stop using app.resolve_ref def resolve_refs(morphs): for repo, ref in morphs.list_refs(): + # You can't resolve null refs, so don't attempt to. + if repo is None or ref is None: + continue # TODO: Handle refs that are only in workspace in general if (repo == sb.root_repository_url and ref == sb.system_branch_name): |