Remove annoying 'no differences' error dialog

When the user selects two identical patch sets, the server throws
a NoDifferencesException, which causes Gerrit to display an error
dialog.  This dialog blocks subsequent attempts to view that file
until the patch set being compared gets reset.

This change deletes the NoDifferencesException class and instead
displays the message "No differences" in the diff table if the user
selects two identical patch sets to diff.
This commit is contained in:
Cedric Beust
2009-07-07 15:48:36 -07:00
committed by Shawn O. Pearce
parent 9943edbf64
commit 2fd32f8616
4 changed files with 16 additions and 54 deletions

View File

@@ -31,7 +31,6 @@ import com.google.gerrit.client.reviewdb.Change;
import com.google.gerrit.client.reviewdb.Patch;
import com.google.gerrit.client.reviewdb.PatchSet;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.NoDifferencesException;
import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.DirectScreenLink;
import com.google.gerrit.client.ui.Screen;
@@ -357,22 +356,9 @@ public abstract class PatchScreen extends Screen {
@Override
public void onFailure(final Throwable caught) {
if (rpcSequence == rpcseq) {
if (isNoDifferences(caught) && !isFirst) {
historyTable.enableAll(true);
showPatch(false);
} else {
super.onFailure(caught);
}
super.onFailure(caught);
}
}
private boolean isNoDifferences(final Throwable caught) {
if (caught instanceof NoDifferencesException) {
return true;
}
return caught instanceof RemoteJsonException
&& caught.getMessage().equals(NoDifferencesException.MESSAGE);
}
});
PatchUtil.DETAIL_SVC.patchComments(patchKey, idSideA, idSideB,
@@ -405,8 +391,15 @@ public abstract class PatchScreen extends Screen {
historyPanel.setVisible(false);
}
if (contentTable instanceof SideBySideTable
&& script.getEdits().isEmpty() && !script.getPatchHeader().isEmpty()) {
// True if there are differences between the two patch sets
boolean hasEdits = !script.getEdits().isEmpty();
// True if this change is a mode change or a pure rename/copy
boolean hasMeta = !script.getPatchHeader().isEmpty();
boolean hasDifferences = hasEdits || hasMeta;
boolean pureMetaChange = !hasEdits && hasMeta;
if (contentTable instanceof SideBySideTable && pureMetaChange) {
// User asked for SideBySide (or a link guessed, wrong) and we can't
// show a binary or pure-rename change there accurately. Switch to
// the unified view instead.
@@ -418,10 +411,12 @@ public abstract class PatchScreen extends Screen {
History.newItem(Link.toPatchUnified(patchKey), false);
}
contentTable.display(patchKey, idSideA, idSideB, script);
contentTable.display(comments);
contentTable.finishDisplay();
showPatch(true);
if (hasDifferences) {
contentTable.display(patchKey, idSideA, idSideB, script);
contentTable.display(comments);
contentTable.finishDisplay();
}
showPatch(hasDifferences);
script = null;
comments = null;

View File

@@ -62,9 +62,6 @@ public class BaseServiceImplementation {
} else if (e.getCause() instanceof NoSuchEntityException) {
callback.onFailure(e.getCause());
} else if (e.getCause() instanceof NoDifferencesException) {
callback.onFailure(e.getCause());
} else {
callback.onFailure(e);
}

View File

@@ -1,26 +0,0 @@
// Copyright (C) 2008 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.rpc;
/** Error indicating there are no differences in selected files. */
public class NoDifferencesException extends Exception {
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "No Differences";
public NoDifferencesException() {
super(MESSAGE);
}
}

View File

@@ -30,7 +30,6 @@ import com.google.gerrit.client.reviewdb.Project;
import com.google.gerrit.client.reviewdb.ReviewDb;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.CorruptEntityException;
import com.google.gerrit.client.rpc.NoDifferencesException;
import com.google.gerrit.client.rpc.NoSuchEntityException;
import com.google.gerrit.client.rpc.BaseServiceImplementation.Action;
import com.google.gerrit.client.rpc.BaseServiceImplementation.Failure;
@@ -112,9 +111,6 @@ class PatchScriptAction implements Action<PatchScript> {
final DiffCacheKey key = keyFor(bId, aId);
final DiffCacheContent contentWS = get(key);
final CommentDetail comments = allComments(db);
if (contentWS.isNoDifference() && comments.isEmpty()) {
throw new Failure(new NoDifferencesException());
}
final DiffCacheContent contentActual;
if (settings.getWhitespace() != Whitespace.IGNORE_NONE) {