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.
diff --git a/src/main/java/com/google/gerrit/client/patches/PatchScreen.java b/src/main/java/com/google/gerrit/client/patches/PatchScreen.java
index a795bc9..37f4aff 100644
--- a/src/main/java/com/google/gerrit/client/patches/PatchScreen.java
+++ b/src/main/java/com/google/gerrit/client/patches/PatchScreen.java
@@ -31,7 +31,6 @@
 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 @@
           @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 @@
         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 @@
         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;
diff --git a/src/main/java/com/google/gerrit/client/rpc/BaseServiceImplementation.java b/src/main/java/com/google/gerrit/client/rpc/BaseServiceImplementation.java
index 7b6ab03..36cc33e 100644
--- a/src/main/java/com/google/gerrit/client/rpc/BaseServiceImplementation.java
+++ b/src/main/java/com/google/gerrit/client/rpc/BaseServiceImplementation.java
@@ -62,9 +62,6 @@
       } else if (e.getCause() instanceof NoSuchEntityException) {
         callback.onFailure(e.getCause());
 
-      } else if (e.getCause() instanceof NoDifferencesException) {
-        callback.onFailure(e.getCause());
-
       } else {
         callback.onFailure(e);
       }
diff --git a/src/main/java/com/google/gerrit/client/rpc/NoDifferencesException.java b/src/main/java/com/google/gerrit/client/rpc/NoDifferencesException.java
deleted file mode 100644
index 042119e..0000000
--- a/src/main/java/com/google/gerrit/client/rpc/NoDifferencesException.java
+++ /dev/null
@@ -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);
-  }
-}
diff --git a/src/main/java/com/google/gerrit/server/patch/PatchScriptAction.java b/src/main/java/com/google/gerrit/server/patch/PatchScriptAction.java
index b7d5709..2864dc7 100644
--- a/src/main/java/com/google/gerrit/server/patch/PatchScriptAction.java
+++ b/src/main/java/com/google/gerrit/server/patch/PatchScriptAction.java
@@ -30,7 +30,6 @@
 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 @@
     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) {