Deprecate IgnoreWhitespace enum in favor of Whitespace enum

The internal IgnoreWhitespace enum was replaced by a new Whitespace
enum which is available in the extension package. The old enum was
still used for the '--ignore-whitespace' option on the GetDiff REST
endpoint. Deprecate this '--ignore-whitespace' option and replace it
with a new '--whitespace' option. This will allow us to set this
option from the Gerrit API, which doesn't have access to the
IgnoreWhitespace enum.

Adapt the client to use the new '--whitespace' option.

Change-Id: Iba38480fc802c141a676de423e5e9beae0020c11
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin 2016-02-09 17:13:23 +01:00
parent 2676ba980f
commit 0b7c40fa76
3 changed files with 20 additions and 20 deletions

View File

@ -3670,8 +3670,9 @@ If the `weblinks-only` parameter is specified, only the diff web links are retur
}
----
The `ignore-whitespace` parameter can be specified to control how whitespace differences are
reported in the result. Valid values are `NONE`, `TRAILING`, `CHANGED` or `ALL`.
The `whitespace` parameter can be specified to control how whitespace
differences are reported in the result. Valid values are `IGNORE_NONE`,
`IGNORE_TRAILING`, `IGNORE_LEADING_AND_TRAILING` or `IGNORE_ALL`.
The `context` parameter can be specified to control the number of lines of surrounding context
in the diff. Valid values are `ALL` or number of lines.

View File

@ -19,6 +19,7 @@ import com.google.gerrit.client.info.FileInfo;
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -70,22 +71,8 @@ public class DiffApi {
}
public DiffApi ignoreWhitespace(DiffPreferencesInfo.Whitespace w) {
switch (w) {
default:
case IGNORE_NONE:
return ignoreWhitespace(IgnoreWhitespace.NONE);
case IGNORE_TRAILING:
return ignoreWhitespace(IgnoreWhitespace.TRAILING);
case IGNORE_LEADING_AND_TRAILING:
return ignoreWhitespace(IgnoreWhitespace.CHANGED);
case IGNORE_ALL:
return ignoreWhitespace(IgnoreWhitespace.ALL);
}
}
public DiffApi ignoreWhitespace(IgnoreWhitespace w) {
if (w != null && w != IgnoreWhitespace.NONE) {
call.addParameter("ignore-whitespace", w);
if (w != null && w != Whitespace.IGNORE_ALL) {
call.addParameter("whitespace", w);
}
return this;
}

View File

@ -25,6 +25,7 @@ import com.google.common.collect.Maps;
import com.google.gerrit.common.data.PatchScript;
import com.google.gerrit.common.data.PatchScript.DisplayMethod;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace;
import com.google.gerrit.extensions.common.ChangeType;
import com.google.gerrit.extensions.common.DiffInfo;
import com.google.gerrit.extensions.common.DiffInfo.ContentEntry;
@ -89,8 +90,12 @@ public class GetDiff implements RestReadView<FileResource> {
@Option(name = "--base", metaVar = "REVISION")
String base;
@Deprecated
@Option(name = "--ignore-whitespace")
IgnoreWhitespace ignoreWhitespace = IgnoreWhitespace.NONE;
IgnoreWhitespace ignoreWhitespace;
@Option(name = "--whitespace")
Whitespace whitespace;
@Option(name = "--context", handler = ContextOptionHandler.class)
int context = DiffPreferencesInfo.DEFAULT_CONTEXT;
@ -123,7 +128,13 @@ public class GetDiff implements RestReadView<FileResource> {
basePatchSet = baseResource.getPatchSet();
}
DiffPreferencesInfo prefs = new DiffPreferencesInfo();
if (whitespace != null) {
prefs.ignoreWhitespace = whitespace;
} else if (ignoreWhitespace != null) {
prefs.ignoreWhitespace = ignoreWhitespace.whitespace;
} else {
prefs.ignoreWhitespace = Whitespace.IGNORE_ALL;
}
prefs.context = context;
prefs.intralineDifference = intraline;
@ -368,6 +379,7 @@ public class GetDiff implements RestReadView<FileResource> {
}
}
@Deprecated
enum IgnoreWhitespace {
NONE(DiffPreferencesInfo.Whitespace.IGNORE_NONE),
TRAILING(DiffPreferencesInfo.Whitespace.IGNORE_TRAILING),