# HG changeset patch # User Sylvain Thénault # Date 1284368422 -7200 # Node ID e2aeb40d59832873842944f59020f0c663babd51 # Parent fc6d7a54bae20b32b651a711a81332f002fec2cf [migration] fix so that context modification are reflected on the currently executed migration script diff -r fc6d7a54bae2 -r e2aeb40d5983 migration.py --- a/migration.py Mon Sep 13 10:51:55 2010 +0200 +++ b/migration.py Mon Sep 13 11:00:22 2010 +0200 @@ -122,6 +122,7 @@ 'config': self.config, 'interactive_mode': interactive, } + self._context_stack = [] def __getattribute__(self, name): try: @@ -284,6 +285,11 @@ context[attr[4:]] = getattr(self, attr) return context + def update_context(self, key, value): + for context in self._context_stack: + context[key] = value + self.__context[key] = value + def cmd_process_script(self, migrscript, funcname=None, *args, **kwargs): """execute a migration script in interactive mode @@ -327,6 +333,7 @@ if not self.execscript_confirm(migrscript): return scriptlocals = self._create_context().copy() + self._context_stack.append(scriptlocals) if script_mode == 'python': if funcname is None: pyname = '__main__' @@ -352,6 +359,7 @@ import doctest doctest.testfile(migrscript, module_relative=False, optionflags=doctest.ELLIPSIS, globs=scriptlocals) + del self._context_stack[-1] def cmd_option_renamed(self, oldname, newname): """a configuration option has been renamed""" diff -r fc6d7a54bae2 -r e2aeb40d5983 server/migractions.py --- a/server/migractions.py Mon Sep 13 10:51:55 2010 +0200 +++ b/server/migractions.py Mon Sep 13 11:00:22 2010 +0200 @@ -657,7 +657,8 @@ newcubes_schema = self.config.load_schema(construction_mode='non-strict') # XXX we have to replace fs_schema, used in cmd_add_relation_type # etc. and fsschema of migration script contexts - self.fs_schema = self._create_context()['fsschema'] = newcubes_schema + self.fs_schema = newcubes_schema + self.update_context('fsschema', self.fs_schema) new = set() # execute pre-create files driver = self.repo.system_source.dbdriver