Merge "Add client API for /changes/<id>/revisions/<id>/files"

This commit is contained in:
Edwin Kempin 2013-07-08 20:06:26 +00:00 committed by Gerrit Code Review
commit e12f8b0314
3 changed files with 40 additions and 0 deletions

View File

@ -65,6 +65,10 @@ public class ChangeApi {
call(id, "detail").get(cb);
}
public static RestApi revision(int id, String revision) {
return change(id).view("revisions").id(revision);
}
public static RestApi revision(PatchSet.Id id) {
return change(id.getParentKey().get()).view("revisions").id(id.get());
}

View File

@ -15,6 +15,7 @@
package com.google.gerrit.client.diff;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -24,6 +25,13 @@ public class DiffApi {
NONE, TRAILING, CHANGED, ALL;
};
public static void list(int id, String revision,
AsyncCallback<NativeMap<FileInfo>> cb) {
ChangeApi.revision(id, revision)
.view("files")
.get(NativeMap.copyKeysIntoChildren("path", cb));
}
public static DiffApi diff(PatchSet.Id id, String path) {
return new DiffApi(ChangeApi.revision(id)
.view("files").id(path)

View File

@ -0,0 +1,28 @@
// Copyright (C) 2013 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.diff;
import com.google.gwt.core.client.JavaScriptObject;
public class FileInfo extends JavaScriptObject {
public final native String path() /*-{ return this.path; }-*/;
public final native String old_path() /*-{ return this.old_path; }-*/;
public final native int lines_inserted() /*-{ return this.lines_inserted || 0; }-*/;
public final native int lines_deleted() /*-{ return this.lines_deleted || 0; }-*/;
public final native boolean binary() /*-{ return this.binary || false; }-*/;
protected FileInfo() {
}
}