[IMP] runbot_merge: cancel splits on cancel=staging

If a PR is cancel=staging, even if it's not the
urgentest (priority=alone) odds are good it's being staged to fix the
split. And even if it's not, it probably can't hurt.

So cancel splits in order to stage it. This may be slightly harmful if
the split is legit and has nothing to do with the PR being
prioritised, but that seems like the less likely scenario. And having
to update staging priorities on the fly seems like a bad idea. Though
obviously it might do nothing if the PRs are in "default" priority.#

Also simplify the unstage trigger from the PRs becoming ready:

- the user is useless as it's always the system user
- the batch id is not really helpful
This commit is contained in:
Xavier Morel 2024-06-26 14:30:31 +02:00
parent 3bc5b4e3e4
commit 1c76a675c2
2 changed files with 5 additions and 3 deletions

View File

@ -227,10 +227,10 @@ class Batch(models.Model):
batch.blocked = f"Multiple target branches: {', '.join(targets.mapped('name'))!r}"
else:
if batch.blocked and batch.cancel_staging:
if splits := batch.target.split_ids:
splits.unlink()
batch.target.active_staging_id.cancel(
'unstaged by %s on %s (%s)',
self.env.user.login,
batch,
'unstaged by %s becoming ready',
', '.join(batch.prs.mapped('display_name')),
)
batch.blocked = False

View File

@ -842,6 +842,8 @@ For your own safety I've ignored *everything in your entire comment*.
case commands.CancelStaging() if is_admin:
self.batch_id.cancel_staging = True
if not self.batch_id.blocked:
if splits := self.target.split_ids:
splits.unlink()
self.target.active_staging_id.cancel(
"Unstaged by %s on %s",
author.github_login, self.display_name,