Merge branch 'stable-2.16' into stable-3.0

* stable-2.16:
  Use Flogger instead of System.out.println in DeleteZombieCommentsRefs
  Update git submodules
  Bazel: Move runtime dependencies only from deps to runtime_deps
  Update rename project documentation in project owner guide
  Fix issues with caching edited commit message
  Add "edit" button to diff view
  Remove egit plugin from project owner guide Documentation
  Bazel: Remove superfluous dependencies flagged by unused_deps

Change-Id: I868514a9c1d6f19dd8250e2fea05a0c73df7183b
This commit is contained in:
Marco Miller 2020-02-18 11:52:22 -05:00
commit 1f4ccf2e02
36 changed files with 81 additions and 88 deletions

View File

@ -586,13 +586,6 @@ The `download-commands` plugin provides the default download commands
Gerrit administrators may configure which of the commands are shown on
the change screen.
- link:https://gerrit-review.googlesource.com/admin/repos/plugins/egit[
egit] plugin:
+
The `egit` plugin provides the change ref as a download command, which is
needed for downloading a change from within
link:https://www.eclipse.org/egit/[EGit].
- link:https://gerrit-review.googlesource.com/admin/repos/plugins/project-download-commands[
project-download-commands] plugin:
+
@ -759,7 +752,14 @@ link:project-configuration.html#project-state[project state] to `ReadOnly` or
Gerrit core does not support the renaming of projects.
As workaround you can perform the following steps:
If the link:https://gerrit-review.googlesource.com/admin/repos/plugins/rename-project[rename-project]
plugin is installed, projects can be renamed using the
link:https://gerrit.googlesource.com/plugins/rename-project/+/refs/heads/master/src/main/resources/Documentation/cmd-rename.md[rename-project]
ssh command. Find details about prerequisites in the
link:https://gerrit.googlesource.com/plugins/rename-project/+/refs/heads/master/src/main/resources/Documentation/about.md[plugin documentation].
If you don't want to use the rename-project plugin you can perform the following steps as
a workaround:
. link:#project-creation[Create a new project] with the new name.
. link:#import-history[Import the history of the old project].
@ -768,11 +768,6 @@ As workaround you can perform the following steps:
Please note that a drawback of this workaround is that the whole review
history (changes, review comments) is lost.
Alternatively, you can use the
link:https://gerrit.googlesource.com/plugins/importer/[importer] plugin
to copy the project _including the review history_, and then
link:#project-deletion[delete the old project].
GERRIT
------
Part of link:index.html[Gerrit Code Review]

View File

