diff options
author | Alexandre Philbert <alexandre.philbert@ericsson.com> | 2016-02-18 09:13:40 -0500 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-02-26 16:13:54 +0900 |
commit | 09800bdda7964c4423bffcac60baaf530a2e8dc0 (patch) | |
tree | 7cac4ac3897b7716c22521698f9784c071703ad3 | |
parent | 71797a9f3ef108bb088090d180eb0a17fcc90aba (diff) |
Fix display of "Related changes" after change is rebased in web UI
Rebasing a change can be done using the command line or with the web UI.
Using the command line, the involved code is mostly in "ReceiveCommits"
where many manipulations are made. Using the web UI (RestApi), the
classes used are "RebaseChangeOp" and "PatchSetInserter".
The reason why the rebase operation does not show the related changes
properly is because the PatchSet.groups was not set correctly. Instead
of setting the new patch set's groups to the base's ones, it kept its
previous value; contrarily to the rebase operation done in
"ReceiveCommits" [1].
To avoid bringing in too many classes and complexity from
"ReceiveCommits" to "RebaseChangeOp", a simple database search is done
to determine what the base commit's patch set groups are, and then they
are passed into the new patch set.
[1] http://pastebin.com/ye2wUnuW
Bug: Issue 3894
Change-Id: I31b1420fb3606a077337e3d8617f54b328d1c503
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeOp.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeOp.java index d3367a085f..ae344f680f 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeOp.java @@ -33,6 +33,7 @@ import com.google.gerrit.server.project.ChangeControl; import com.google.gerrit.server.project.InvalidChangeOperationException; import com.google.gerrit.server.project.ProjectState; import com.google.gwtorm.server.OrmException; +import com.google.gwtorm.server.ResultSet; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; @@ -44,6 +45,8 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevWalk; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; public class RebaseChangeOp extends BatchUpdate.Op { public interface Factory { @@ -125,10 +128,20 @@ public class RebaseChangeOp extends BatchUpdate.Op { ObjectId newId = rebaseCommit(ctx, original, baseCommit); rebasedCommit = rw.parseCommit(newId); + List<String> baseCommitPatchSetGroups = new ArrayList<>(); + RevId patchSetByRev = new RevId((baseCommitish != null) ? baseCommitish + : ObjectId.toString(baseCommit.getId())); + ResultSet<PatchSet> relatedPatchSets = + ctx.getDb().patchSets().byRevision(patchSetByRev); + for (PatchSet ps : relatedPatchSets) { + baseCommitPatchSetGroups.addAll(ps.getGroups()); + } + rebasedPatchSetId = ChangeUtil.nextPatchSetId( ctx.getRepository(), ctl.getChange().currentPatchSetId()); patchSetInserter = patchSetInserterFactory .create(ctl.getRefControl(), rebasedPatchSetId, rebasedCommit) + .setGroups(baseCommitPatchSetGroups) .setDraft(originalPatchSet.isDraft()) .setUploader(ctx.getUser().getAccountId()) .setSendMail(false) |