Merge branch 'stable-2.12'

* stable-2.12:
  Documentation: Fix anchor for gitweb.urlEncode
  Fix gitweb backlinks
  AbstractSubmit: Refactor ref-updated event tests to be more precise
  ChangeData: Prevent possible NPE when loading current patch set
  Do not keep reference to non-singleton ListTags in singleton TagsCollection
  Bazel: Fix CheckReturnValue error detected by ErrorProne
  Submit: Don't assume the "Submitted Together" Tab exists.
  Submit: Give another error message when the change itself has problems
  Submit: Move check for enabling button after rechecking mergeability
  Bazel: Fix CheckReturnValue error detected by ErrorProne
  ACL screen: Show error when group to be added is not found
  Bazel: Fix MisusedWeekYear error detected by ErrorProne
  Submit: fix typo in user message
  AbstractSubmit: Add stricter assertions about ref-updated event content
  Eclipse: Update compiler warnings settings from Eclipse MARS.2
  Upgrade replication plugin to latest revision

This merge reverts the following commits:

  AbstractSubmit: Refactor ref-updated event tests to be more precise
  AbstractSubmit: Add stricter assertions about ref-updated event content

because they are related to tests that are currently not working
on the master branch. These are reintroduced in later commits
that are still under review.

Change-Id: Icce7ad25f91ed0f7cae0f2673eff88fd648d9293
This commit is contained in:
David Pursehouse
2016-06-10 09:16:26 +09:00
8 changed files with 44 additions and 23 deletions

View File

@@ -1976,7 +1976,7 @@ using the property 'gitweb.pathSeparator'.
+ +
Valid values are the characters '*', '(' and ')'. Valid values are the characters '*', '(' and ')'.
[[gitweb.linkDrafts]]gitweb.urlEncode:: [[gitweb.urlEncode]]gitweb.urlEncode::
+ +
Whether or not Gerrit should encode the generated viewer URL. Whether or not Gerrit should encode the generated viewer URL.
+ +

View File

@@ -102,8 +102,7 @@ public class ActionsIT extends AbstractDaemonTest {
assertThat(info.enabled).isNull(); assertThat(info.enabled).isNull();
assertThat(info.label).isEqualTo("Submit whole topic"); assertThat(info.label).isEqualTo("Submit whole topic");
assertThat(info.method).isEqualTo("POST"); assertThat(info.method).isEqualTo("POST");
assertThat(info.title).isEqualTo( assertThat(info.title).isEqualTo("Problems with change(s): 2");
"See the \"Submitted Together\" tab for problems, specially see: 2");
} else { } else {
noSubmitWholeTopicAssertions(actions, 1); noSubmitWholeTopicAssertions(actions, 1);
} }

View File

@@ -61,7 +61,7 @@ public class SafeHtmlBuilderTest {
final SafeHtmlBuilder b = new SafeHtmlBuilder(); final SafeHtmlBuilder b = new SafeHtmlBuilder();
assertThat(b).isSameAs(b.append('a')); assertThat(b).isSameAs(b.append('a'));
assertThat(b).isSameAs(b.append('b')); assertThat(b).isSameAs(b.append('b'));
assertThat("ab"); assertThat(b.asString()).isEqualTo("ab");
} }
@Test @Test

View File

@@ -14,6 +14,8 @@
package com.google.gerrit.client.admin; package com.google.gerrit.client.admin;
import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.groups.GroupMap; import com.google.gerrit.client.groups.GroupMap;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.common.data.AccessSection; import com.google.gerrit.common.data.AccessSection;
@@ -219,7 +221,7 @@ public class PermissionEditor extends Composite implements Editor<Permission>,
addStage2.getStyle().setDisplay(Display.NONE); addStage2.getStyle().setDisplay(Display.NONE);
} }
private void addGroup(GroupReference ref) { private void addGroup(final GroupReference ref) {
if (ref.getUUID() != null) { if (ref.getUUID() != null) {
if (value.getRule(ref) == null) { if (value.getRule(ref) == null) {
PermissionRule newRule = value.getRule(ref, true); PermissionRule newRule = value.getRule(ref, true);
@@ -253,6 +255,8 @@ public class PermissionEditor extends Composite implements Editor<Permission>,
result.values().get(0).name())); result.values().get(0).name()));
} else { } else {
groupToAdd.setFocus(true); groupToAdd.setFocus(true);
new ErrorDialog(Gerrit.M.noSuchGroupMessage(ref.getName()))
.center();
} }
} }

