Merge branch 'stable-2.12'

* stable-2.12:
  ResourceServlet: Fix refreshing stale resources
  Skip non-existent projects when migrating to schema version 108
  rest-api-changes.txt: Make anchor names consistent
  SiteIndexer: Always scan changes from repo/db
  Update download-commands plugin
  Handle new CommitMergeStatus REBASE_MERGE_CONFLICT in MergeOp
  Make JdbcUtil#port() public
  Allow to use GWTORM Key classes in plugins
  Update 2.12 release notes
  Update JGit to 4.1.1.201511131810-r
  Set version to 2.12
  dev-plugins: Correct missing @Inject annotation
  Mention that "submit whole topic" is experimental.

Change-Id: Ic567729ba8a90799cbaa7219b624f7e4720afa79
This commit is contained in:
Dave Borowitz
2015-11-24 16:46:43 -05:00
10 changed files with 82 additions and 62 deletions

View File

@@ -897,7 +897,7 @@ submitted.
Default is "Submit all ${topicSize} changes of the same topic (${submitSize}
changes including ancestors and other changes related by topic)".
[[change.submitWholeTopic]]change.submitWholeTopic::
[[change.submitWholeTopic]]change.submitWholeTopic (*Experimental*)::
+
Determines if the submit button submits the whole topic instead of
just the current change.

View File

@@ -283,6 +283,7 @@ can get `com.google.gerrit.pgm.init.api.AllProjectsConfig` injected:
private final ConsoleUI ui;
private final AllProjectsConfig allProjectsConfig;
@Inject
public MyInitStep(@PluginName String pluginName, ConsoleUI ui,
AllProjectsConfig allProjectsConfig) {
this.pluginName = pluginName;

View File

@@ -224,7 +224,7 @@ default. Optional fields are:
* `ALL_REVISIONS`: describe all revisions, not just current.
--
[[download_commands]]
[[download-commands]]
--
* `DOWNLOAD_COMMANDS`: include the `commands` field in the
link:#fetch-info[FetchInfo] for revisions. Only valid when the
@@ -1104,7 +1104,7 @@ message is contained in the response body.
blocked by Verified
----
[[submitted_together]]
[[submitted-together]]
=== Changes submitted together
--
'GET /changes/link:#change-id[\{change-id\}]/submitted_together'
@@ -4254,7 +4254,7 @@ set via a certain protocol.
|`commands` |optional|
The download commands for this patch set as a map that maps the command
names to the commands. +
Only set if link:#download_commands[download commands] are requested.
Only set if link:#download-commands[download commands] are requested.
|==========================
[[file-info]]

View File

@@ -35,7 +35,7 @@ Release Highlights
This release includes the following new features. See the sections below for
further details.
* New "Submit Whole Topic" / "Submitted Together" workflow.
* New change submission workflows, "Submit Whole Topic" and "Submitted Together".
* Support for GPG Keys and signed pushes.
@@ -43,8 +43,8 @@ further details.
New Features
------------
New Change Submission Workflow
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
New Change Submission Workflows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* New "Submit Whole Topic" setting.
+
@@ -53,7 +53,7 @@ link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/conf
`change.submitWholeTopic`] setting is enabled, all changes belonging to the same
topic will be submitted at the same time.
+
This setting is disabled by default.
This setting should be considered experimental, and is disabled by default.
* Submission of changes may include ancestors.
+
@@ -297,7 +297,7 @@ Upgrades
* Upgrade Jetty to 9.2.13.v20150730
* Upgrade JGit to 4.1.0.201509280440-r
* Upgrade JGit to 4.1.1.201511131810-r
* Upgrade joda-time to 2.8

View File