@ -106,7 +106,6 @@ java_library2(
"//java/com/google/gerrit/lucene",
"//java/com/google/gerrit/mail",
"//java/com/google/gerrit/metrics",
"//java/com/google/gerrit/pgm/init",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/audit",

View File

@ -13,7 +13,6 @@ java_library(
"//java/com/google/gerrit/httpd",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/audit",
"//lib:gson",
"//lib:guava",
"//lib:servlet-api-3_1",

View File

@ -16,7 +16,6 @@ java_library(
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/util/http",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/audit",
"//lib:guava",
"//java/com/google/gwtorm",
"//lib:servlet-api-3_1",

View File

@ -16,14 +16,12 @@ java_library(
"//java/com/google/gerrit/metrics/dropwizard",
"//java/com/google/gerrit/pgm/init",
"//java/com/google/gerrit/pgm/util",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server:module",
"//java/com/google/gerrit/server/api",
"//java/com/google/gerrit/server/audit",
"//java/com/google/gerrit/server/cache/h2",
"//java/com/google/gerrit/server/cache/mem",
"//java/com/google/gerrit/server/git/receive",
"//java/com/google/gerrit/server/restapi",
"//java/com/google/gerrit/server/schema",
"//java/com/google/gerrit/sshd",
@ -33,6 +31,5 @@ java_library(
"//lib/guice",
"//lib/guice:guice-servlet",
"//lib/jgit/org.eclipse.jgit:jgit",
"//prolog:gerrit-prolog-common",
],
)

View File

@ -9,8 +9,6 @@ java_library(
deps = [
"//java/com/google/gerrit/index",
"//java/com/google/gerrit/index:query_exception",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//lib:guava",
"//lib/lucene:lucene-core-and-backward-codecs",
],

View File

@ -8,7 +8,6 @@ java_library(
"//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/metrics",
"//java/com/google/gerrit/pgm/http/jetty",
"//java/com/google/gerrit/server",
"//lib:args4j",
"//lib:guava",

View File

@ -43,13 +43,11 @@ java_library(
"//java/com/google/gerrit/server/audit",
"//java/com/google/gerrit/server/cache/h2",
"//java/com/google/gerrit/server/cache/mem",
"//java/com/google/gerrit/server/git/receive",
"//java/com/google/gerrit/server/ioutil",
"//java/com/google/gerrit/server/restapi",
"//java/com/google/gerrit/server/schema",
"//java/com/google/gerrit/server/util/time",
"//java/com/google/gerrit/sshd",
"//java/com/google/gerrit/util/http",
"//lib:args4j",
"//lib:guava",
"//lib:protobuf",

View File

@ -5,10 +5,8 @@ java_library(
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/httpd",
"//java/com/google/gerrit/launcher",
"//java/com/google/gerrit/lifecycle",
"//java/com/google/gerrit/metrics",
"//java/com/google/gerrit/server",

View File

@ -12,10 +12,8 @@ java_library(
"//java/com/google/gerrit/metrics/dropwizard",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server:module",
"//java/com/google/gerrit/server/cache/h2",
"//java/com/google/gerrit/server/cache/mem",
"//java/com/google/gerrit/server/git/receive",
"//java/com/google/gerrit/server/restapi",
"//java/com/google/gerrit/server/schema",
"//java/com/google/gerrit/util/cli",

View File

@ -11,7 +11,6 @@ java_library(
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/lifecycle",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/restapi",

View File

@ -10,12 +10,6 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/index",
"//java/com/google/gerrit/index:query_exception",
"//java/com/google/gerrit/index/project",
"//java/com/google/gerrit/lifecycle",
"//java/com/google/gerrit/metrics",
"//java/com/google/gerrit/prettify:server",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/ioutil",
@ -83,7 +77,6 @@ java_library(
"//lib/log:jsonevent-layout",
"//lib/log:log4j",
"//lib/lucene:lucene-analyzers-common",
"//lib/lucene:lucene-core-and-backward-codecs",
"//lib/lucene:lucene-queryparser",
"//lib/mime4j:core",
"//lib/mime4j:dom",

View File

@ -6,7 +6,6 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/lifecycle",
"//java/com/google/gerrit/server",

View File

@ -7,9 +7,6 @@ java_library(
testonly = True,
srcs = glob(["*.java"]),
deps = [
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//lib:guava",
"//lib/jgit/org.eclipse.jgit:jgit",

View File

@ -17,6 +17,7 @@ package com.google.gerrit.server.notedb;
import static com.google.common.collect.ImmutableList.toImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.git.RefUpdateUtil;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.config.AllUsersName;
@ -42,6 +43,8 @@ import org.eclipse.jgit.transport.ReceiveCommand;
* and not get deleted. These refs point to an empty tree.
*/
public class DeleteZombieCommentsRefs {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final String EMPTY_TREE_ID = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
private final String DRAFT_REFS_PREFIX = "refs/draft-comments";
private final int CHUNK_SIZE = 100; // log progress after deleting every CHUNK_SIZE refs
@ -70,18 +73,15 @@ public class DeleteZombieCommentsRefs {
List<Ref> draftRefs = allUsersRepo.getRefDatabase().getRefsByPrefix(DRAFT_REFS_PREFIX);
List<Ref> zombieRefs = filterZombieRefs(draftRefs);
System.out.println(
String.format(
"Found a total of %d zombie draft refs in %s repo.",
zombieRefs.size(), allUsers.get()));
logger.atInfo().log(
"Found a total of %d zombie draft refs in %s repo.", zombieRefs.size(), allUsers.get());
System.out.println(String.format("Cleanup percentage = %d", cleanupPercentage));
logger.atInfo().log("Cleanup percentage = %d", cleanupPercentage);
zombieRefs =
zombieRefs.stream()
.filter(ref -> Change.Id.fromAllUsersRef(ref.getName()).get() % 100 < cleanupPercentage)
.collect(toImmutableList());
System.out.println(
String.format("Number of zombie refs to be cleaned = %d", zombieRefs.size()));
logger.atInfo().log("Number of zombie refs to be cleaned = %d", zombieRefs.size());
long zombieRefsCnt = zombieRefs.size();
long deletedRefsCnt = 0;
@ -124,7 +124,7 @@ public class DeleteZombieCommentsRefs {
}
private void logProgress(long deletedRefsCount, long allRefsCount, long elapsed) {
System.out.format(
logger.atInfo().log(
"Deleted %d/%d zombie draft refs (%d seconds)\n", deletedRefsCount, allRefsCount, elapsed);
}
}

View File

@ -23,7 +23,6 @@ java_library(
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/ioutil",
"//java/com/google/gerrit/server/logging",
"//java/com/google/gerrit/server/util/time",
"//java/com/google/gerrit/util/cli",
"//lib:args4j",

View File

@ -11,12 +11,10 @@ java_library(
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/json",
"//java/com/google/gerrit/lifecycle",
"//java/com/google/gerrit/lucene",
"//java/com/google/gerrit/metrics",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/audit",
"//java/com/google/gerrit/server/cache/h2",
"//java/com/google/gerrit/server/git/receive",
"//java/com/google/gerrit/server/ioutil",
"//java/com/google/gerrit/server/logging",

View File

@ -6,7 +6,6 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server",
"//lib:args4j",
"//lib:guava",
"//lib/auto:auto-value-annotations",

View File

@ -6,16 +6,12 @@ junit_tests(
tags = ["no_windows"],
visibility = ["//visibility:public"],
deps = [
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/gpg",
"//java/com/google/gerrit/gpg/testing:gpg-test-util",
"//java/com/google/gerrit/lifecycle",
"//java/com/google/gerrit/lucene",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/cache/h2",
"//java/com/google/gerrit/server/project/testing:project-test-util",
"//java/com/google/gerrit/server/schema",
"//java/com/google/gerrit/testing:gerrit-test-util",
"//lib:guava",

View File

@ -4,11 +4,8 @@ junit_tests(
name = "httpd_tests",
srcs = glob(["**/*.java"]),
deps = [
"//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/httpd",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/testing:gerrit-test-util",
"//java/com/google/gerrit/util/http",

View File

@ -8,18 +8,8 @@ junit_tests(
),
visibility = ["//visibility:public"],
deps = [
"//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/extensions/common/testing:common-test-util",
"//java/com/google/gerrit/index",
"//java/com/google/gerrit/index:query_exception",
"//java/com/google/gerrit/lifecycle",
"//java/com/google/gerrit/mail",
"//java/com/google/gerrit/metrics",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/project/testing:project-test-util",
"//java/com/google/gerrit/testing:gerrit-test-util",
"//lib:gson",
"//lib:guava-retrying",

View File

@ -7,7 +7,6 @@ junit_tests(
deps = [
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/pgm",
"//java/com/google/gerrit/pgm/http/jetty",
"//java/com/google/gerrit/pgm/init",
"//java/com/google/gerrit/pgm/init/api",
"//java/com/google/gerrit/server",

View File

@ -4,7 +4,6 @@ junit_tests(
name = "tests",
srcs = glob(["**/*.java"]),
deps = [
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/cache/h2",
"//java/com/google/gerrit/server/cache/serialize",
"//lib:guava",

View File

@ -8,6 +8,9 @@ java_library(
testonly = True,
srcs = ABSTRACT_QUERY_TEST,
visibility = ["//visibility:public"],
runtime_deps = [
"//prolog:gerrit-prolog-common",
],
deps = [
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/index",
@ -21,7 +24,6 @@ java_library(
"//lib/jgit/org.eclipse.jgit:jgit",
"//lib/truth",
"//lib/truth:truth-java8-extension",
"//prolog:gerrit-prolog-common",
],
)

View File

@ -8,7 +8,9 @@ java_library(
testonly = True,
srcs = ABSTRACT_QUERY_TEST,
visibility = ["//visibility:public"],
runtime_deps = ["//prolog:gerrit-prolog-common"],
runtime_deps = [
"//prolog:gerrit-prolog-common",
],
deps = [
"//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server",

View File

@ -35,7 +35,6 @@ junit_tests(
deps = [
":abstract_query_tests",
"//java/com/google/gerrit/index/project",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/testing:gerrit-test-util",
"//lib/guice",
"//lib/jgit/org.eclipse.jgit:jgit",

View File

@ -5,6 +5,7 @@ junit_tests(
srcs = glob(["*.java"]),
resource_strip_prefix = "prologtests",
resources = ["//prologtests:gerrit_common_test"],
runtime_deps = ["//prolog:gerrit-prolog-common"],
deps = [
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/reviewdb:server",
@ -17,6 +18,5 @@ junit_tests(
"//lib/jgit/org.eclipse.jgit:jgit",
"//lib/prolog:runtime",
"//lib/truth",
"//prolog:gerrit-prolog-common",
],
)

View File

@ -5,11 +5,8 @@ junit_tests(
size = "small",
srcs = glob(["*.java"]),
deps = [
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/lifecycle",
"//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/schema",
"//java/com/google/gerrit/server/util/time",
"//java/com/google/gerrit/testing:gerrit-test-util",
"//lib:guava",

View File

@ -5,7 +5,6 @@ junit_tests(
srcs = glob(["**/*.java"]),
deps = [
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/server",
"//java/com/google/gerrit/sshd",
"//java/com/google/gerrit/testing:gerrit-test-util",
"//lib/mina:sshd",

View File

@ -6,7 +6,6 @@ java_library(
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//java/com/google/gerrit/extensions:api",
"//lib:guava",
"//lib:servlet-api-3_1",
"//lib/httpcomponents:httpclient",

View File

@ -40,6 +40,7 @@ EXPORTS = [
"//java/com/google/gerrit/index:query_exception",
"//java/com/google/gerrit/json",
"//java/com/google/gerrit/lifecycle",
"//java/com/google/gerrit/lucene",
"//java/com/google/gerrit/mail",
"//java/com/google/gerrit/metrics",
"//java/com/google/gerrit/metrics/dropwizard",

View File

@ -138,11 +138,13 @@ limitations under the License.
align-items: center;
display: flex;
}
.diffModeSelector {
.diffModeSelector,
.editButton {
align-items: center;
display: flex;
}
.diffModeSelector span {
.diffModeSelector span,
.editButton span {
margin-right: .2rem;
}
.diffModeSelector.hide,
@ -154,6 +156,9 @@ limitations under the License.
text-transform: none;
}
}
.editButtona a {
text-decoration: none;
}
@media screen and (max-width: 50em) {
header {
padding: .5em var(--default-horizontal-margin);
@ -283,8 +288,15 @@ limitations under the License.
link
disabled="[[_isBlameLoading]]"
on-tap="_toggleBlame">[[_computeBlameToggleLabel(_isBlameLoaded, _isBlameLoading)]]</gr-button>
<span class="separator"></span>
</span>
<template is="dom-if" if="[[_computeIsLoggedIn(_loggedIn)]]">
<span class="editButton">
<a href$="[[_computeEditURL(_change, _patchRange, _path)]]">
<iron-icon icon="gr-icons:edit"></iron-icon>
</a>
<span class="separator"></span>
</span>
</template>
<div class$="diffModeSelector [[_computeModeSelectHideClass(_isImageDiff)]]">
<span>Diff view:</span>
<gr-diff-mode-selector

View File

@ -536,6 +536,14 @@
return this._getDiffUrl(this._change, this._patchRange, newPath.path);
},
_computeEditURL(change, patchRange, path) {
if ([change, patchRange, path].some(arg => arg === undefined)) {
return '';
}
return Gerrit.Nav.getEditUrlForDiff(
change, path, patchRange.patchNum);
},
/**
* Gives an object representing the target of navigating either left or
* right through the change. The resulting object will have one of the
@ -1101,5 +1109,9 @@
_handleReloadingDiffPreference() {
this._getDiffPreferences();
},
_computeIsLoggedIn(loggedIn) {
return loggedIn ? true : false;
},
});
})();

View File

@ -82,13 +82,34 @@
if (newContent.length) {
this.$.storage.setEditableContentItem(this.storageKey, newContent);
} else {
// This does not really happen, because we don't clear newContent
// after saving (see below). So this only occurs when the user clears
// all the content in the editable textarea. But <gr-storage> cleans
// up itself after one day, so we are not so concerned about leaving
// some garbage behind.
this.$.storage.eraseEditableContentItem(this.storageKey);
}
}, STORAGE_DEBOUNCE_INTERVAL_MS);
},
_editingChanged(editing) {
if (!editing) { return; }
// This method is for initializing _newContent when you start editing.
// Restoring content from local storage is not perfect and has
// some issues:
//
// 1. When you start editing in multiple tabs, then we are vulnerable to
// race conditions between the tabs.
// 2. The stored content is keyed by revision, so when you upload a new
// patchset and click "reload" and then click "cancel" on the content-
// editable, then you won't be able to recover the content anymore.
//
// Because of these issues we believe that it is better to only recover
// content from local storage when you enter editing mode for the first
// time. Otherwise it is better to just keep the last editing state from
// the same session.
if (!editing || this._newContent) {
return;
}
let content;
if (this.storageKey) {
@ -111,12 +132,15 @@
},
_computeSaveDisabled(disabled, content, newContent) {
return disabled || (content === newContent);
return disabled || !newContent || content === newContent;
},
_handleSave(e) {
e.preventDefault();
this.fire('editable-content-save', {content: this._newContent});
// It would be nice, if we would set this._newContent = undefined here,
// but we can only do that when we are sure that the save operation has
// succeeded.
},
_handleCancel(e) {

View File

@ -62,11 +62,11 @@ limitations under the License.
MockInteractions.tap(element.$$('gr-button:not([primary])'));
});
test('enabling editing updates edit field contents', () => {
test('enabling editing keeps old content', () => {
element.content = 'current content';
element._newContent = 'stale content';
element._newContent = 'old content';
element.editing = true;
assert.equal(element._newContent, 'current content');
assert.equal(element._newContent, 'old content');
});
test('disabling editing does not update edit field contents', () => {

View File

@ -23,6 +23,7 @@ LIBS = [
"//lib/bouncycastle:bcprov",
"//lib/bouncycastle:bcpg",
"//lib/log:impl-log4j",
"//prolog:gerrit-prolog-common",
"//resources:log4j-config",
]