Gitlab APi python-gitlab - cherrypick or rebase commits from a merge request


I have a webhook for merge requests, which envokes a script that creates a new merge request now to another target branch.

Lets say I have a source branch which was created off of master. And I would like to create a new merge request with the same commits as the first merge request onto another target branch, let’s say next-major branch.

This works using the API and python-gitlab.

Only problem is that it is not that nice to use one source branch for merge requests into two different target branches. Reasons:

  1. There can be different merge conflicts for each merge, and solving this is awkward when there is one source branch
  2. Commits made to master which are inherited to the source branch and that are not present in the new target branch will be added to the list of commits in the new merge request. I would not like this, because it could be that these commits in fact should not be in the new target branch.

The better way to do this would therefore be to

  1. Create a new dev-branch with parent being the new target branch
  2. Rebase or in some way apply the commits from the original merge request onto this new dev-branch
  3. Create a merge request of this new dev-branch into the new target branch.

I can not seem to manage this with the API. There is a possibility to cherry-pick a merge request onto another branch, but when I try this, it only recognizes branches belonging to the target project. Not the fork project. Which is what I need, as all our merge requests come from forks. And the new source branch needs to be created in the fork.

Is there a way to do this that I have missed?