recursive requirements are detected now

This commit is contained in:
gwen 2012-07-26 10:54:57 +02:00
parent 323663385b
commit c9bc9f3823
3 changed files with 16 additions and 1 deletions

View File

@ -395,6 +395,15 @@ class Config(object):
self = self._cfgimpl_parent self = self._cfgimpl_parent
return self return self
def _cfgimpl_get_path(self):
subpath = []
obj = self
while obj._cfgimpl_parent is not None:
subpath.insert(0, obj._cfgimpl_descr._name)
obj = obj._cfgimpl_parent
return ".".join(subpath)
def cfgimpl_previous_value(self, path): def cfgimpl_previous_value(self, path):
home, name = self._cfgimpl_get_home_by_path(path) home, name = self._cfgimpl_get_home_by_path(path)
return home._cfgimpl_previous_values[name] return home._cfgimpl_previous_values[name]

View File

@ -16,6 +16,8 @@ class MethodCallError(Exception):
pass pass
class RequiresError(Exception): class RequiresError(Exception):
pass pass
class RequirementRecursionError(RequiresError):
pass
class MandatoryError(Exception): class MandatoryError(Exception):
pass pass
class SpecialOwnersError(Exception): class SpecialOwnersError(Exception):

View File

@ -23,7 +23,7 @@
from tiramisu.autolib import special_owners from tiramisu.autolib import special_owners
from tiramisu.basetype import HiddenBaseType, DisabledBaseType, ModeBaseType, modes from tiramisu.basetype import HiddenBaseType, DisabledBaseType, ModeBaseType, modes
from tiramisu.error import (ConfigError, ConflictConfigError, NotFoundError, from tiramisu.error import (ConfigError, ConflictConfigError, NotFoundError,
SpecialOwnersError, RequiresError) SpecialOwnersError, RequiresError, RequirementRecursionError)
available_actions = ['hide', 'show', 'enable', 'disable'] available_actions = ['hide', 'show', 'enable', 'disable']
reverse_actions = {'hide': 'show', 'show': 'hide', reverse_actions = {'hide': 'show', 'show': 'hide',
'disable':'enable', 'enable': 'disable'} 'disable':'enable', 'enable': 'disable'}
@ -498,6 +498,10 @@ def apply_requires(opt, config):
name, expected, action, inverted = req name, expected, action, inverted = req
if inverted == 'inverted': if inverted == 'inverted':
inverted = True inverted = True
path = config._cfgimpl_get_path() + '.' + opt._name
if name.startswith(path):
raise RequirementRecursionError("malformed requirements imbrication "
"detected for option: '{0}' with requirement on: '{1}'".format(path, name))
homeconfig, shortname = \ homeconfig, shortname = \
rootconfig._cfgimpl_get_home_by_path(name) rootconfig._cfgimpl_get_home_by_path(name)
# FIXME: doesn't work with 'auto' or 'fill' yet # FIXME: doesn't work with 'auto' or 'fill' yet