@@ -136,28 +136,25 @@ public abstract class ResourceServlet extends HttpServlet {
}
Resource r = cache.getIfPresent(p);
if (r == null && maybeStream(p, req, rsp)) {
try {
if (r == null) {
if (maybeStream(p, req, rsp)) {
return; // Bypass cache for large resource.
}
r = cache.get(p, newLoader(p));
}
if (refresh && r.isStale(p, this)) {
cache.invalidate(p);
r = cache.get(p, newLoader(p));
}
} catch (ExecutionException e) {
log.warn("Cannot load static resource " + req.getPathInfo(), e);
CacheHeaders.setNotCacheable(rsp);
rsp.setStatus(SC_INTERNAL_SERVER_ERROR);
return;
}
if (r == null) {
Callable<Resource> loader = newLoader(p);
try {
r = cache.get(p, loader);
if (refresh && r.isStale(p, this)) {
cache.invalidate(p);
r = cache.get(p, loader);
}
} catch (ExecutionException | IOException e) {
log.warn("Cannot load static resource " + req.getPathInfo(), e);
CacheHeaders.setNotCacheable(rsp);
rsp.setStatus(SC_INTERNAL_SERVER_ERROR);
return;
}
}
if (r == Resource.NOT_FOUND) {
notFound(rsp);
notFound(rsp); // Cached not found response.
return;
}

View File

@@ -888,6 +888,7 @@ public class MergeOp {
break;
case PATH_CONFLICT:
case REBASE_MERGE_CONFLICT:
case MANUAL_RECURSIVE_MERGE:
case CANNOT_CHERRY_PICK_ROOT:
case NOT_FAST_FORWARD:

View File

@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.cache.CacheModule;
import com.google.gerrit.server.util.ManualRequestContext;
import com.google.gerrit.server.util.OneOffRequestContext;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Module;
import com.google.inject.Singleton;
@@ -37,6 +38,7 @@ import org.eclipse.jgit.lib.Repository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
@@ -97,25 +99,29 @@ public class ScanningChangeCacheImpl implements ChangeCache {
public List<Change> load(Project.NameKey key) throws Exception {
try (Repository repo = repoManager.openRepository(key);
ManualRequestContext ctx = requestContext.open()) {
ReviewDb db = ctx.getReviewDbProvider().get();
Map<String, Ref> refs =
repo.getRefDatabase().getRefs(RefNames.REFS_CHANGES);
Set<Change.Id> ids = new LinkedHashSet<>();
for (Ref r : refs.values()) {
Change.Id id = Change.Id.fromRef(r.getName());
if (id != null) {
ids.add(id);
}
}
List<Change> changes = new ArrayList<>(ids.size());
// A batch size of N may overload get(Iterable), so use something smaller,
// but still >1.
for (List<Change.Id> batch : Iterables.partition(ids, 30)) {
Iterables.addAll(changes, db.changes().get(batch));
}
return changes;
return scan(repo, ctx.getReviewDbProvider().get());
}
}
}
public static List<Change> scan(Repository repo, ReviewDb db)
throws OrmException, IOException {
Map<String, Ref> refs =
repo.getRefDatabase().getRefs(RefNames.REFS_CHANGES);
Set<Change.Id> ids = new LinkedHashSet<>();
for (Ref r : refs.values()) {
Change.Id id = Change.Id.fromRef(r.getName());
if (id != null) {
ids.add(id);
}
}
List<Change> changes = new ArrayList<>(ids.size());
// A batch size of N may overload get(Iterable), so use something smaller,
// but still >1.
for (List<Change.Id> batch : Iterables.partition(ids, 30)) {
Iterables.addAll(changes, db.changes().get(batch));
}
return changes;
}
}

View File

@@ -33,11 +33,11 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.git.ChangeCache;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.MergeUtil;
import com.google.gerrit.server.git.MultiProgressMonitor;
import com.google.gerrit.server.git.MultiProgressMonitor.Task;
import com.google.gerrit.server.git.ScanningChangeCacheImpl;
import com.google.gerrit.server.patch.PatchListLoader;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gwtorm.server.SchemaFactory;
@@ -112,7 +112,6 @@ public class SiteIndexer {
}
private final SchemaFactory<ReviewDb> schemaFactory;
private final ChangeCache changeCache;
private final ChangeData.Factory changeDataFactory;
private final GitRepositoryManager repoManager;
private final ListeningExecutorService executor;
@@ -126,14 +125,12 @@ public class SiteIndexer {
@Inject
SiteIndexer(SchemaFactory<ReviewDb> schemaFactory,
ChangeCache changeCache,
ChangeData.Factory changeDataFactory,
GitRepositoryManager repoManager,
@IndexExecutor(BATCH) ListeningExecutorService executor,
ChangeIndexer.Factory indexerFactory,
@GerritServerConfig Config config) {
this.schemaFactory = schemaFactory;
this.changeCache = changeCache;
this.changeDataFactory = changeDataFactory;
this.repoManager = repoManager;
this.executor = executor;
@@ -241,7 +238,7 @@ public class SiteIndexer {
try (Repository repo = repoManager.openRepository(project);
ReviewDb db = schemaFactory.open()) {
Map<String, Ref> refs = repo.getRefDatabase().getRefs(ALL);
for (Change c : changeCache.get(project)) {
for (Change c : ScanningChangeCacheImpl.scan(repo, db)) {
Ref r = refs.get(c.currentPatchSetId().toRefName());
if (r != null) {
byId.put(r.getObjectId(), changeDataFactory.create(db, c));

View File

@@ -14,14 +14,17 @@
package com.google.gerrit.server.schema;
import com.google.common.base.Joiner;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Change.Status;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.NameKey;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.git.GitRepositoryManager;
@@ -44,6 +47,7 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
public class Schema_108 extends SchemaVersion {
private final GitRepositoryManager repoManager;
@@ -59,7 +63,7 @@ public class Schema_108 extends SchemaVersion {
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
ui.message("Listing all changes ...");
SetMultimap<Project.NameKey, Change.Id> openByProject =
getOpenChangesByProject(db);
getOpenChangesByProject(db, ui);
ui.message("done");
ui.message("Updating groups for open changes ...");
@@ -140,7 +144,9 @@ public class Schema_108 extends SchemaVersion {
}
private SetMultimap<Project.NameKey, Change.Id> getOpenChangesByProject(
ReviewDb db) throws OrmException {
ReviewDb db, UpdateUI ui) throws OrmException {
SortedSet<NameKey> projects = repoManager.list();
SortedSet<NameKey> nonExistentProjects = Sets.newTreeSet();
SetMultimap<Project.NameKey, Change.Id> openByProject =
HashMultimap.create();
for (Change c : db.changes().all()) {
@@ -149,10 +155,22 @@ public class Schema_108 extends SchemaVersion {
continue;
}
// The old "submitted" state is not supported anymore
// (thus status is null) but it was an opened state and needs
// to be migrated as such
openByProject.put(c.getProject(), c.getId());
NameKey projectKey = c.getProject();
if (!projects.contains(projectKey)) {
nonExistentProjects.add(projectKey);
} else {
// The old "submitted" state is not supported anymore
// (thus status is null) but it was an opened state and needs
// to be migrated as such
openByProject.put(projectKey, c.getId());
}
}
if (!nonExistentProjects.isEmpty()) {
ui.message("Detected open changes referring to the following non-existent projects:");
ui.message(Joiner.on(", ").join(nonExistentProjects));
ui.message("It is highly recommended to remove\n"
+ "the obsolete open changes, comments and patch-sets from your DB.\n");
}
return openByProject;
}

View File

@@ -1,13 +1,13 @@
include_defs('//lib/maven.defs')
REPO = MAVEN_CENTRAL # Leave here even if set to MAVEN_CENTRAL.
VERS = '4.1.0.201509280440-r'
VERS = '4.1.1.201511131810-r'
maven_jar(
name = 'jgit',
id = 'org.eclipse.jgit:org.eclipse.jgit:' + VERS,
bin_sha1 = '6410f290b796184df95d321a18d4c3665ba542a8',
src_sha1 = 'a681c59ec854b3e55f3abff8442e3e4ece31fa70',
bin_sha1 = '17cf7d0cb7da8bbcc16e43f0ab5dbfc43b5cb539',
src_sha1 = 'e65acfcdca36ae3cbdcbd5496648612eebe54be7',
license = 'jgit',
repository = REPO,
unsign = True,
@@ -22,7 +22,7 @@ maven_jar(
maven_jar(
name = 'jgit-servlet',
id = 'org.eclipse.jgit:org.eclipse.jgit.http.server:' + VERS,
sha1 = '2f86ccebd5b5e0837757d35f63f04471432c13b8',
sha1 = '3bbeaab1ddfd87319c4938145c9c2c276ec8de17',
license = 'jgit',
repository = REPO,
deps = [':jgit'],
@@ -36,7 +36,7 @@ maven_jar(
maven_jar(
name = 'jgit-archive',
id = 'org.eclipse.jgit:org.eclipse.jgit.archive:' + VERS,
sha1 = 'd6d0ec8d77cea3b7efeac9789140f8373c10454b',
sha1 = 'aae0cc90ab568182bdd1cb5a32bee5b44780e1a7',
license = 'jgit',
repository = REPO,
deps = [':jgit',
@@ -53,7 +53,7 @@ maven_jar(
maven_jar(
name = 'junit',
id = 'org.eclipse.jgit:org.eclipse.jgit.junit:' + VERS,
sha1 = '69ef53175d9f150bc4072f8f5ba9046bf14cc55f',
sha1 = '63fd8d96849c7c20d5c70c91575ff8dda12718e0',
license = 'DO_NOT_DISTRIBUTE',
repository = REPO,
unsign = True,