Redirect the user to the reverted change.

When the user reverts a change through the
use of the "Revert"-button, the user will get
redirected to the new change.

Change-Id: I6f3f616f67b8d53904968b17cdb96e6778b69475
This commit is contained in:
Gustaf Lundh
2011-10-27 11:52:32 -07:00
parent ac7d2f3448
commit 8f9b8f9714
3 changed files with 15 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AccountDashboardLink;
import com.google.gerrit.client.ui.ComplexDisclosurePanel;
import com.google.gerrit.client.ui.ListenableAccountDiffPreference;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.ChangeDetail;
import com.google.gerrit.common.data.GitwebLink;
import com.google.gerrit.common.data.PatchSetDetail;
@@ -436,7 +437,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel implements O
@Override
public void onClick(final ClickEvent event) {
b.setEnabled(false);
new CommentedChangeActionDialog(patchSet.getId(), createCommentedCallback(b),
new CommentedChangeActionDialog(patchSet.getId(), createCommentedCallback(b, true),
Util.C.revertChangeTitle(), Util.C.headingRevertMessage(),
Util.C.buttonRevertChangeSend(), Util.C.buttonRevertChangeCancel(),
Gerrit.RESOURCES.css().revertChangeDialog(), Gerrit.RESOURCES.css().revertMessage(),
@@ -456,7 +457,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel implements O
@Override
public void onClick(final ClickEvent event) {
b.setEnabled(false);
new CommentedChangeActionDialog(patchSet.getId(), createCommentedCallback(b),
new CommentedChangeActionDialog(patchSet.getId(), createCommentedCallback(b, false),
Util.C.abandonChangeTitle(), Util.C.headingAbandonMessage(),
Util.C.buttonAbandonChangeSend(), Util.C.buttonAbandonChangeCancel(),
Gerrit.RESOURCES.css().abandonChangeDialog(), Gerrit.RESOURCES.css().abandonMessage()) {
@@ -475,7 +476,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel implements O
@Override
public void onClick(final ClickEvent event) {
b.setEnabled(false);
new CommentedChangeActionDialog(patchSet.getId(), createCommentedCallback(b),
new CommentedChangeActionDialog(patchSet.getId(), createCommentedCallback(b, false),
Util.C.restoreChangeTitle(), Util.C.headingRestoreMessage(),
Util.C.buttonRestoreChangeSend(), Util.C.buttonRestoreChangeCancel(),
Gerrit.RESOURCES.css().abandonChangeDialog(), Gerrit.RESOURCES.css().abandonMessage()) {
@@ -633,11 +634,15 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel implements O
}
}
private AsyncCallback<ChangeDetail> createCommentedCallback(final Button b) {
private AsyncCallback<ChangeDetail> createCommentedCallback(final Button b, final boolean redirect) {
return new AsyncCallback<ChangeDetail>() {
public void onSuccess(ChangeDetail result) {
if (redirect) {
Gerrit.display(PageLinks.toChange(result.getChange().getId()));
} else {
changeScreen.update(result);
}
}
public void onFailure(Throwable caught) {
b.setEnabled(true);

View File

@@ -105,10 +105,10 @@ class RevertChange extends Handler<ChangeDetail> {
throw new NoSuchChangeException(changeId);
}
ChangeUtil.revert(patchSetId, currentUser, message, db,
Change.Id revertedChangeId = ChangeUtil.revert(patchSetId, currentUser, message, db,
revertedSenderFactory, hooks, gitManager, patchSetInfoFactory,
replication, myIdent);
return changeDetailFactory.create(changeId).call();
return changeDetailFactory.create(revertedChangeId).call();
}
}

View File

@@ -256,7 +256,7 @@ public class ChangeUtil {
hooks.doChangeAbandonedHook(updatedChange, user.getAccount(), message);
}
public static void revert(final PatchSet.Id patchSetId,
public static Change.Id revert(final PatchSet.Id patchSetId,
final IdentifiedUser user, final String message, final ReviewDb db,
final RevertedSender.Factory revertedSenderFactory,
final ChangeHookRunner hooks, GitRepositoryManager gitManager,
@@ -352,6 +352,8 @@ public class ChangeUtil {
cm.send();
hooks.doPatchsetCreatedHook(change, ps);
return change.getId();
} finally {
revWalk.release();
git.close();