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:
parent
2676ba980f
commit
0b7c40fa76
@ -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
|
The `whitespace` parameter can be specified to control how whitespace
|
||||||
reported in the result. Valid values are `NONE`, `TRAILING`, `CHANGED` or `ALL`.
|
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
|
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.
|
in the diff. Valid values are `ALL` or number of lines.
|
||||||
|
@ -19,6 +19,7 @@ import com.google.gerrit.client.info.FileInfo;
|
|||||||
import com.google.gerrit.client.rpc.NativeMap;
|
import com.google.gerrit.client.rpc.NativeMap;
|
||||||
import com.google.gerrit.client.rpc.RestApi;
|
import com.google.gerrit.client.rpc.RestApi;
|
||||||
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
|
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.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
@ -70,22 +71,8 @@ public class DiffApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiffApi ignoreWhitespace(DiffPreferencesInfo.Whitespace w) {
|
public DiffApi ignoreWhitespace(DiffPreferencesInfo.Whitespace w) {
|
||||||
switch (w) {
|
if (w != null && w != Whitespace.IGNORE_ALL) {
|
||||||
default:
|
call.addParameter("whitespace", w);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import com.google.common.collect.Maps;
|
|||||||
import com.google.gerrit.common.data.PatchScript;
|
import com.google.gerrit.common.data.PatchScript;
|
||||||
import com.google.gerrit.common.data.PatchScript.DisplayMethod;
|
import com.google.gerrit.common.data.PatchScript.DisplayMethod;
|
||||||
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
|
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.ChangeType;
|
||||||
import com.google.gerrit.extensions.common.DiffInfo;
|
import com.google.gerrit.extensions.common.DiffInfo;
|
||||||
import com.google.gerrit.extensions.common.DiffInfo.ContentEntry;
|
import com.google.gerrit.extensions.common.DiffInfo.ContentEntry;
|
||||||
@ -89,8 +90,12 @@ public class GetDiff implements RestReadView<FileResource> {
|
|||||||
@Option(name = "--base", metaVar = "REVISION")
|
@Option(name = "--base", metaVar = "REVISION")
|
||||||
String base;
|
String base;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Option(name = "--ignore-whitespace")
|
@Option(name = "--ignore-whitespace")
|
||||||
IgnoreWhitespace ignoreWhitespace = IgnoreWhitespace.NONE;
|
IgnoreWhitespace ignoreWhitespace;
|
||||||
|
|
||||||
|
@Option(name = "--whitespace")
|
||||||
|
Whitespace whitespace;
|
||||||
|
|
||||||
@Option(name = "--context", handler = ContextOptionHandler.class)
|
@Option(name = "--context", handler = ContextOptionHandler.class)
|
||||||
int context = DiffPreferencesInfo.DEFAULT_CONTEXT;
|
int context = DiffPreferencesInfo.DEFAULT_CONTEXT;
|
||||||
@ -123,7 +128,13 @@ public class GetDiff implements RestReadView<FileResource> {
|
|||||||
basePatchSet = baseResource.getPatchSet();
|
basePatchSet = baseResource.getPatchSet();
|
||||||
}
|
}
|
||||||
DiffPreferencesInfo prefs = new DiffPreferencesInfo();
|
DiffPreferencesInfo prefs = new DiffPreferencesInfo();
|
||||||
prefs.ignoreWhitespace = ignoreWhitespace.whitespace;
|
if (whitespace != null) {
|
||||||
|
prefs.ignoreWhitespace = whitespace;
|
||||||
|
} else if (ignoreWhitespace != null) {
|
||||||
|
prefs.ignoreWhitespace = ignoreWhitespace.whitespace;
|
||||||
|
} else {
|
||||||
|
prefs.ignoreWhitespace = Whitespace.IGNORE_ALL;
|
||||||
|
}
|
||||||
prefs.context = context;
|
prefs.context = context;
|
||||||
prefs.intralineDifference = intraline;
|
prefs.intralineDifference = intraline;
|
||||||
|
|
||||||
@ -368,6 +379,7 @@ public class GetDiff implements RestReadView<FileResource> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
enum IgnoreWhitespace {
|
enum IgnoreWhitespace {
|
||||||
NONE(DiffPreferencesInfo.Whitespace.IGNORE_NONE),
|
NONE(DiffPreferencesInfo.Whitespace.IGNORE_NONE),
|
||||||
TRAILING(DiffPreferencesInfo.Whitespace.IGNORE_TRAILING),
|
TRAILING(DiffPreferencesInfo.Whitespace.IGNORE_TRAILING),
|
||||||
|
Loading…
Reference in New Issue
Block a user