Merge branch 'stable-2.15'

* stable-2.15:
  ChangeQueryBuilder: Remove unused Config parameter from constructor
  Release 2.15-rc3
  Schema_159: Don't set closed changes as WIP/private
  Change default of migrating draft changes to WIP, not private
  Remove handling of change.allowDrafts
  Remove documentation on change.allowDrafts

Change-Id: I841e44ca792371d89b5f646df8f69739ec1284be
This commit is contained in:
David Pursehouse
2018-02-22 10:02:19 +09:00
9 changed files with 18 additions and 39 deletions

View File

@@ -1126,13 +1126,6 @@ Allow blame on side by side diff. If set to false, blame cannot be used.
+ +
Default is true. Default is true.
[[change.allowDrafts]]change.allowDrafts::
+
Allow drafts workflow. If set to false, drafts cannot be created,
deleted or published.
+
Default is true.
[[change.api.allowedIdentifier]]change.api.allowedIdentifier:: [[change.api.allowedIdentifier]]change.api.allowedIdentifier::
+ +
Change identifier(s) that are allowed on the API. See Change identifier(s) that are allowed on the API. See

View File

@@ -60,8 +60,6 @@ public class ServerInfo extends JavaScriptObject {
protected ServerInfo() {} protected ServerInfo() {}
public static class ChangeConfigInfo extends JavaScriptObject { public static class ChangeConfigInfo extends JavaScriptObject {
public final native boolean allowDrafts() /*-{ return this.allow_drafts || false; }-*/;
public final native boolean allowBlame() /*-{ return this.allow_blame || false; }-*/; public final native boolean allowBlame() /*-{ return this.allow_blame || false; }-*/;
public final native int largeChange() /*-{ return this.large_change || 0; }-*/; public final native int largeChange() /*-{ return this.large_change || 0; }-*/;

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.extensions.common;
public class ChangeConfigInfo { public class ChangeConfigInfo {
public Boolean allowBlame; public Boolean allowBlame;
public Boolean showAssigneeInChangesTable; public Boolean showAssigneeInChangesTable;
public Boolean allowDrafts;
public Boolean disablePrivateChanges; public Boolean disablePrivateChanges;
public int largeChange; public int largeChange;
public String replyLabel; public String replyLabel;

View File

@@ -58,7 +58,6 @@ import com.google.gerrit.server.account.VersionedAccountQueries;
import com.google.gerrit.server.change.ChangeTriplet; import com.google.gerrit.server.change.ChangeTriplet;
import com.google.gerrit.server.config.AllProjectsName; import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.config.AllUsersName; import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.strategy.SubmitDryRun; import com.google.gerrit.server.git.strategy.SubmitDryRun;
import com.google.gerrit.server.index.change.ChangeField; import com.google.gerrit.server.index.change.ChangeField;
@@ -92,7 +91,6 @@ import java.util.function.Function;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
/** Parses a query string meant to be applied to change objects. */ /** Parses a query string meant to be applied to change objects. */
@@ -215,7 +213,6 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
final Provider<ReviewDb> db; final Provider<ReviewDb> db;
final StarredChangesUtil starredChangesUtil; final StarredChangesUtil starredChangesUtil;
final SubmitDryRun submitDryRun; final SubmitDryRun submitDryRun;
final boolean allowsDrafts;
final GroupMembers groupMembers; final GroupMembers groupMembers;
private final Provider<CurrentUser> self; private final Provider<CurrentUser> self;
@@ -248,7 +245,6 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
IndexConfig indexConfig, IndexConfig indexConfig,
StarredChangesUtil starredChangesUtil, StarredChangesUtil starredChangesUtil,
AccountCache accountCache, AccountCache accountCache,
@GerritServerConfig Config cfg,
NotesMigration notesMigration, NotesMigration notesMigration,
GroupMembers groupMembers) { GroupMembers groupMembers) {
this( this(
@@ -277,7 +273,6 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
indexConfig, indexConfig,
starredChangesUtil, starredChangesUtil,
accountCache, accountCache,
cfg == null ? true : cfg.getBoolean("change", "allowDrafts", true),
notesMigration, notesMigration,
groupMembers); groupMembers);
} }
@@ -308,7 +303,6 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
IndexConfig indexConfig, IndexConfig indexConfig,
StarredChangesUtil starredChangesUtil, StarredChangesUtil starredChangesUtil,
AccountCache accountCache, AccountCache accountCache,
boolean allowsDrafts,
NotesMigration notesMigration, NotesMigration notesMigration,
GroupMembers groupMembers) { GroupMembers groupMembers) {
this.db = db; this.db = db;
@@ -335,7 +329,6 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
this.indexConfig = indexConfig; this.indexConfig = indexConfig;
this.starredChangesUtil = starredChangesUtil; this.starredChangesUtil = starredChangesUtil;
this.accountCache = accountCache; this.accountCache = accountCache;
this.allowsDrafts = allowsDrafts;
this.hasOperands = hasOperands; this.hasOperands = hasOperands;
this.notesMigration = notesMigration; this.notesMigration = notesMigration;
this.groupMembers = groupMembers; this.groupMembers = groupMembers;
@@ -368,7 +361,6 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
indexConfig, indexConfig,
starredChangesUtil, starredChangesUtil,
accountCache, accountCache,
allowsDrafts,
notesMigration, notesMigration,
groupMembers); groupMembers);
} }

