summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Kempin <edwin.kempin@sap.com>2013-06-06 12:17:33 +0200
committerEdwin Kempin <edwin.kempin@gmail.com>2013-06-06 11:05:06 +0000
commit441d1ba2574517ef1ffe92b8ac6e488024abe464 (patch)
tree19152742cc4f519fdff3652132600aed4813cd45
parentffe4ea0748a1afa83432edf8c4dcea53a623c5ef (diff)
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 <edwin.kempin@sap.com>
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/changedetail/RebaseChange.java3
1 files changed, 3 insertions, 0 deletions
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;