mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 22:11:44 -07:00
Attempt 4: Prevent reparenting a block with itself (#38747)
* More concisely reparent, ensuring we don't go too shallow or too deep in this process. Fixes #38357 * More explicit reparenting, with a short circuit for a common case * We need new_block to have a parent, otherwise we lose context with this approach * Remove duplicate parent assignment * Change callers of Block.copy to not use exclude_parent=True, when including the parent, exclude tasks
This commit is contained in:
parent
d2ce1d3c26
commit
f474195a3b
3 changed files with 18 additions and 21 deletions
|
@ -524,7 +524,7 @@ class PlayIterator:
|
|||
if state.tasks_child_state:
|
||||
state.tasks_child_state = self._insert_tasks_into_state(state.tasks_child_state, task_list)
|
||||
else:
|
||||
target_block = state._blocks[state.cur_block].copy(exclude_parent=True)
|
||||
target_block = state._blocks[state.cur_block].copy()
|
||||
before = target_block.block[:state.cur_regular_task]
|
||||
after = target_block.block[state.cur_regular_task:]
|
||||
target_block.block = before + task_list + after
|
||||
|
@ -533,7 +533,7 @@ class PlayIterator:
|
|||
if state.rescue_child_state:
|
||||
state.rescue_child_state = self._insert_tasks_into_state(state.rescue_child_state, task_list)
|
||||
else:
|
||||
target_block = state._blocks[state.cur_block].copy(exclude_parent=True)
|
||||
target_block = state._blocks[state.cur_block].copy()
|
||||
before = target_block.rescue[:state.cur_rescue_task]
|
||||
after = target_block.rescue[state.cur_rescue_task:]
|
||||
target_block.rescue = before + task_list + after
|
||||
|
@ -542,7 +542,7 @@ class PlayIterator:
|
|||
if state.always_child_state:
|
||||
state.always_child_state = self._insert_tasks_into_state(state.always_child_state, task_list)
|
||||
else:
|
||||
target_block = state._blocks[state.cur_block].copy(exclude_parent=True)
|
||||
target_block = state._blocks[state.cur_block].copy()
|
||||
before = target_block.always[:state.cur_always_task]
|
||||
after = target_block.always[state.cur_always_task:]
|
||||
target_block.always = before + task_list + after
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue