Store mergeable field from cache in index
Eventually this will no longer be part of the serialized change proto, and even with the cache it is still expensive to check mergeability for each change in a list of search results, as the submit type must still be checked in order to look up the mergeability. The new MERGEABLE field now loads from the cache, although ChangeJson and several other callers still depend on the field in Change. This will facilitate index schema upgrades, in that a full reindex will also populate the persistent cache. While we're at it, upgrade Lucene to 4.10.1, which contains some important stability bugfixes[1]. [1] http://lucene.apache.org/core/4_10_1/changes/Changes.html#v4.10.1 Change-Id: I166b85f91bd596a3f0295616c2e72853b692dd54
This commit is contained in:
@@ -119,8 +119,10 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
private static final String CHANGE_FIELD = ChangeField.CHANGE.getName();
|
private static final String CHANGE_FIELD = ChangeField.CHANGE.getName();
|
||||||
private static final String DELETED_FIELD = ChangeField.DELETED.getName();
|
private static final String DELETED_FIELD = ChangeField.DELETED.getName();
|
||||||
private static final String ID_FIELD = ChangeField.LEGACY_ID.getName();
|
private static final String ID_FIELD = ChangeField.LEGACY_ID.getName();
|
||||||
|
private static final String MERGEABLE_FIELD = ChangeField.MERGEABLE.getName();
|
||||||
private static final ImmutableSet<String> FIELDS = ImmutableSet.of(
|
private static final ImmutableSet<String> FIELDS = ImmutableSet.of(
|
||||||
ADDED_FIELD, APPROVAL_FIELD, CHANGE_FIELD, DELETED_FIELD, ID_FIELD);
|
ADDED_FIELD, APPROVAL_FIELD, CHANGE_FIELD, DELETED_FIELD, ID_FIELD,
|
||||||
|
MERGEABLE_FIELD);
|
||||||
private static final Map<String, String> CUSTOM_CHAR_MAPPING = ImmutableMap.of(
|
private static final Map<String, String> CUSTOM_CHAR_MAPPING = ImmutableMap.of(
|
||||||
"_", " ", ".", " ");
|
"_", " ", ".", " ");
|
||||||
|
|
||||||
@@ -138,6 +140,8 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
Version lucene47 = Version.LUCENE_47;
|
Version lucene47 = Version.LUCENE_47;
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
Version lucene48 = Version.LUCENE_48;
|
Version lucene48 = Version.LUCENE_48;
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
Version lucene410 = Version.LUCENE_4_10_0;
|
||||||
for (Map.Entry<Integer, Schema<ChangeData>> e
|
for (Map.Entry<Integer, Schema<ChangeData>> e
|
||||||
: ChangeSchemas.ALL.entrySet()) {
|
: ChangeSchemas.ALL.entrySet()) {
|
||||||
if (e.getKey() <= 3) {
|
if (e.getKey() <= 3) {
|
||||||
@@ -150,8 +154,10 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
versions.put(e.getValue(), lucene47);
|
versions.put(e.getValue(), lucene47);
|
||||||
} else if (e.getKey() <= 11) {
|
} else if (e.getKey() <= 11) {
|
||||||
versions.put(e.getValue(), lucene48);
|
versions.put(e.getValue(), lucene48);
|
||||||
|
} else if (e.getKey() <= 13) {
|
||||||
|
versions.put(e.getValue(), lucene410);
|
||||||
} else {
|
} else {
|
||||||
versions.put(e.getValue(), Version.LUCENE_4_10_0);
|
versions.put(e.getValue(), Version.LUCENE_4_10_1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LUCENE_VERSIONS = versions.build();
|
LUCENE_VERSIONS = versions.build();
|
||||||
@@ -480,6 +486,14 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
deleted.numericValue().intValue());
|
deleted.numericValue().intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mergeable.
|
||||||
|
String mergeable = doc.get(MERGEABLE_FIELD);
|
||||||
|
if ("1".equals(mergeable)) {
|
||||||
|
cd.setMergeable(true);
|
||||||
|
} else if ("0".equals(mergeable)) {
|
||||||
|
cd.setMergeable(false);
|
||||||
|
}
|
||||||
|
|
||||||
return cd;
|
return cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,39 +21,24 @@ import com.google.common.collect.Sets;
|
|||||||
import com.google.gerrit.common.Die;
|
import com.google.gerrit.common.Die;
|
||||||
import com.google.gerrit.lifecycle.LifecycleManager;
|
import com.google.gerrit.lifecycle.LifecycleManager;
|
||||||
import com.google.gerrit.lucene.LuceneIndexModule;
|
import com.google.gerrit.lucene.LuceneIndexModule;
|
||||||
import com.google.gerrit.pgm.util.BatchGitModule;
|
|
||||||
import com.google.gerrit.pgm.util.BatchProgramModule;
|
import com.google.gerrit.pgm.util.BatchProgramModule;
|
||||||
import com.google.gerrit.pgm.util.SiteProgram;
|
import com.google.gerrit.pgm.util.SiteProgram;
|
||||||
import com.google.gerrit.pgm.util.ThreadLimiter;
|
import com.google.gerrit.pgm.util.ThreadLimiter;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.cache.h2.DefaultCacheFactory;
|
|
||||||
import com.google.gerrit.server.change.MergeabilityCache;
|
|
||||||
import com.google.gerrit.server.change.MergeabilityChecker;
|
import com.google.gerrit.server.change.MergeabilityChecker;
|
||||||
import com.google.gerrit.server.change.MergeabilityChecksExecutor;
|
|
||||||
import com.google.gerrit.server.change.MergeabilityChecksExecutor.Priority;
|
|
||||||
import com.google.gerrit.server.change.PatchSetInserter;
|
|
||||||
import com.google.gerrit.server.config.FactoryModule;
|
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.server.git.MergeUtil;
|
|
||||||
import com.google.gerrit.server.git.WorkQueue;
|
|
||||||
import com.google.gerrit.server.index.ChangeBatchIndexer;
|
import com.google.gerrit.server.index.ChangeBatchIndexer;
|
||||||
import com.google.gerrit.server.index.ChangeIndex;
|
import com.google.gerrit.server.index.ChangeIndex;
|
||||||
import com.google.gerrit.server.index.ChangeSchemas;
|
import com.google.gerrit.server.index.ChangeSchemas;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
import com.google.gerrit.server.index.IndexCollection;
|
||||||
import com.google.gerrit.server.index.IndexModule;
|
import com.google.gerrit.server.index.IndexModule;
|
||||||
import com.google.gerrit.server.index.IndexModule.IndexType;
|
import com.google.gerrit.server.index.IndexModule.IndexType;
|
||||||
import com.google.gerrit.server.mail.ReplacePatchSetSender;
|
|
||||||
import com.google.gerrit.server.notedb.NoteDbModule;
|
|
||||||
import com.google.gerrit.solr.SolrIndexModule;
|
import com.google.gerrit.solr.SolrIndexModule;
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Key;
|
import com.google.inject.Key;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.Singleton;
|
|
||||||
import com.google.inject.util.Providers;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Config;
|
import org.eclipse.jgit.lib.Config;
|
||||||
import org.eclipse.jgit.lib.ProgressMonitor;
|
import org.eclipse.jgit.lib.ProgressMonitor;
|
||||||
@@ -146,15 +131,6 @@ public class Reindex extends SiteProgram {
|
|||||||
}
|
}
|
||||||
modules.add(changeIndexModule);
|
modules.add(changeIndexModule);
|
||||||
modules.add(dbInjector.getInstance(BatchProgramModule.class));
|
modules.add(dbInjector.getInstance(BatchProgramModule.class));
|
||||||
modules.add(new AbstractModule() {
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
if (recheckMergeable) {
|
|
||||||
install(new MergeabilityModule());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return dbInjector.createChildInjector(modules);
|
return dbInjector.createChildInjector(modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,38 +143,6 @@ public class Reindex extends SiteProgram {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MergeabilityModule extends FactoryModule {
|
|
||||||
@Override
|
|
||||||
public void configure() {
|
|
||||||
factory(PatchSetInserter.Factory.class);
|
|
||||||
bind(ReplacePatchSetSender.Factory.class).toProvider(
|
|
||||||
Providers.<ReplacePatchSetSender.Factory>of(null));
|
|
||||||
|
|
||||||
factory(MergeUtil.Factory.class);
|
|
||||||
install(new NoteDbModule());
|
|
||||||
install(new BatchGitModule());
|
|
||||||
install(new DefaultCacheFactory.Module());
|
|
||||||
install(MergeabilityCache.module());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
@MergeabilityChecksExecutor(Priority.BACKGROUND)
|
|
||||||
public WorkQueue.Executor createMergeabilityChecksExecutor(
|
|
||||||
WorkQueue queues) {
|
|
||||||
return queues.createQueue(1, "MergeabilityChecks");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
@MergeabilityChecksExecutor(Priority.INTERACTIVE)
|
|
||||||
public WorkQueue.Executor createInteractiveMergeabilityChecksExecutor(
|
|
||||||
@MergeabilityChecksExecutor(Priority.BACKGROUND)
|
|
||||||
WorkQueue.Executor bg) {
|
|
||||||
return bg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int indexAll() throws Exception {
|
private int indexAll() throws Exception {
|
||||||
ReviewDb db = sysInjector.getInstance(ReviewDb.class);
|
ReviewDb db = sysInjector.getInstance(ReviewDb.class);
|
||||||
ProgressMonitor pm = new TextProgressMonitor();
|
ProgressMonitor pm = new TextProgressMonitor();
|
||||||
|
@@ -30,14 +30,22 @@ import com.google.gerrit.server.account.GroupIncludeCacheImpl;
|
|||||||
import com.google.gerrit.server.cache.CacheRemovalListener;
|
import com.google.gerrit.server.cache.CacheRemovalListener;
|
||||||
import com.google.gerrit.server.cache.h2.DefaultCacheFactory;
|
import com.google.gerrit.server.cache.h2.DefaultCacheFactory;
|
||||||
import com.google.gerrit.server.change.ChangeKindCacheImpl;
|
import com.google.gerrit.server.change.ChangeKindCacheImpl;
|
||||||
|
import com.google.gerrit.server.change.MergeabilityCache;
|
||||||
|
import com.google.gerrit.server.change.MergeabilityChecksExecutor;
|
||||||
|
import com.google.gerrit.server.change.MergeabilityChecksExecutor.Priority;
|
||||||
|
import com.google.gerrit.server.change.PatchSetInserter;
|
||||||
import com.google.gerrit.server.config.CanonicalWebUrl;
|
import com.google.gerrit.server.config.CanonicalWebUrl;
|
||||||
import com.google.gerrit.server.config.CanonicalWebUrlProvider;
|
import com.google.gerrit.server.config.CanonicalWebUrlProvider;
|
||||||
import com.google.gerrit.server.config.DisableReverseDnsLookup;
|
import com.google.gerrit.server.config.DisableReverseDnsLookup;
|
||||||
import com.google.gerrit.server.config.DisableReverseDnsLookupProvider;
|
import com.google.gerrit.server.config.DisableReverseDnsLookupProvider;
|
||||||
import com.google.gerrit.server.config.FactoryModule;
|
import com.google.gerrit.server.config.FactoryModule;
|
||||||
import com.google.gerrit.server.git.ChangeCache;
|
import com.google.gerrit.server.git.ChangeCache;
|
||||||
|
import com.google.gerrit.server.git.MergeUtil;
|
||||||
import com.google.gerrit.server.git.TagCache;
|
import com.google.gerrit.server.git.TagCache;
|
||||||
|
import com.google.gerrit.server.git.WorkQueue;
|
||||||
import com.google.gerrit.server.group.GroupModule;
|
import com.google.gerrit.server.group.GroupModule;
|
||||||
|
import com.google.gerrit.server.mail.ReplacePatchSetSender;
|
||||||
|
import com.google.gerrit.server.notedb.NoteDbModule;
|
||||||
import com.google.gerrit.server.patch.PatchListCacheImpl;
|
import com.google.gerrit.server.patch.PatchListCacheImpl;
|
||||||
import com.google.gerrit.server.project.AccessControlModule;
|
import com.google.gerrit.server.project.AccessControlModule;
|
||||||
import com.google.gerrit.server.project.CommentLinkInfo;
|
import com.google.gerrit.server.project.CommentLinkInfo;
|
||||||
@@ -48,6 +56,8 @@ import com.google.gerrit.server.project.SectionSortCache;
|
|||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import com.google.inject.util.Providers;
|
import com.google.inject.util.Providers;
|
||||||
|
|
||||||
@@ -87,10 +97,16 @@ public class BatchProgramModule extends FactoryModule {
|
|||||||
.toProvider(DisableReverseDnsLookupProvider.class).in(SINGLETON);
|
.toProvider(DisableReverseDnsLookupProvider.class).in(SINGLETON);
|
||||||
bind(IdentifiedUser.class)
|
bind(IdentifiedUser.class)
|
||||||
.toProvider(Providers.<IdentifiedUser> of(null));
|
.toProvider(Providers.<IdentifiedUser> of(null));
|
||||||
|
bind(ReplacePatchSetSender.Factory.class).toProvider(
|
||||||
|
Providers.<ReplacePatchSetSender.Factory>of(null));
|
||||||
bind(CurrentUser.class).to(IdentifiedUser.class);
|
bind(CurrentUser.class).to(IdentifiedUser.class);
|
||||||
|
factory(MergeUtil.Factory.class);
|
||||||
|
factory(PatchSetInserter.Factory.class);
|
||||||
install(new AccessControlModule());
|
install(new AccessControlModule());
|
||||||
|
install(new BatchGitModule());
|
||||||
install(new DefaultCacheFactory.Module());
|
install(new DefaultCacheFactory.Module());
|
||||||
install(new GroupModule());
|
install(new GroupModule());
|
||||||
|
install(new NoteDbModule());
|
||||||
install(new PrologModule());
|
install(new PrologModule());
|
||||||
install(AccountByEmailCacheImpl.module());
|
install(AccountByEmailCacheImpl.module());
|
||||||
install(AccountCacheImpl.module());
|
install(AccountCacheImpl.module());
|
||||||
@@ -100,9 +116,27 @@ public class BatchProgramModule extends FactoryModule {
|
|||||||
install(SectionSortCache.module());
|
install(SectionSortCache.module());
|
||||||
install(ChangeKindCacheImpl.module());
|
install(ChangeKindCacheImpl.module());
|
||||||
install(ChangeCache.module());
|
install(ChangeCache.module());
|
||||||
|
install(MergeabilityCache.module());
|
||||||
install(TagCache.module());
|
install(TagCache.module());
|
||||||
factory(CapabilityControl.Factory.class);
|
factory(CapabilityControl.Factory.class);
|
||||||
factory(ChangeData.Factory.class);
|
factory(ChangeData.Factory.class);
|
||||||
factory(ProjectState.Factory.class);
|
factory(ProjectState.Factory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@MergeabilityChecksExecutor(Priority.BACKGROUND)
|
||||||
|
public WorkQueue.Executor createMergeabilityChecksExecutor(
|
||||||
|
WorkQueue queues) {
|
||||||
|
return queues.createQueue(1, "MergeabilityChecks");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@MergeabilityChecksExecutor(Priority.INTERACTIVE)
|
||||||
|
public WorkQueue.Executor createInteractiveMergeabilityChecksExecutor(
|
||||||
|
@MergeabilityChecksExecutor(Priority.BACKGROUND)
|
||||||
|
WorkQueue.Executor bg) {
|
||||||
|
return bg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -38,9 +38,12 @@ import com.google.gerrit.server.git.MergeException;
|
|||||||
import com.google.gerrit.server.git.strategy.SubmitStrategyFactory;
|
import com.google.gerrit.server.git.strategy.SubmitStrategyFactory;
|
||||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Key;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
import com.google.inject.name.Named;
|
import com.google.inject.name.Named;
|
||||||
|
import com.google.inject.name.Names;
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||||
import org.eclipse.jgit.errors.MissingObjectException;
|
import org.eclipse.jgit.errors.MissingObjectException;
|
||||||
@@ -84,6 +87,12 @@ public class MergeabilityCache {
|
|||||||
"SubmitType <-> char BiMap needs updating");
|
"SubmitType <-> char BiMap needs updating");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static Key bindingKey() {
|
||||||
|
return Key.get(new TypeLiteral<LoadingCache<EntryKey, Boolean>>() {},
|
||||||
|
Names.named(CACHE_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
public static Module module() {
|
public static Module module() {
|
||||||
return new CacheModule() {
|
return new CacheModule() {
|
||||||
@Override
|
@Override
|
||||||
|
@@ -441,13 +441,25 @@ public class ChangeField {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Whether the change is mergeable. */
|
/** Whether the change is mergeable. */
|
||||||
public static final FieldDef<ChangeData, String> MERGEABLE =
|
@Deprecated
|
||||||
|
public static final FieldDef<ChangeData, String> LEGACY_MERGEABLE =
|
||||||
new FieldDef.Single<ChangeData, String>(
|
new FieldDef.Single<ChangeData, String>(
|
||||||
ChangeQueryBuilder.FIELD_MERGEABLE, FieldType.EXACT, false) {
|
ChangeQueryBuilder.FIELD_MERGEABLE, FieldType.EXACT, false) {
|
||||||
@Override
|
@Override
|
||||||
public String get(ChangeData input, FillArgs args)
|
public String get(ChangeData input, FillArgs args)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
return input.change().isMergeable() ? "1" : null;
|
return input.isMergeable() ? "1" : null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Whether the change is mergeable. */
|
||||||
|
public static final FieldDef<ChangeData, String> MERGEABLE =
|
||||||
|
new FieldDef.Single<ChangeData, String>(
|
||||||
|
"mergeable2", FieldType.EXACT, true) {
|
||||||
|
@Override
|
||||||
|
public String get(ChangeData input, FillArgs args)
|
||||||
|
throws OrmException {
|
||||||
|
return input.isMergeable() ? "1" : "0";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -118,7 +118,7 @@ public class ChangeSchemas {
|
|||||||
ChangeField.COMMENT,
|
ChangeField.COMMENT,
|
||||||
ChangeField.CHANGE,
|
ChangeField.CHANGE,
|
||||||
ChangeField.APPROVAL,
|
ChangeField.APPROVAL,
|
||||||
ChangeField.MERGEABLE);
|
ChangeField.LEGACY_MERGEABLE);
|
||||||
|
|
||||||
// For upgrade to Lucene 4.6.0 index format only.
|
// For upgrade to Lucene 4.6.0 index format only.
|
||||||
static final Schema<ChangeData> V6 = release(V5.getFields().values());
|
static final Schema<ChangeData> V6 = release(V5.getFields().values());
|
||||||
@@ -145,7 +145,7 @@ public class ChangeSchemas {
|
|||||||
ChangeField.COMMENT,
|
ChangeField.COMMENT,
|
||||||
ChangeField.CHANGE,
|
ChangeField.CHANGE,
|
||||||
ChangeField.APPROVAL,
|
ChangeField.APPROVAL,
|
||||||
ChangeField.MERGEABLE);
|
ChangeField.LEGACY_MERGEABLE);
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
static final Schema<ChangeData> V8 = release(
|
static final Schema<ChangeData> V8 = release(
|
||||||
@@ -168,7 +168,7 @@ public class ChangeSchemas {
|
|||||||
ChangeField.COMMENT,
|
ChangeField.COMMENT,
|
||||||
ChangeField.CHANGE,
|
ChangeField.CHANGE,
|
||||||
ChangeField.APPROVAL,
|
ChangeField.APPROVAL,
|
||||||
ChangeField.MERGEABLE);
|
ChangeField.LEGACY_MERGEABLE);
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
static final Schema<ChangeData> V9 = release(
|
static final Schema<ChangeData> V9 = release(
|
||||||
@@ -192,8 +192,9 @@ public class ChangeSchemas {
|
|||||||
ChangeField.COMMENT,
|
ChangeField.COMMENT,
|
||||||
ChangeField.CHANGE,
|
ChangeField.CHANGE,
|
||||||
ChangeField.APPROVAL,
|
ChangeField.APPROVAL,
|
||||||
ChangeField.MERGEABLE);
|
ChangeField.LEGACY_MERGEABLE);
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
static final Schema<ChangeData> V10 = release(
|
static final Schema<ChangeData> V10 = release(
|
||||||
ChangeField.LEGACY_ID,
|
ChangeField.LEGACY_ID,
|
||||||
ChangeField.ID,
|
ChangeField.ID,
|
||||||
@@ -215,8 +216,9 @@ public class ChangeSchemas {
|
|||||||
ChangeField.COMMENT,
|
ChangeField.COMMENT,
|
||||||
ChangeField.CHANGE,
|
ChangeField.CHANGE,
|
||||||
ChangeField.APPROVAL,
|
ChangeField.APPROVAL,
|
||||||
ChangeField.MERGEABLE);
|
ChangeField.LEGACY_MERGEABLE);
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
static final Schema<ChangeData> V11 = release(
|
static final Schema<ChangeData> V11 = release(
|
||||||
ChangeField.LEGACY_ID,
|
ChangeField.LEGACY_ID,
|
||||||
ChangeField.ID,
|
ChangeField.ID,
|
||||||
@@ -238,7 +240,7 @@ public class ChangeSchemas {
|
|||||||
ChangeField.COMMENT,
|
ChangeField.COMMENT,
|
||||||
ChangeField.CHANGE,
|
ChangeField.CHANGE,
|
||||||
ChangeField.APPROVAL,
|
ChangeField.APPROVAL,
|
||||||
ChangeField.MERGEABLE,
|
ChangeField.LEGACY_MERGEABLE,
|
||||||
ChangeField.ADDED,
|
ChangeField.ADDED,
|
||||||
ChangeField.DELETED,
|
ChangeField.DELETED,
|
||||||
ChangeField.DELTA);
|
ChangeField.DELTA);
|
||||||
@@ -246,7 +248,35 @@ public class ChangeSchemas {
|
|||||||
// For upgrade to Lucene 4.10.0 index format only.
|
// For upgrade to Lucene 4.10.0 index format only.
|
||||||
static final Schema<ChangeData> V12 = release(V11.getFields().values());
|
static final Schema<ChangeData> V12 = release(V11.getFields().values());
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
static final Schema<ChangeData> V13 = release(
|
static final Schema<ChangeData> V13 = release(
|
||||||
|
ChangeField.LEGACY_ID,
|
||||||
|
ChangeField.ID,
|
||||||
|
ChangeField.STATUS,
|
||||||
|
ChangeField.PROJECT,
|
||||||
|
ChangeField.PROJECTS,
|
||||||
|
ChangeField.REF,
|
||||||
|
ChangeField.TOPIC,
|
||||||
|
ChangeField.UPDATED,
|
||||||
|
ChangeField.FILE_PART,
|
||||||
|
ChangeField.PATH,
|
||||||
|
ChangeField.OWNER,
|
||||||
|
ChangeField.REVIEWER,
|
||||||
|
ChangeField.COMMIT,
|
||||||
|
ChangeField.TR,
|
||||||
|
ChangeField.LABEL,
|
||||||
|
ChangeField.REVIEWED,
|
||||||
|
ChangeField.COMMIT_MESSAGE,
|
||||||
|
ChangeField.COMMENT,
|
||||||
|
ChangeField.CHANGE,
|
||||||
|
ChangeField.APPROVAL,
|
||||||
|
ChangeField.LEGACY_MERGEABLE,
|
||||||
|
ChangeField.ADDED,
|
||||||
|
ChangeField.DELETED,
|
||||||
|
ChangeField.DELTA,
|
||||||
|
ChangeField.HASHTAG);
|
||||||
|
|
||||||
|
static final Schema<ChangeData> V14 = release(
|
||||||
ChangeField.LEGACY_ID,
|
ChangeField.LEGACY_ID,
|
||||||
ChangeField.ID,
|
ChangeField.ID,
|
||||||
ChangeField.STATUS,
|
ChangeField.STATUS,
|
||||||
|
@@ -26,11 +26,11 @@ import com.google.inject.name.Named;
|
|||||||
|
|
||||||
public class BasicChangeRewrites extends QueryRewriter<ChangeData> {
|
public class BasicChangeRewrites extends QueryRewriter<ChangeData> {
|
||||||
private static final ChangeQueryBuilder BUILDER = new ChangeQueryBuilder(
|
private static final ChangeQueryBuilder BUILDER = new ChangeQueryBuilder(
|
||||||
new ChangeQueryBuilder.Arguments( //
|
new ChangeQueryBuilder.Arguments(
|
||||||
new InvalidProvider<ReviewDb>(), //
|
new InvalidProvider<ReviewDb>(),
|
||||||
new InvalidProvider<ChangeQueryRewriter>(), //
|
new InvalidProvider<ChangeQueryRewriter>(),
|
||||||
null, null, null, null, null, null, null, //
|
null, null, null, null, null, null, null, null, null, null, null,
|
||||||
null, null, null, null, null, null, null, null, null, null, null),
|
null, null, null, null, null, null, null, null),
|
||||||
null);
|
null);
|
||||||
|
|
||||||
private static final QueryRewriter.Definition<ChangeData, BasicChangeRewrites> mydef =
|
private static final QueryRewriter.Definition<ChangeData, BasicChangeRewrites> mydef =
|
||||||
|
@@ -23,6 +23,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.SetMultimap;
|
import com.google.common.collect.SetMultimap;
|
||||||
import com.google.gerrit.common.data.SubmitRecord;
|
import com.google.gerrit.common.data.SubmitRecord;
|
||||||
|
import com.google.gerrit.common.data.SubmitTypeRecord;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||||
@@ -36,7 +37,9 @@ import com.google.gerrit.server.ChangeMessagesUtil;
|
|||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.PatchLineCommentsUtil;
|
import com.google.gerrit.server.PatchLineCommentsUtil;
|
||||||
|
import com.google.gerrit.server.change.MergeabilityCache;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
|
import com.google.gerrit.server.git.MergeUtil;
|
||||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||||
import com.google.gerrit.server.notedb.NotesMigration;
|
import com.google.gerrit.server.notedb.NotesMigration;
|
||||||
import com.google.gerrit.server.notedb.ReviewerState;
|
import com.google.gerrit.server.notedb.ReviewerState;
|
||||||
@@ -46,6 +49,8 @@ import com.google.gerrit.server.patch.PatchListEntry;
|
|||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.gerrit.server.project.ChangeControl;
|
import com.google.gerrit.server.project.ChangeControl;
|
||||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||||
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
|
import com.google.gerrit.server.project.SubmitRuleEvaluator;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.gwtorm.server.ResultSet;
|
import com.google.gwtorm.server.ResultSet;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
@@ -55,6 +60,7 @@ import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
|||||||
import org.eclipse.jgit.errors.MissingObjectException;
|
import org.eclipse.jgit.errors.MissingObjectException;
|
||||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
|
import org.eclipse.jgit.lib.Ref;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.eclipse.jgit.revwalk.FooterLine;
|
import org.eclipse.jgit.revwalk.FooterLine;
|
||||||
import org.eclipse.jgit.revwalk.RevCommit;
|
import org.eclipse.jgit.revwalk.RevCommit;
|
||||||
@@ -154,8 +160,8 @@ public class ChangeData {
|
|||||||
* @return instance for testing.
|
* @return instance for testing.
|
||||||
*/
|
*/
|
||||||
static ChangeData createForTest(Change.Id id, int currentPatchSetId) {
|
static ChangeData createForTest(Change.Id id, int currentPatchSetId) {
|
||||||
ChangeData cd = new ChangeData(null, null, null, null, null,
|
ChangeData cd = new ChangeData(null, null, null, null, null, null, null,
|
||||||
null, null, null, null, null, id);
|
null, null, null, null, null, null, id);
|
||||||
cd.currentPatchSet = new PatchSet(new PatchSet.Id(id, currentPatchSetId));
|
cd.currentPatchSet = new PatchSet(new PatchSet.Id(id, currentPatchSetId));
|
||||||
return cd;
|
return cd;
|
||||||
}
|
}
|
||||||
@@ -164,12 +170,15 @@ public class ChangeData {
|
|||||||
private final GitRepositoryManager repoManager;
|
private final GitRepositoryManager repoManager;
|
||||||
private final ChangeControl.GenericFactory changeControlFactory;
|
private final ChangeControl.GenericFactory changeControlFactory;
|
||||||
private final IdentifiedUser.GenericFactory userFactory;
|
private final IdentifiedUser.GenericFactory userFactory;
|
||||||
|
private final ProjectCache projectCache;
|
||||||
|
private final MergeUtil.Factory mergeUtilFactory;
|
||||||
private final ChangeNotes.Factory notesFactory;
|
private final ChangeNotes.Factory notesFactory;
|
||||||
private final ApprovalsUtil approvalsUtil;
|
private final ApprovalsUtil approvalsUtil;
|
||||||
private final ChangeMessagesUtil cmUtil;
|
private final ChangeMessagesUtil cmUtil;
|
||||||
private final PatchLineCommentsUtil plcUtil;
|
private final PatchLineCommentsUtil plcUtil;
|
||||||
private final PatchListCache patchListCache;
|
private final PatchListCache patchListCache;
|
||||||
private final NotesMigration notesMigration;
|
private final NotesMigration notesMigration;
|
||||||
|
private final MergeabilityCache mergeabilityCache;
|
||||||
private final Change.Id legacyId;
|
private final Change.Id legacyId;
|
||||||
private ChangeDataSource returnedBySource;
|
private ChangeDataSource returnedBySource;
|
||||||
private Change change;
|
private Change change;
|
||||||
@@ -187,30 +196,37 @@ public class ChangeData {
|
|||||||
private List<ChangeMessage> messages;
|
private List<ChangeMessage> messages;
|
||||||
private List<SubmitRecord> submitRecords;
|
private List<SubmitRecord> submitRecords;
|
||||||
private ChangedLines changedLines;
|
private ChangedLines changedLines;
|
||||||
|
private Boolean mergeable;
|
||||||
|
|
||||||
@AssistedInject
|
@AssistedInject
|
||||||
private ChangeData(
|
private ChangeData(
|
||||||
GitRepositoryManager repoManager,
|
GitRepositoryManager repoManager,
|
||||||
ChangeControl.GenericFactory changeControlFactory,
|
ChangeControl.GenericFactory changeControlFactory,
|
||||||
IdentifiedUser.GenericFactory userFactory,
|
IdentifiedUser.GenericFactory userFactory,
|
||||||
|
ProjectCache projectCache,
|
||||||
|
MergeUtil.Factory mergeUtilFactory,
|
||||||
ChangeNotes.Factory notesFactory,
|
ChangeNotes.Factory notesFactory,
|
||||||
ApprovalsUtil approvalsUtil,
|
ApprovalsUtil approvalsUtil,
|
||||||
ChangeMessagesUtil cmUtil,
|
ChangeMessagesUtil cmUtil,
|
||||||
PatchLineCommentsUtil plcUtil,
|
PatchLineCommentsUtil plcUtil,
|
||||||
PatchListCache patchListCache,
|
PatchListCache patchListCache,
|
||||||
NotesMigration notesMigration,
|
NotesMigration notesMigration,
|
||||||
|
MergeabilityCache mergeabilityCache,
|
||||||
@Assisted ReviewDb db,
|
@Assisted ReviewDb db,
|
||||||
@Assisted Change.Id id) {
|
@Assisted Change.Id id) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.repoManager = repoManager;
|
this.repoManager = repoManager;
|
||||||
this.changeControlFactory = changeControlFactory;
|
this.changeControlFactory = changeControlFactory;
|
||||||
this.userFactory = userFactory;
|
this.userFactory = userFactory;
|
||||||
|
this.projectCache = projectCache;
|
||||||
|
this.mergeUtilFactory = mergeUtilFactory;
|
||||||
this.notesFactory = notesFactory;
|
this.notesFactory = notesFactory;
|
||||||
this.approvalsUtil = approvalsUtil;
|
this.approvalsUtil = approvalsUtil;
|
||||||
this.cmUtil = cmUtil;
|
this.cmUtil = cmUtil;
|
||||||
this.plcUtil = plcUtil;
|
this.plcUtil = plcUtil;
|
||||||
this.patchListCache = patchListCache;
|
this.patchListCache = patchListCache;
|
||||||
this.notesMigration = notesMigration;
|
this.notesMigration = notesMigration;
|
||||||
|
this.mergeabilityCache = mergeabilityCache;
|
||||||
legacyId = id;
|
legacyId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,24 +235,30 @@ public class ChangeData {
|
|||||||
GitRepositoryManager repoManager,
|
GitRepositoryManager repoManager,
|
||||||
ChangeControl.GenericFactory changeControlFactory,
|
ChangeControl.GenericFactory changeControlFactory,
|
||||||
IdentifiedUser.GenericFactory userFactory,
|
IdentifiedUser.GenericFactory userFactory,
|
||||||
|
ProjectCache projectCache,
|
||||||
|
MergeUtil.Factory mergeUtilFactory,
|
||||||
ChangeNotes.Factory notesFactory,
|
ChangeNotes.Factory notesFactory,
|
||||||
ApprovalsUtil approvalsUtil,
|
ApprovalsUtil approvalsUtil,
|
||||||
ChangeMessagesUtil cmUtil,
|
ChangeMessagesUtil cmUtil,
|
||||||
PatchLineCommentsUtil plcUtil,
|
PatchLineCommentsUtil plcUtil,
|
||||||
PatchListCache patchListCache,
|
PatchListCache patchListCache,
|
||||||
NotesMigration notesMigration,
|
NotesMigration notesMigration,
|
||||||
|
MergeabilityCache mergeabilityCache,
|
||||||
@Assisted ReviewDb db,
|
@Assisted ReviewDb db,
|
||||||
@Assisted Change c) {
|
@Assisted Change c) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.repoManager = repoManager;
|
this.repoManager = repoManager;
|
||||||
this.changeControlFactory = changeControlFactory;
|
this.changeControlFactory = changeControlFactory;
|
||||||
this.userFactory = userFactory;
|
this.userFactory = userFactory;
|
||||||
|
this.projectCache = projectCache;
|
||||||
|
this.mergeUtilFactory = mergeUtilFactory;
|
||||||
this.notesFactory = notesFactory;
|
this.notesFactory = notesFactory;
|
||||||
this.approvalsUtil = approvalsUtil;
|
this.approvalsUtil = approvalsUtil;
|
||||||
this.cmUtil = cmUtil;
|
this.cmUtil = cmUtil;
|
||||||
this.plcUtil = plcUtil;
|
this.plcUtil = plcUtil;
|
||||||
this.patchListCache = patchListCache;
|
this.patchListCache = patchListCache;
|
||||||
this.notesMigration = notesMigration;
|
this.notesMigration = notesMigration;
|
||||||
|
this.mergeabilityCache = mergeabilityCache;
|
||||||
legacyId = c.getId();
|
legacyId = c.getId();
|
||||||
change = c;
|
change = c;
|
||||||
}
|
}
|
||||||
@@ -246,24 +268,30 @@ public class ChangeData {
|
|||||||
GitRepositoryManager repoManager,
|
GitRepositoryManager repoManager,
|
||||||
ChangeControl.GenericFactory changeControlFactory,
|
ChangeControl.GenericFactory changeControlFactory,
|
||||||
IdentifiedUser.GenericFactory userFactory,
|
IdentifiedUser.GenericFactory userFactory,
|
||||||
|
ProjectCache projectCache,
|
||||||
|
MergeUtil.Factory mergeUtilFactory,
|
||||||
ChangeNotes.Factory notesFactory,
|
ChangeNotes.Factory notesFactory,
|
||||||
ApprovalsUtil approvalsUtil,
|
ApprovalsUtil approvalsUtil,
|
||||||
ChangeMessagesUtil cmUtil,
|
ChangeMessagesUtil cmUtil,
|
||||||
PatchLineCommentsUtil plcUtil,
|
PatchLineCommentsUtil plcUtil,
|
||||||
PatchListCache patchListCache,
|
PatchListCache patchListCache,
|
||||||
NotesMigration notesMigration,
|
NotesMigration notesMigration,
|
||||||
|
MergeabilityCache mergeabilityCache,
|
||||||
@Assisted ReviewDb db,
|
@Assisted ReviewDb db,
|
||||||
@Assisted ChangeControl c) {
|
@Assisted ChangeControl c) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.repoManager = repoManager;
|
this.repoManager = repoManager;
|
||||||
this.changeControlFactory = changeControlFactory;
|
this.changeControlFactory = changeControlFactory;
|
||||||
this.userFactory = userFactory;
|
this.userFactory = userFactory;
|
||||||
|
this.projectCache = projectCache;
|
||||||
|
this.mergeUtilFactory = mergeUtilFactory;
|
||||||
this.notesFactory = notesFactory;
|
this.notesFactory = notesFactory;
|
||||||
this.approvalsUtil = approvalsUtil;
|
this.approvalsUtil = approvalsUtil;
|
||||||
this.cmUtil = cmUtil;
|
this.cmUtil = cmUtil;
|
||||||
this.plcUtil = plcUtil;
|
this.plcUtil = plcUtil;
|
||||||
this.patchListCache = patchListCache;
|
this.patchListCache = patchListCache;
|
||||||
this.notesMigration = notesMigration;
|
this.notesMigration = notesMigration;
|
||||||
|
this.mergeabilityCache = mergeabilityCache;
|
||||||
legacyId = c.getChange().getId();
|
legacyId = c.getChange().getId();
|
||||||
change = c.getChange();
|
change = c.getChange();
|
||||||
changeControl = c;
|
changeControl = c;
|
||||||
@@ -555,6 +583,45 @@ public class ChangeData {
|
|||||||
return submitRecords;
|
return submitRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMergeable(boolean mergeable) {
|
||||||
|
this.mergeable = mergeable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMergeable() throws OrmException {
|
||||||
|
if (mergeable == null) {
|
||||||
|
Change c = change();
|
||||||
|
if (c.getStatus() == Change.Status.MERGED) {
|
||||||
|
mergeable = true;
|
||||||
|
} else {
|
||||||
|
PatchSet ps = currentPatchSet();
|
||||||
|
Repository repo = null;
|
||||||
|
try {
|
||||||
|
repo = repoManager.openRepository(c.getProject());
|
||||||
|
Ref ref = repo.getRef(c.getDest().get());
|
||||||
|
SubmitTypeRecord rec = new SubmitRuleEvaluator(this)
|
||||||
|
.getSubmitType();
|
||||||
|
if (rec.status != SubmitTypeRecord.Status.OK) {
|
||||||
|
throw new OrmException(
|
||||||
|
"Error in mergeability check: " + rec.errorMessage);
|
||||||
|
}
|
||||||
|
String mergeStrategy = mergeUtilFactory
|
||||||
|
.create(projectCache.get(c.getProject()))
|
||||||
|
.mergeStrategyName();
|
||||||
|
mergeable = mergeabilityCache.get(
|
||||||
|
ObjectId.fromString(ps.getRevision().get()),
|
||||||
|
ref, rec.type, mergeStrategy, c.getDest(), repo, db);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new OrmException(e);
|
||||||
|
} finally {
|
||||||
|
if (repo != null) {
|
||||||
|
repo.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mergeable;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return MoreObjects.toStringHelper(this).addValue(getId()).toString();
|
return MoreObjects.toStringHelper(this).addValue(getId()).toString();
|
||||||
|
@@ -37,6 +37,7 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
|||||||
import com.google.gerrit.server.git.strategy.SubmitStrategyFactory;
|
import com.google.gerrit.server.git.strategy.SubmitStrategyFactory;
|
||||||
import com.google.gerrit.server.index.ChangeField;
|
import com.google.gerrit.server.index.ChangeField;
|
||||||
import com.google.gerrit.server.index.ChangeIndex;
|
import com.google.gerrit.server.index.ChangeIndex;
|
||||||
|
import com.google.gerrit.server.index.FieldDef;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
import com.google.gerrit.server.index.IndexCollection;
|
||||||
import com.google.gerrit.server.index.Schema;
|
import com.google.gerrit.server.index.Schema;
|
||||||
import com.google.gerrit.server.patch.PatchListCache;
|
import com.google.gerrit.server.patch.PatchListCache;
|
||||||
@@ -146,6 +147,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
final CapabilityControl.Factory capabilityControlFactory;
|
final CapabilityControl.Factory capabilityControlFactory;
|
||||||
final ChangeControl.GenericFactory changeControlGenericFactory;
|
final ChangeControl.GenericFactory changeControlGenericFactory;
|
||||||
final ChangeData.Factory changeDataFactory;
|
final ChangeData.Factory changeDataFactory;
|
||||||
|
final FieldDef.FillArgs fillArgs;
|
||||||
final PatchLineCommentsUtil plcUtil;
|
final PatchLineCommentsUtil plcUtil;
|
||||||
final AccountResolver accountResolver;
|
final AccountResolver accountResolver;
|
||||||
final GroupBackend groupBackend;
|
final GroupBackend groupBackend;
|
||||||
@@ -169,6 +171,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
CapabilityControl.Factory capabilityControlFactory,
|
CapabilityControl.Factory capabilityControlFactory,
|
||||||
ChangeControl.GenericFactory changeControlGenericFactory,
|
ChangeControl.GenericFactory changeControlGenericFactory,
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
|
FieldDef.FillArgs fillArgs,
|
||||||
PatchLineCommentsUtil plcUtil,
|
PatchLineCommentsUtil plcUtil,
|
||||||
AccountResolver accountResolver,
|
AccountResolver accountResolver,
|
||||||
GroupBackend groupBackend,
|
GroupBackend groupBackend,
|
||||||
@@ -189,6 +192,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
this.capabilityControlFactory = capabilityControlFactory;
|
this.capabilityControlFactory = capabilityControlFactory;
|
||||||
this.changeControlGenericFactory = changeControlGenericFactory;
|
this.changeControlGenericFactory = changeControlGenericFactory;
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
|
this.fillArgs = fillArgs;
|
||||||
this.plcUtil = plcUtil;
|
this.plcUtil = plcUtil;
|
||||||
this.accountResolver = accountResolver;
|
this.accountResolver = accountResolver;
|
||||||
this.groupBackend = groupBackend;
|
this.groupBackend = groupBackend;
|
||||||
@@ -326,7 +330,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ("mergeable".equalsIgnoreCase(value)) {
|
if ("mergeable".equalsIgnoreCase(value)) {
|
||||||
return new IsMergeablePredicate();
|
return new IsMergeablePredicate(schema(args.indexes), args.fillArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@@ -14,20 +14,39 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.query.change;
|
package com.google.gerrit.server.query.change;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import static com.google.gerrit.server.index.ChangeField.MERGEABLE;
|
||||||
|
|
||||||
import com.google.gerrit.server.index.ChangeField;
|
import com.google.gerrit.server.index.ChangeField;
|
||||||
|
import com.google.gerrit.server.index.FieldDef;
|
||||||
|
import com.google.gerrit.server.index.FieldDef.FillArgs;
|
||||||
import com.google.gerrit.server.index.IndexPredicate;
|
import com.google.gerrit.server.index.IndexPredicate;
|
||||||
|
import com.google.gerrit.server.index.Schema;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class IsMergeablePredicate extends IndexPredicate<ChangeData> {
|
class IsMergeablePredicate extends IndexPredicate<ChangeData> {
|
||||||
IsMergeablePredicate() {
|
@SuppressWarnings("deprecation")
|
||||||
super(ChangeField.MERGEABLE, "1");
|
static FieldDef<ChangeData, ?> mergeableField(Schema<ChangeData> schema) {
|
||||||
|
if (schema == null) {
|
||||||
|
return ChangeField.LEGACY_MERGEABLE;
|
||||||
|
}
|
||||||
|
FieldDef<ChangeData, ?> f = schema.getFields().get(MERGEABLE.getName());
|
||||||
|
if (f != null) {
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
return schema.getFields().get(ChangeField.LEGACY_MERGEABLE.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private final FillArgs args;
|
||||||
|
|
||||||
|
IsMergeablePredicate(Schema<ChangeData> schema,
|
||||||
|
FillArgs args) {
|
||||||
|
super(mergeableField(schema), "1");
|
||||||
|
this.args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(ChangeData object) throws OrmException {
|
public boolean match(ChangeData object) throws OrmException {
|
||||||
Change c = object.change();
|
return getValue().equals(getField().get(object, args));
|
||||||
return c != null && c.isMergeable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -26,8 +26,8 @@ public class FakeQueryBuilder extends ChangeQueryBuilder {
|
|||||||
new FakeQueryBuilder.Definition<>(
|
new FakeQueryBuilder.Definition<>(
|
||||||
FakeQueryBuilder.class),
|
FakeQueryBuilder.class),
|
||||||
new ChangeQueryBuilder.Arguments(null, null, null, null, null, null,
|
new ChangeQueryBuilder.Arguments(null, null, null, null, null, null,
|
||||||
null, null, null, null, null, null, null, null, null, indexes, null,
|
null, null, null, null, null, null, null, null, null, null, indexes,
|
||||||
null, null, null),
|
null, null, null, null),
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,6 +40,7 @@ import com.google.gerrit.server.account.GroupMembership;
|
|||||||
import com.google.gerrit.server.account.ListGroupMembership;
|
import com.google.gerrit.server.account.ListGroupMembership;
|
||||||
import com.google.gerrit.server.change.ChangeKindCache;
|
import com.google.gerrit.server.change.ChangeKindCache;
|
||||||
import com.google.gerrit.server.change.ChangeKindCacheImpl;
|
import com.google.gerrit.server.change.ChangeKindCacheImpl;
|
||||||
|
import com.google.gerrit.server.change.MergeabilityCache;
|
||||||
import com.google.gerrit.server.config.AllProjectsName;
|
import com.google.gerrit.server.config.AllProjectsName;
|
||||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||||
import com.google.gerrit.server.config.AnonymousCowardNameProvider;
|
import com.google.gerrit.server.config.AnonymousCowardNameProvider;
|
||||||
@@ -50,6 +51,7 @@ import com.google.gerrit.server.config.FactoryModule;
|
|||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.server.config.SitePaths;
|
import com.google.gerrit.server.config.SitePaths;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
|
import com.google.gerrit.server.git.MergeUtil;
|
||||||
import com.google.gerrit.server.git.ProjectConfig;
|
import com.google.gerrit.server.git.ProjectConfig;
|
||||||
import com.google.gerrit.server.group.SystemGroupBackend;
|
import com.google.gerrit.server.group.SystemGroupBackend;
|
||||||
import com.google.gerrit.server.patch.PatchListCache;
|
import com.google.gerrit.server.patch.PatchListCache;
|
||||||
@@ -58,6 +60,7 @@ import com.google.gerrit.testutil.FakeAccountCache;
|
|||||||
import com.google.gerrit.testutil.InMemoryRepositoryManager;
|
import com.google.gerrit.testutil.InMemoryRepositoryManager;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.Provider;
|
||||||
import com.google.inject.util.Providers;
|
import com.google.inject.util.Providers;
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||||
@@ -253,18 +256,20 @@ public class Util {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Injector injector = Guice.createInjector(new FactoryModule() {
|
Injector injector = Guice.createInjector(new FactoryModule() {
|
||||||
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Provider nullProvider = Providers.of(null);
|
||||||
bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(
|
bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(
|
||||||
new Config());
|
new Config());
|
||||||
bind(ReviewDb.class).toProvider(Providers.<ReviewDb> of(null));
|
bind(ReviewDb.class).toProvider(nullProvider);
|
||||||
bind(GitRepositoryManager.class).toInstance(repoManager);
|
bind(GitRepositoryManager.class).toInstance(repoManager);
|
||||||
bind(PatchListCache.class)
|
bind(PatchListCache.class).toProvider(nullProvider);
|
||||||
.toProvider(Providers.<PatchListCache> of(null));
|
|
||||||
|
|
||||||
factory(CapabilityControl.Factory.class);
|
factory(CapabilityControl.Factory.class);
|
||||||
factory(ChangeControl.AssistedFactory.class);
|
factory(ChangeControl.AssistedFactory.class);
|
||||||
factory(ChangeData.Factory.class);
|
factory(ChangeData.Factory.class);
|
||||||
|
factory(MergeUtil.Factory.class);
|
||||||
bind(ProjectCache.class).toInstance(projectCache);
|
bind(ProjectCache.class).toInstance(projectCache);
|
||||||
bind(AccountCache.class).toInstance(new FakeAccountCache());
|
bind(AccountCache.class).toInstance(new FakeAccountCache());
|
||||||
bind(GroupBackend.class).to(SystemGroupBackend.class);
|
bind(GroupBackend.class).to(SystemGroupBackend.class);
|
||||||
@@ -275,6 +280,7 @@ public class Util {
|
|||||||
bind(String.class).annotatedWith(AnonymousCowardName.class)
|
bind(String.class).annotatedWith(AnonymousCowardName.class)
|
||||||
.toProvider(AnonymousCowardNameProvider.class);
|
.toProvider(AnonymousCowardNameProvider.class);
|
||||||
bind(ChangeKindCache.class).to(ChangeKindCacheImpl.NoCache.class);
|
bind(ChangeKindCache.class).to(ChangeKindCacheImpl.NoCache.class);
|
||||||
|
bind(MergeabilityCache.bindingKey()).toProvider(nullProvider);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ import java.util.zip.ZipEntry;
|
|||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
public class DocIndexer {
|
public class DocIndexer {
|
||||||
private static final Version LUCENE_VERSION = Version.LUCENE_4_10_0;
|
private static final Version LUCENE_VERSION = Version.LUCENE_4_10_1;
|
||||||
private static final Pattern SECTION_HEADER = Pattern.compile("^=+ (.*)");
|
private static final Pattern SECTION_HEADER = Pattern.compile("^=+ (.*)");
|
||||||
|
|
||||||
@Option(name = "-o", usage = "output JAR file")
|
@Option(name = "-o", usage = "output JAR file")
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
include_defs('//lib/maven.defs')
|
include_defs('//lib/maven.defs')
|
||||||
|
|
||||||
VERSION = '4.10.0'
|
VERSION = '4.10.1'
|
||||||
|
|
||||||
maven_jar(
|
maven_jar(
|
||||||
name = 'core',
|
name = 'core',
|
||||||
id = 'org.apache.lucene:lucene-core:' + VERSION,
|
id = 'org.apache.lucene:lucene-core:' + VERSION,
|
||||||
sha1 = 'a4ceea9a80e81fe84e81fe4fccce9e9930dc703a',
|
sha1 = '4ff28101d9de465b7f3cf59d7bc2892c1c118b4b',
|
||||||
license = 'Apache2.0',
|
license = 'Apache2.0',
|
||||||
exclude = [
|
exclude = [
|
||||||
'META-INF/LICENSE.txt',
|
'META-INF/LICENSE.txt',
|
||||||
@@ -16,7 +16,7 @@ maven_jar(
|
|||||||
maven_jar(
|
maven_jar(
|
||||||
name = 'analyzers-common',
|
name = 'analyzers-common',
|
||||||
id = 'org.apache.lucene:lucene-analyzers-common:' + VERSION,
|
id = 'org.apache.lucene:lucene-analyzers-common:' + VERSION,
|
||||||
sha1 = '912962d436d9851dc90091e48251c802d3b65941',
|
sha1 = '6491c6019c32e7c4f7674f238d5beaa84d3108a6',
|
||||||
license = 'Apache2.0',
|
license = 'Apache2.0',
|
||||||
exclude = [
|
exclude = [
|
||||||
'META-INF/LICENSE.txt',
|
'META-INF/LICENSE.txt',
|
||||||
@@ -27,6 +27,6 @@ maven_jar(
|
|||||||
maven_jar(
|
maven_jar(
|
||||||
name = 'query-parser',
|
name = 'query-parser',
|
||||||
id = 'org.apache.lucene:lucene-queryparser:' + VERSION,
|
id = 'org.apache.lucene:lucene-queryparser:' + VERSION,
|
||||||
sha1 = '7a00eb4b97a6cb7a5a29957b62c7f002dd71b7ff',
|
sha1 = '0174ffd89d5289037ae24759f38111285b98636d',
|
||||||
license = 'Apache2.0',
|
license = 'Apache2.0',
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user