Merge branch 'stable-2.12'

* stable-2.12:
  AbstractSubmit: Extend tests to check for ref-updated events
  Print proper name for TrustedListenableFutureTask in show-queue command
  Remove non working Reindex --dry-run option
  Synchronize MyersDiff and HistogramDiff invocations on local variable
  RebaseSorter: leave commit /merge candidate as interesting if referenced

This reverts I0ce6e9f0 (listed above), since those tests are still
failing in master, as per open Issue 4123. Change Ic978fb28 aims at
bringing those tests in master -once the latter issue gets resolved.

Change-Id: Icf9cb1f3f9650e0b8ddc0350353e78ae37933b23
This commit is contained in:
Marco Miller
2016-05-25 14:05:19 -04:00
7 changed files with 59 additions and 23 deletions

View File

@@ -478,6 +478,16 @@ public abstract class AbstractDaemonTest {
.create(new BranchInput());
}
protected BranchApi createBranchWithRevision(Branch.NameKey branch,
String revision) throws Exception {
BranchInput in = new BranchInput();
in.revision = revision;
return gApi.projects()
.name(branch.getParentKey().get())
.branch(branch.get())
.create(in);
}
private static final List<Character> RANDOM =
Chars.asList(new char[]{'a','b','c','d','e','f','g','h'});
protected PushOneCommit.Result amendChange(String changeId)

View File

@@ -338,6 +338,13 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
assertThat(new Account.Id(cr.all.get(0)._accountId)).isEqualTo(admin.getId());
}
protected void assertMerged(PushOneCommit.Result change)
throws RestApiException {
String changeId = change.getChangeId();
ChangeStatus status = gApi.changes().id(changeId).info().status;
assertThat(status).isEqualTo(ChangeStatus.MERGED);
}
protected void assertPersonEquals(PersonIdent expected,
PersonIdent actual) {
assertThat(actual.getEmailAddress())

View File

@@ -27,8 +27,10 @@ import com.google.gerrit.extensions.client.InheritableBoolean;
import com.google.gerrit.extensions.client.SubmitType;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.change.Submit.TestSubmitInput;
import org.eclipse.jgit.lib.ObjectId;
@@ -261,4 +263,19 @@ public class SubmitByRebaseIfNecessaryIT extends AbstractSubmit {
approve(id2);
submit(id1);
}
@Test
public void submitChangesAfterBranchOnSecond() throws Exception {
PushOneCommit.Result change = createChange();
approve(change.getChangeId());
PushOneCommit.Result change2nd = createChange();
approve(change2nd.getChangeId());
Project.NameKey project = change2nd.getChange().change().getProject();
Branch.NameKey branch = new Branch.NameKey(project, "branch");
createBranchWithRevision(branch, change2nd.getCommit().getName());
gApi.changes().id(change2nd.getChangeId()).current().submit();
assertMerged(change2nd);
assertMerged(change);
}
}

View File

@@ -61,9 +61,6 @@ public class Reindex extends SiteProgram {
@Option(name = "--verbose", usage = "Output debug information for each change")
private boolean verbose;
@Option(name = "--dry-run", usage = "Dry run: don't write anything to index")
private boolean dryRun;
private Injector dbInjector;
private Injector sysInjector;
private Config globalConfig;

View File

@@ -51,8 +51,11 @@ public class RebaseSorter {
rw.resetRetain(canMergeFlag);
rw.markStart(n);
for (RevCommit c : accepted) {
// n also tip of directly pushed branch => n remains 'interesting' here
if (!c.equals(n)) {
rw.markUninteresting(c);
}
}
CodeReviewCommit c;
final List<CodeReviewCommit> contents = new ArrayList<>();

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.git;
import com.google.common.util.concurrent.ListenableFutureTask;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.reviewdb.client.Project;
@@ -387,24 +386,29 @@ public class WorkQueue {
@Override
public String toString() {
//This is a workaround to be able to print a proper name when the task
//is wrapped into a ListenableFutureTask.
if (runnable instanceof ListenableFutureTask<?>) {
String errorMessage;
//is wrapped into a TrustedListenableFutureTask.
try {
for (Field field : ListenableFutureTask.class.getSuperclass()
.getDeclaredFields()) {
if (field.getType().isAssignableFrom(Callable.class)) {
if (runnable.getClass().isAssignableFrom(Class.forName(
"com.google.common.util.concurrent.TrustedListenableFutureTask"))) {
Class<?> trustedFutureInterruptibleTask = Class.forName(
"com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask");
for (Field field : runnable.getClass().getDeclaredFields()) {
if (field.getType().isAssignableFrom(trustedFutureInterruptibleTask)) {
field.setAccessible(true);
return ((Callable<?>) field.get(runnable)).toString();
Object innerObj = field.get(runnable);
for (Field innerField : innerObj.getClass().getDeclaredFields()) {
if (innerField.getType().isAssignableFrom(Callable.class)) {
innerField.setAccessible(true);
return ((Callable<?>) innerField.get(innerObj)).toString();
}
}
errorMessage = "Cannot find wrapped Callable field";
} catch (SecurityException | IllegalArgumentException
}
}
}
} catch (ClassNotFoundException | IllegalArgumentException
| IllegalAccessException e) {
errorMessage = "Cannot call toString on Callable field";
}
log.debug("Cannot get a proper name for ListenableFutureTask: {}",
errorMessage);
log.debug("Cannot get a proper name for TrustedListenableFutureTask: {}",
e.getMessage());
}
return runnable.toString();
}

View File

@@ -84,7 +84,6 @@ public class PatchListLoader implements Callable<PatchList> {
private final PatchListKey key;
private final Project.NameKey project;
private final long timeoutMillis;
private final Object lock;
@AssistedInject
PatchListLoader(GitRepositoryManager mgr,
@@ -101,7 +100,6 @@ public class PatchListLoader implements Callable<PatchList> {
autoMerger = am;
key = k;
project = p;
lock = new Object();
timeoutMillis =
ConfigUtil.getTimeUnit(cfg, "cache", PatchListCacheImpl.FILE_NAME,
"timeout", TimeUnit.MILLISECONDS.convert(5, TimeUnit.SECONDS),
@@ -228,7 +226,7 @@ public class PatchListLoader implements Callable<PatchList> {
Future<FileHeader> result = diffExecutor.submit(new Callable<FileHeader>() {
@Override
public FileHeader call() throws IOException {
synchronized (lock) {
synchronized (diffEntry) {
return diffFormatter.toFileHeader(diffEntry);
}
}
@@ -244,7 +242,7 @@ public class PatchListLoader implements Callable<PatchList> {
+ " comparing " + diffEntry.getOldId().name()
+ ".." + diffEntry.getNewId().name());
result.cancel(true);
synchronized (lock) {
synchronized (diffEntry) {
return toFileHeaderWithoutMyersDiff(diffFormatter, diffEntry);
}
} catch (ExecutionException e) {