Allow User to Merge/Cherry Pick on Specific Branch using Web UI

1,911 views
Skip to first unread message

laurent....@ullink.com

unread,
Oct 1, 2013, 6:30:53 AM10/1/13
to repo-d...@googlegroups.com
Hello,

We are using Gerrit for quite a while now, and there is something that is requested by our developpers : An easy way to Merge/Cherry Pick changes from one branch to an other.

From my point of view the ideal way would be to have an option at same level than "Review" & "Revert Change", ie "Cherry pick on...", "Merge on..." ( see sample screenshot ) Displaying list of Branch in a popup for example.

My questions :
* Is this do-able using plugin (from what I saw it's not)
* Is there any chance to get it included in future release of gerrit (ie, If I start developing such feature, I don't want to patch each new relese with my changes) ?

Thanks for your help,

Laurent


Cherry pick on.png

David Pursehouse

unread,
Oct 1, 2013, 6:37:19 AM10/1/13
to laurent....@ullink.com, repo-d...@googlegroups.com
In Gerrit 2.8 there will be a "Cherry pick" button on the change screen,
alongside the "Review", "Revert", etc buttons, pretty much exactly as
you show in the screenshot.


David Pursehouse

unread,
Oct 1, 2013, 6:42:51 AM10/1/13
to repo-d...@googlegroups.com, laurent....@ullink.com
I should also mention that it includes a pop-up dialog to select the target branch.

If you want to see it in action you can have a look at https://gerrit-review.googlesource.com or download the latest version on the master branch and test it yourself.

Or just have a look at the attached screenshots.

cherrypick-branch-selection.png
cherrypick-button.png

laurent....@ullink.com

unread,
Oct 1, 2013, 2:14:55 PM10/1/13
to repo-d...@googlegroups.com, laurent....@ullink.com
Wonderful !!

Tomas Hellberg

unread,
Feb 3, 2014, 5:41:19 AM2/3/14
to repo-d...@googlegroups.com, laurent....@ullink.com
I get "Could not create a merge commit during the cherry pick" when I tried this function and I don't see anything in the error_log. Does this require any special access controls?

Bassem Rabil

unread,
Feb 3, 2014, 3:55:37 PM2/3/14
to repo-d...@googlegroups.com, laurent....@ullink.com
Same here with Gerrit 2.8.1, we get this error "Could not create a merge commit during the cherry pick" when trying this new feature. I thought first this was for open changes only to be cherry picked, but I get this error for both open and merged changes. Is there any hints on how to get this working ? The branch we are trying to cherry pick to is a personal branch which we have full permissions on.

Bassem Rabil

unread,
Feb 4, 2014, 11:19:11 AM2/4/14
to repo-d...@googlegroups.com, laurent....@ullink.com
I checked the code and the error is coming from the file gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java

The code snippest is below:

        RevCommit cherryPickCommit;
        ObjectInserter oi = git.newObjectInserter();
        try {
          ProjectState projectState = refControl.getProjectControl().getProjectState();
          cherryPickCommit =
              mergeUtilFactory.create(projectState).createCherryPickFromCommit(git, oi, mergeTip,
                  commitToCherryPick, committerIdent, commitMessage, revWalk);
        } finally {
          oi.release();
        }

        if (cherryPickCommit == null) {
          throw new MergeException(
              "Could not create a merge commit during the cherry pick");
        }

It seems that such an error could be resulting from insufficient permission to destination branch, however the destination branch in our case was a personal branch with Push, Push Merge Commit, Submit are granted. We are not able to use this new feature since its introduction in Gerrit 2.8. Are there any required permissions for source or destination branches to cherry pick using this new feature ?

Thanks
Bassem

UkJung Kim

unread,
Mar 3, 2014, 3:41:58 PM3/3/14
to repo-d...@googlegroups.com, laurent....@ullink.com
In my case, it failed because of path conflict. If I changed "Automatically resolve conflicts" project option to true, then cherry-pick succeeded without any failure.
I think "Automatically resolve conflicts" should be true by default for cherry-pick.

Dave Castagna (Motorola Mobility)

unread,
Jun 5, 2014, 2:01:56 PM6/5/14
to repo-d...@googlegroups.com, laurent....@ullink.com
Has there been any movement on this?

We are seeing a similar issue.  It would be good to know exactly what permissions are required at the downstream end in order to successfully "Cherry Pick To".

Marcelo Ávila

unread,
Jun 5, 2014, 3:46:18 PM6/5/14
to Dave Castagna (Motorola Mobility), Repo and Gerrit Discussion, laurent....@ullink.com
Hi Dave,

Have you granted "Forge Author" permissions in these failed cherry-picks situations?


--
Marcelo Ávila de Oliveira
CPqD - Information Technology Engineer


--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Pursehouse

unread,
Jun 5, 2014, 8:45:45 PM6/5/14
to Dave Castagna (Motorola Mobility), repo-d...@googlegroups.com, laurent....@ullink.com
It might not be a permission issue.

The error message mentioned below will also be raised if the commit
cannot be cherry-picked cleanly (i.e. has conflicts) or the cherry pick
results in an empty commit (i.e. the same changes already exist on the
target branch).

Have you tried to manually cherry pick the change on a local workspace
to see the results?
> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to repo-discuss...@googlegroups.com
> <mailto:repo-discuss...@googlegroups.com>.

yestin

unread,
Jul 24, 2014, 9:00:48 PM7/24/14
to repo-d...@googlegroups.com, cast...@motorola.com, laurent....@ullink.com
Alternatively, you can check if the "Automatically resolve conflicts" option
of the project is enabled when you are sure it is not a permission issue.

I was having the same problem that I am sure the "Cherry Pick To" works
in my project but I can not do it on some changes, while I can manually
cherry-pick them in my local workspace.

Gerrit uses JGit ThreeWayMerger.merge() to do the cherry pick.

When it tries to do a merge, by default the merge will only succeed
if there is no path conflict. A path conflict occurs when the same file has
also been changed on the other side of the merge.

If Automatically resolve conflicts is enabled, Gerrit will try to do a content
merge when a path conflict occurs.

Thanks,
Yestin
Reply all
Reply to author
Forward
0 new messages