- (env, node_list_pre, node_list_post) = self._BuildEnv(phase)
- if nodes is None:
- if phase == constants.HOOKS_PHASE_PRE:
- self.pre_nodes = (node_list_pre, node_list_post)
- nodes = node_list_pre
- elif phase == constants.HOOKS_PHASE_POST:
- post_nodes = (node_list_pre, node_list_post)
- assert self.pre_nodes == post_nodes, \
- ("Node lists returned for post-phase hook don't match pre-phase"
- " lists (pre %s, post %s)" % (self.pre_nodes, post_nodes))
- nodes = node_list_post
- else:
- raise AssertionError("Unknown phase '%s'" % phase)
+ if phase == constants.HOOKS_PHASE_PRE:
+ if nodes is None:
+ nodes = self.pre_nodes
+ env = self.pre_env
+ elif phase == constants.HOOKS_PHASE_POST:
+ if nodes is None:
+ nodes = self.post_nodes
+ env = self._BuildEnv(phase)
+ else:
+ raise AssertionError("Unknown phase '%s'" % phase)