Merge changes Id768b4f1,Iba8447f6
* changes: Display only mergeable changes in Conflicts With tab Add 'is:mergeable' operator to find changes without merge conflict
This commit is contained in:
@@ -258,6 +258,11 @@ is:submitted, is:merged, is:abandoned::
|
|||||||
+
|
+
|
||||||
Same as <<status,status:'STATE'>>.
|
Same as <<status,status:'STATE'>>.
|
||||||
|
|
||||||
|
is:mergeable::
|
||||||
|
+
|
||||||
|
True if the change has no merge conflicts and could be merged into its
|
||||||
|
destination branch.
|
||||||
|
|
||||||
[[status]]
|
[[status]]
|
||||||
status:open::
|
status:open::
|
||||||
+
|
+
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
|
|||||||
suggestions.add("is:submitted");
|
suggestions.add("is:submitted");
|
||||||
suggestions.add("is:merged");
|
suggestions.add("is:merged");
|
||||||
suggestions.add("is:abandoned");
|
suggestions.add("is:abandoned");
|
||||||
|
suggestions.add("is:mergeable");
|
||||||
|
|
||||||
suggestions.add("status:");
|
suggestions.add("status:");
|
||||||
suggestions.add("status:open");
|
suggestions.add("status:open");
|
||||||
|
|||||||
@@ -193,8 +193,8 @@ class RelatedChanges extends TabPanel {
|
|||||||
if (Gerrit.getConfig().hasIndex()) {
|
if (Gerrit.getConfig().hasIndex()) {
|
||||||
StringBuilder conflictsQuery = new StringBuilder();
|
StringBuilder conflictsQuery = new StringBuilder();
|
||||||
conflictsQuery.append("status:open");
|
conflictsQuery.append("status:open");
|
||||||
|
conflictsQuery.append(" is:mergeable");
|
||||||
conflictsQuery.append(" ").append(op("conflicts", info.legacy_id().get()));
|
conflictsQuery.append(" ").append(op("conflicts", info.legacy_id().get()));
|
||||||
conflictsQuery.append(" -age:1month");
|
|
||||||
ChangeList.query(conflictsQuery.toString(),
|
ChangeList.query(conflictsQuery.toString(),
|
||||||
EnumSet.of(ListChangesOption.CURRENT_REVISION, ListChangesOption.CURRENT_COMMIT),
|
EnumSet.of(ListChangesOption.CURRENT_REVISION, ListChangesOption.CURRENT_COMMIT),
|
||||||
new AsyncCallback<ChangeList>() {
|
new AsyncCallback<ChangeList>() {
|
||||||
|
|||||||
@@ -349,6 +349,17 @@ public class ChangeField {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Whether the change is mergeable. */
|
||||||
|
public static final FieldDef<ChangeData, String> MERGEABLE =
|
||||||
|
new FieldDef.Single<ChangeData, String>(
|
||||||
|
ChangeQueryBuilder.FIELD_MERGEABLE, FieldType.EXACT, false) {
|
||||||
|
@Override
|
||||||
|
public String get(ChangeData input, FillArgs args)
|
||||||
|
throws OrmException {
|
||||||
|
return input.change(args.db).isMergeable() ? "1" : null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private static <T> List<byte[]> toProtos(ProtobufCodec<T> codec, Collection<T> objs)
|
private static <T> List<byte[]> toProtos(ProtobufCodec<T> codec, Collection<T> objs)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
List<byte[]> result = Lists.newArrayListWithCapacity(objs.size());
|
List<byte[]> result = Lists.newArrayListWithCapacity(objs.size());
|
||||||
|
|||||||
@@ -97,6 +97,29 @@ public class ChangeSchemas {
|
|||||||
// For upgrade to Lucene 4.4.0 index format only.
|
// For upgrade to Lucene 4.4.0 index format only.
|
||||||
static final Schema<ChangeData> V4 = release(V3.getFields().values());
|
static final Schema<ChangeData> V4 = release(V3.getFields().values());
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
static final Schema<ChangeData> V5 = release(
|
||||||
|
ChangeField.LEGACY_ID,
|
||||||
|
ChangeField.ID,
|
||||||
|
ChangeField.STATUS,
|
||||||
|
ChangeField.PROJECT,
|
||||||
|
ChangeField.REF,
|
||||||
|
ChangeField.TOPIC,
|
||||||
|
ChangeField.UPDATED,
|
||||||
|
ChangeField.SORTKEY,
|
||||||
|
ChangeField.FILE,
|
||||||
|
ChangeField.OWNER,
|
||||||
|
ChangeField.REVIEWER,
|
||||||
|
ChangeField.COMMIT,
|
||||||
|
ChangeField.TR,
|
||||||
|
ChangeField.LABEL,
|
||||||
|
ChangeField.REVIEWED,
|
||||||
|
ChangeField.COMMIT_MESSAGE,
|
||||||
|
ChangeField.COMMENT,
|
||||||
|
ChangeField.CHANGE,
|
||||||
|
ChangeField.APPROVAL,
|
||||||
|
ChangeField.MERGEABLE);
|
||||||
|
|
||||||
private static Schema<ChangeData> release(Collection<FieldDef<ChangeData, ?>> fields) {
|
private static Schema<ChangeData> release(Collection<FieldDef<ChangeData, ?>> fields) {
|
||||||
return new Schema<ChangeData>(true, fields);
|
return new Schema<ChangeData>(true, fields);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
public static final String FIELD_HAS = "has";
|
public static final String FIELD_HAS = "has";
|
||||||
public static final String FIELD_LABEL = "label";
|
public static final String FIELD_LABEL = "label";
|
||||||
public static final String FIELD_LIMIT = "limit";
|
public static final String FIELD_LIMIT = "limit";
|
||||||
|
public static final String FIELD_MERGEABLE = "mergeable";
|
||||||
public static final String FIELD_MESSAGE = "message";
|
public static final String FIELD_MESSAGE = "message";
|
||||||
public static final String FIELD_OWNER = "owner";
|
public static final String FIELD_OWNER = "owner";
|
||||||
public static final String FIELD_OWNERIN = "ownerin";
|
public static final String FIELD_OWNERIN = "ownerin";
|
||||||
@@ -280,7 +281,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Operator
|
@Operator
|
||||||
public Predicate<ChangeData> is(String value) {
|
public Predicate<ChangeData> is(String value) throws QueryParseException {
|
||||||
if ("starred".equalsIgnoreCase(value)) {
|
if ("starred".equalsIgnoreCase(value)) {
|
||||||
return new IsStarredByPredicate(args.dbProvider, currentUser);
|
return new IsStarredByPredicate(args.dbProvider, currentUser);
|
||||||
}
|
}
|
||||||
@@ -305,6 +306,11 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
return new ReviewerPredicate(args.dbProvider, self());
|
return new ReviewerPredicate(args.dbProvider, self());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ("mergeable".equalsIgnoreCase(value)) {
|
||||||
|
requireIndex(FIELD_IS, "mergeable");
|
||||||
|
return new IsMergeablePredicate(args.dbProvider);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return status(value);
|
return status(value);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
// 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.server.query.change;
|
||||||
|
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
|
import com.google.gerrit.server.index.ChangeField;
|
||||||
|
import com.google.gerrit.server.index.IndexPredicate;
|
||||||
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
|
class IsMergeablePredicate extends IndexPredicate<ChangeData> {
|
||||||
|
private final Provider<ReviewDb> dbProvider;
|
||||||
|
|
||||||
|
IsMergeablePredicate(Provider<ReviewDb> dbProvider) {
|
||||||
|
super(ChangeField.MERGEABLE, "1");
|
||||||
|
this.dbProvider = dbProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean match(ChangeData object) throws OrmException {
|
||||||
|
Change c = object.change(dbProvider);
|
||||||
|
return c != null && c.isMergeable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCost() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user