Scenario: After rolling a new train branch 1.40.0-wmf.1 to testwikis, errors were seen that resulted in rollback to 1.39.0-wmf.28. A fix was eventually prepared for 1.40.0-wmf.1 and I tried to use scap backport to merge, pull, and (effectively no-op) deploy it.
dancy@deploy1002:~$ scap backport https://gerrit.wikimedia.org/r/c/mediawiki/core/+/831985 18:09:32 Checking whether changes are in a branch and version deployed to production... 18:09:32 Change '831985' branch '1.40.0-wmf.1' not valid for any deployed wikiversion. Deployed wikiversions: ['1.39.0-wmf.28']
If a change's target branch is checked out but not live, scap backport should print a warning and ask the operator if they want to proceed anyway.