~rogpeppe/juju-deployer/speed-up-inheritance

« back to all changes in this revision

Viewing changes to deployer/config.py

  • Committer: rogpeppe
  • Date: 2017-03-17 13:52:21 UTC
  • Revision ID: roger.peppe@canonical.com-20170317135221-437750xlb3m3uiem
add a test for the inheritance infinite loop

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
    def _resolve_inherited(self, deploy_data):
110
110
        if 'inherits' not in deploy_data:
111
111
            return deploy_data
112
 
        parents = self._inherits(deploy_data)
113
 
        inherits = list(parents)
114
 
        for parent_name in parents:
 
112
            
 
113
        inherits = self._inherits(deploy_data)
 
114
        # note: clone the inherits list because otherwise
 
115
        # we modify it as we iterate, which can lead to an
 
116
        # infinite loop.
 
117
        for parent_name in inherits[:]:
115
118
            parent = self.get(parent_name)
116
119
            inherits.extend(self._inherits(parent.data))
117
120
            deploy_data = dict_merge(parent.data, deploy_data)
118
 
 
 
121
        
119
122
        deploy_data['inherits'] = inherits
120
123
        return deploy_data
121
124