View File

@@ -281,9 +281,9 @@ class GitwebServlet extends HttpServlet {
p.print(" my $h = shift;\n"); p.print(" my $h = shift;\n");
p.print(" my $q;\n"); p.print(" my $q;\n");
p.print(" if (!$h || $h eq 'HEAD') {\n"); p.print(" if (!$h || $h eq 'HEAD') {\n");
p.print(" $q = qq{#q,project:$ENV{'GERRIT_PROJECT_NAME'}};\n"); p.print(" $q = qq{#/q/project:$ENV{'GERRIT_PROJECT_NAME'}};\n");
p.print(" } elsif ($h =~ /^refs\\/heads\\/([-\\w]+)$/) {\n"); p.print(" } elsif ($h =~ /^refs\\/heads\\/([-\\w]+)$/) {\n");
p.print(" $q = qq{#q,project:$ENV{'GERRIT_PROJECT_NAME'}"); p.print(" $q = qq{#/q/project:$ENV{'GERRIT_PROJECT_NAME'}");
p.print("+branch:$1};\n"); // wrapped p.print("+branch:$1};\n"); // wrapped
p.print(" } elsif ($h =~ /^refs\\/changes\\/\\d{2}\\/(\\d+)\\/\\d+$/) "); p.print(" } elsif ($h =~ /^refs\\/changes\\/\\d{2}\\/(\\d+)\\/\\d+$/) ");
p.print("{\n"); // wrapped p.print("{\n"); // wrapped

View File

@@ -100,8 +100,10 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
"This change depends on other hidden changes which are not ready"; "This change depends on other hidden changes which are not ready";
private static final String CLICK_FAILURE_TOOLTIP = private static final String CLICK_FAILURE_TOOLTIP =
"Clicking the button would fail"; "Clicking the button would fail";
private static final String CHANGE_UNMERGEABLE =
"Problems with integrating this change";
private static final String CHANGES_NOT_MERGEABLE = private static final String CHANGES_NOT_MERGEABLE =
"See the \"Submitted Together\" tab for problems, specially see: "; "Problems with change(s): ";
public static class Output { public static class Output {
transient Change change; transient Change change;
@@ -246,11 +248,12 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
} }
/** /**
* @param cd the change the user is currently looking at
* @param cs set of changes to be submitted at once * @param cs set of changes to be submitted at once
* @param user the user who is checking to submit * @param user the user who is checking to submit
* @return a reason why any of the changes is not submittable or null * @return a reason why any of the changes is not submittable or null
*/ */
private String problemsForSubmittingChangeset(ChangeSet cs, private String problemsForSubmittingChangeset(ChangeData cd, ChangeSet cs,
CurrentUser user) { CurrentUser user) {
try { try {
@SuppressWarnings("resource") @SuppressWarnings("resource")
@@ -271,6 +274,11 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
if (unmergeable == null) { if (unmergeable == null) {
return CLICK_FAILURE_TOOLTIP; return CLICK_FAILURE_TOOLTIP;
} else if (!unmergeable.isEmpty()) { } else if (!unmergeable.isEmpty()) {
for (ChangeData c : unmergeable) {
if (c.change().getKey().equals(cd.change().getKey())) {
return CHANGE_UNMERGEABLE;
}
}
return CHANGES_NOT_MERGEABLE + Joiner.on(", ").join( return CHANGES_NOT_MERGEABLE + Joiner.on(", ").join(
Iterables.transform(unmergeable, Iterables.transform(unmergeable,
new Function<ChangeData, String>() { new Function<ChangeData, String>() {
@@ -332,13 +340,6 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
.setVisible(false); .setVisible(false);
} }
Boolean enabled;
try {
enabled = cd.isMergeable();
} catch (OrmException e) {
throw new OrmRuntimeException("Could not determine mergeability", e);
}
ChangeSet cs; ChangeSet cs;
try { try {
cs = mergeSuperSet.completeChangeSet( cs = mergeSuperSet.completeChangeSet(
@@ -357,7 +358,23 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
&& topicSize > 1; && topicSize > 1;
String submitProblems = String submitProblems =
problemsForSubmittingChangeset(cs, resource.getUser()); problemsForSubmittingChangeset(cd, cs, resource.getUser());
Boolean enabled;
try {
// Recheck mergeability rather than using value stored in the index,
// which may be stale.
// TODO(dborowitz): This is ugly; consider providing a way to not read
// stored fields from the index in the first place.
// cd.setMergeable(null);
// That was done in unmergeableChanges which was called by
// problemsForSubmittingChangeset, so now it is safe to read from
// the cache, as it yields the same result.
enabled = cd.isMergeable();
} catch (OrmException e) {
throw new OrmRuntimeException("Could not determine mergeability", e);
}
if (submitProblems != null) { if (submitProblems != null) {
return new UiAction.Description() return new UiAction.Description()
.setLabel(treatWithTopic .setLabel(treatWithTopic

View File

@@ -20,6 +20,7 @@ import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestView; import com.google.gerrit.extensions.restapi.RestView;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@@ -28,24 +29,24 @@ import java.io.IOException;
public class TagsCollection implements public class TagsCollection implements
ChildCollection<ProjectResource, TagResource> { ChildCollection<ProjectResource, TagResource> {
private final DynamicMap<RestView<TagResource>> views; private final DynamicMap<RestView<TagResource>> views;
private final ListTags list; private final Provider<ListTags> list;
@Inject @Inject
public TagsCollection(DynamicMap<RestView<TagResource>> views, public TagsCollection(DynamicMap<RestView<TagResource>> views,
ListTags list) { Provider<ListTags> list) {
this.views = views; this.views = views;
this.list = list; this.list = list;
} }
@Override @Override
public RestView<ProjectResource> list() throws ResourceNotFoundException { public RestView<ProjectResource> list() throws ResourceNotFoundException {
return list; return list.get();
} }
@Override @Override
public TagResource parse(ProjectResource resource, IdString id) public TagResource parse(ProjectResource resource, IdString id)
throws ResourceNotFoundException, IOException { throws ResourceNotFoundException, IOException {
return new TagResource(resource.getControl(), list.get(resource, id)); return new TagResource(resource.getControl(), list.get().get(resource, id));
} }
@Override @Override

View File

@@ -997,11 +997,11 @@ public void setPatchSets(Collection<PatchSet> patchSets) {
return Collections.emptySet(); return Collections.emptySet();
} }
editsByUser = new HashSet<>(); editsByUser = new HashSet<>();
Change.Id id = change.getId(); Change.Id id = checkNotNull(change.getId());
try (Repository repo = repoManager.openRepository(project())) { try (Repository repo = repoManager.openRepository(project())) {
for (String ref for (String ref
: repo.getRefDatabase().getRefs(RefNames.REFS_USERS).keySet()) { : repo.getRefDatabase().getRefs(RefNames.REFS_USERS).keySet()) {
if (Change.Id.fromEditRefPart(ref).equals(id)) { if (id.equals(Change.Id.fromEditRefPart(ref))) {
editsByUser.add(Account.Id.fromRefPart(ref)); editsByUser.add(Account.Id.fromRefPart(ref));
} }
} }