View File

@@ -38,15 +38,10 @@ import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.revwalk.RevWalk;
class DeleteChangeOp implements BatchUpdateOp { class DeleteChangeOp implements BatchUpdateOp {
static boolean allowDrafts(Config cfg) {
return cfg.getBoolean("change", "allowDrafts", true);
}
private final PatchSetUtil psUtil; private final PatchSetUtil psUtil;
private final StarredChangesUtil starredChangesUtil; private final StarredChangesUtil starredChangesUtil;
private final DynamicItem<AccountPatchReviewStore> accountPatchReviewStore; private final DynamicItem<AccountPatchReviewStore> accountPatchReviewStore;

View File

@@ -231,7 +231,6 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
private ChangeConfigInfo getChangeInfo(Config cfg) { private ChangeConfigInfo getChangeInfo(Config cfg) {
ChangeConfigInfo info = new ChangeConfigInfo(); ChangeConfigInfo info = new ChangeConfigInfo();
info.allowBlame = toBoolean(cfg.getBoolean("change", "allowBlame", true)); info.allowBlame = toBoolean(cfg.getBoolean("change", "allowBlame", true));
info.allowDrafts = toBoolean(cfg.getBoolean("change", "allowDrafts", true));
boolean hasAssigneeInIndex = boolean hasAssigneeInIndex =
indexes.getSearchIndex().getSchema().hasField(ChangeField.ASSIGNEE); indexes.getSearchIndex().getSchema().hasField(ChangeField.ASSIGNEE);
info.showAssigneeInChangesTable = info.showAssigneeInChangesTable =

View File

@@ -35,26 +35,32 @@ public class Schema_159 extends SchemaVersion {
@Override @Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException { protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
DraftWorkflowMigrationStrategy strategy = DraftWorkflowMigrationStrategy.PRIVATE; DraftWorkflowMigrationStrategy strategy = DraftWorkflowMigrationStrategy.WORK_IN_PROGRESS;
if (ui.yesno( if (ui.yesno(false, "Migrate draft changes to private changes (default is work-in-progress)")) {
false, "Migrate draft changes to work-in-progress changes (default is private)?")) { strategy = DraftWorkflowMigrationStrategy.PRIVATE;
strategy = DraftWorkflowMigrationStrategy.WORK_IN_PROGRESS;
} }
ui.message( ui.message(
String.format("Replace draft changes with %s changes ...", strategy.name().toLowerCase())); String.format("Replace draft changes with %s changes ...", strategy.name().toLowerCase()));
try (StatementExecutor e = newExecutor(db)) { try (StatementExecutor e = newExecutor(db)) {
String column = String column =
strategy == DraftWorkflowMigrationStrategy.PRIVATE ? "is_private" : "work_in_progress"; strategy == DraftWorkflowMigrationStrategy.PRIVATE ? "is_private" : "work_in_progress";
// Mark changes private/wip if changes have status draft or // Mark changes private/WIP and NEW if either:
// if they have any draft patch sets. // * they have status DRAFT
// * they have status NEW and have any draft patch sets
e.execute( e.execute(
String.format( String.format(
"UPDATE changes SET %s = 'Y', created_on = created_on WHERE status = 'd' OR " "UPDATE changes "
+ "EXISTS (SELECT * FROM patch_sets WHERE " + "SET %s = 'Y', "
+ "patch_sets.change_id = changes.change_id AND patch_sets.draft = 'Y')", + " status = 'n', "
+ " created_on = created_on "
+ "WHERE status = 'd' "
+ " OR (status = 'n' "
+ " AND EXISTS "
+ " (SELECT * "
+ " FROM patch_sets "
+ " WHERE patch_sets.change_id = changes.change_id "
+ " AND patch_sets.draft = 'Y')) ",
column)); column));
// Change change status from draft to new.
e.execute("UPDATE changes SET status = 'n', created_on = created_on WHERE status = 'd'");
} }
ui.message("done"); ui.message("done");
} }

View File

@@ -56,7 +56,6 @@ public class ServerInfoIT extends AbstractDaemonTest {
@GerritConfig(name = "auth.httpPasswordUrl", value = "https://example.com/password") @GerritConfig(name = "auth.httpPasswordUrl", value = "https://example.com/password")
// change // change
@GerritConfig(name = "change.allowDrafts", value = "false")
@GerritConfig(name = "change.largeChange", value = "300") @GerritConfig(name = "change.largeChange", value = "300")
@GerritConfig(name = "change.replyTooltip", value = "Publish votes and draft comments") @GerritConfig(name = "change.replyTooltip", value = "Publish votes and draft comments")
@GerritConfig(name = "change.replyLabel", value = "Vote") @GerritConfig(name = "change.replyLabel", value = "Vote")
@@ -101,7 +100,6 @@ public class ServerInfoIT extends AbstractDaemonTest {
assertThat(i.auth.httpPasswordUrl).isNull(); assertThat(i.auth.httpPasswordUrl).isNull();
// change // change
assertThat(i.change.allowDrafts).isNull();
assertThat(i.change.largeChange).isEqualTo(300); assertThat(i.change.largeChange).isEqualTo(300);
assertThat(i.change.replyTooltip).startsWith("Publish votes and draft comments"); assertThat(i.change.replyTooltip).startsWith("Publish votes and draft comments");
assertThat(i.change.replyLabel).isEqualTo("Vote\u2026"); assertThat(i.change.replyLabel).isEqualTo("Vote\u2026");
@@ -175,7 +173,6 @@ public class ServerInfoIT extends AbstractDaemonTest {
assertThat(i.auth.httpPasswordUrl).isNull(); assertThat(i.auth.httpPasswordUrl).isNull();
// change // change
assertThat(i.change.allowDrafts).isTrue();
assertThat(i.change.largeChange).isEqualTo(500); assertThat(i.change.largeChange).isEqualTo(500);
assertThat(i.change.replyTooltip).startsWith("Reply and score"); assertThat(i.change.replyTooltip).startsWith("Reply and score");
assertThat(i.change.replyLabel).isEqualTo("Reply\u2026"); assertThat(i.change.replyLabel).isEqualTo("Reply\u2026");

View File

@@ -27,7 +27,7 @@ public class FakeQueryBuilder extends ChangeQueryBuilder {
new FakeQueryBuilder.Definition<>(FakeQueryBuilder.class), new FakeQueryBuilder.Definition<>(FakeQueryBuilder.class),
new ChangeQueryBuilder.Arguments( new ChangeQueryBuilder.Arguments(
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, indexes, null, null, null, null, null, null, null, null)); null, null, null, null, null, indexes, null, null, null, null, null, null, null));
} }
@Operator @Operator