From 441d1ba2574517ef1ffe92b8ac6e488024abe464 Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Thu, 6 Jun 2013 12:17:33 +0200 Subject: [PATCH] Check that patch set is current before doing a rebase If two users open a change in the WebUI and hit the 'Rebase Change' button one after another, the rebase succeeds for the first user and a new patch set with the rebased commit is created, but for the second user the rebase fails because the change was modified. The bad thing is that also for the second user a new commit and a new patch set are created, only updating the current patch set field of the change fails in the end. By adding the check for the current patch set in the beginning we now fail early for the second user. Change-Id: I52b48c695fe751d4ef8cd99e052a78dfb806a790 Signed-off-by: Edwin Kempin --- .../com/google/gerrit/server/changedetail/RebaseChange.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/changedetail/RebaseChange.java b/gerrit-server/src/main/java/com/google/gerrit/server/changedetail/RebaseChange.java index 9089710345..89c507bdee 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/changedetail/RebaseChange.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/changedetail/RebaseChange.java @@ -313,6 +313,9 @@ public class RebaseChange { OrmException, IOException, InvalidChangeOperationException, PathConflictException { Change change = chg; + if (!chg.currentPatchSetId().equals(patchSetId)) { + throw new InvalidChangeOperationException("patch set is not current"); + } final PatchSet originalPatchSet = db.patchSets().get(patchSetId); final RevCommit rebasedCommit;