[FIX] runbot_merge: _schedule_fp_followup not handling multiple batches

`_schedule_fp_followup` correctly iterates on `self`, however some of
the per-iteration work did not handle that correctly, and would try to
access fields on `self`.

Thankfully in most cases it only works on one batch at a time
anyway, *however* if multiple PRs share a HEAD (which is weird but...)
then `_validate` is called on multiple PRs, which through the
forwardport override leads to `_schedule_fp_followup` being called on
multiple batches, and failing when trying to access the `fw_policy`.

Fix by avoiding the misuse of `self` in the two locations where it's
doing something other than accessing `env`.
This commit is contained in:
Xavier Morel 2024-06-13 07:55:42 +02:00
parent 7711d09854
commit 2662411b96

View File

@ -427,7 +427,7 @@ class Batch(models.Model):
if not (batch.parent_id and all(p.parent_id for p in batch.prs)):
_logger.info('-> no parent %s (%s)', batch, prs)
continue
if not self.env.context.get('force_fw') and self.source.fw_policy != 'skipci' \
if not self.env.context.get('force_fw') and batch.source.fw_policy != 'skipci' \
and (invalid := batch.prs.filtered(lambda p: p.state not in ['validated', 'ready'])):
_logger.info(
'-> wrong state %s (%s)',
@ -437,7 +437,7 @@ class Batch(models.Model):
continue
# check if we've already forward-ported this branch
next_target = self._find_next_targets()
next_target = batch._find_next_targets()
if not next_target:
_logger.info("-> forward port done (no next target)")
continue