Merge changes I5c6d9b49,Icf9cb1f3
* changes: AbstractSubmit: reuse own assertMerged to remove duplicated status check Merge branch 'stable-2.12'
This commit is contained in:
@@ -478,6 +478,16 @@ public abstract class AbstractDaemonTest {
|
|||||||
.create(new BranchInput());
|
.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 =
|
private static final List<Character> RANDOM =
|
||||||
Chars.asList(new char[]{'a','b','c','d','e','f','g','h'});
|
Chars.asList(new char[]{'a','b','c','d','e','f','g','h'});
|
||||||
protected PushOneCommit.Result amendChange(String changeId)
|
protected PushOneCommit.Result amendChange(String changeId)
|
||||||
|
@@ -284,7 +284,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ChangeInfo change = gApi.changes().id(changeId).info();
|
ChangeInfo change = gApi.changes().id(changeId).info();
|
||||||
assertThat(change.status).isEqualTo(ChangeStatus.MERGED);
|
assertMerged(change.changeId);
|
||||||
if (checkMergeResult) {
|
if (checkMergeResult) {
|
||||||
checkMergeResult(change);
|
checkMergeResult(change);
|
||||||
}
|
}
|
||||||
@@ -338,6 +338,11 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
|||||||
assertThat(new Account.Id(cr.all.get(0)._accountId)).isEqualTo(admin.getId());
|
assertThat(new Account.Id(cr.all.get(0)._accountId)).isEqualTo(admin.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void assertMerged(String changeId) throws RestApiException {
|
||||||
|
ChangeStatus status = gApi.changes().id(changeId).info().status;
|
||||||
|
assertThat(status).isEqualTo(ChangeStatus.MERGED);
|
||||||
|
}
|
||||||
|
|
||||||
protected void assertPersonEquals(PersonIdent expected,
|
protected void assertPersonEquals(PersonIdent expected,
|
||||||
PersonIdent actual) {
|
PersonIdent actual) {
|
||||||
assertThat(actual.getEmailAddress())
|
assertThat(actual.getEmailAddress())
|
||||||
|
@@ -27,8 +27,10 @@ import com.google.gerrit.extensions.client.InheritableBoolean;
|
|||||||
import com.google.gerrit.extensions.client.SubmitType;
|
import com.google.gerrit.extensions.client.SubmitType;
|
||||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
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.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.server.change.Submit.TestSubmitInput;
|
import com.google.gerrit.server.change.Submit.TestSubmitInput;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
@@ -84,7 +86,6 @@ public class SubmitByRebaseIfNecessaryIT extends AbstractSubmit {
|
|||||||
assertPersonEquals(admin.getIdent(), head.getCommitterIdent());
|
assertPersonEquals(admin.getIdent(), head.getCommitterIdent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void submitWithRebaseMultipleChanges() throws Exception {
|
public void submitWithRebaseMultipleChanges() throws Exception {
|
||||||
RevCommit initialHead = getRemoteHead();
|
RevCommit initialHead = getRemoteHead();
|
||||||
@@ -261,4 +262,19 @@ public class SubmitByRebaseIfNecessaryIT extends AbstractSubmit {
|
|||||||
approve(id2);
|
approve(id2);
|
||||||
submit(id1);
|
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.getChangeId());
|
||||||
|
assertMerged(change.getChangeId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -61,9 +61,6 @@ public class Reindex extends SiteProgram {
|
|||||||
@Option(name = "--verbose", usage = "Output debug information for each change")
|
@Option(name = "--verbose", usage = "Output debug information for each change")
|
||||||
private boolean verbose;
|
private boolean verbose;
|
||||||
|
|
||||||
@Option(name = "--dry-run", usage = "Dry run: don't write anything to index")
|
|
||||||
private boolean dryRun;
|
|
||||||
|
|
||||||
private Injector dbInjector;
|
private Injector dbInjector;
|
||||||
private Injector sysInjector;
|
private Injector sysInjector;
|
||||||
private Config globalConfig;
|
private Config globalConfig;
|
||||||
|
@@ -51,7 +51,10 @@ public class RebaseSorter {
|
|||||||
rw.resetRetain(canMergeFlag);
|
rw.resetRetain(canMergeFlag);
|
||||||
rw.markStart(n);
|
rw.markStart(n);
|
||||||
for (RevCommit c : accepted) {
|
for (RevCommit c : accepted) {
|
||||||
rw.markUninteresting(c);
|
// n also tip of directly pushed branch => n remains 'interesting' here
|
||||||
|
if (!c.equals(n)) {
|
||||||
|
rw.markUninteresting(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeReviewCommit c;
|
CodeReviewCommit c;
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.git;
|
package com.google.gerrit.server.git;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFutureTask;
|
|
||||||
import com.google.gerrit.extensions.events.LifecycleListener;
|
import com.google.gerrit.extensions.events.LifecycleListener;
|
||||||
import com.google.gerrit.lifecycle.LifecycleModule;
|
import com.google.gerrit.lifecycle.LifecycleModule;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
@@ -384,24 +383,29 @@ public class WorkQueue {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
//This is a workaround to be able to print a proper name when the task
|
//This is a workaround to be able to print a proper name when the task
|
||||||
//is wrapped into a ListenableFutureTask.
|
//is wrapped into a TrustedListenableFutureTask.
|
||||||
if (runnable instanceof ListenableFutureTask<?>) {
|
try {
|
||||||
String errorMessage;
|
if (runnable.getClass().isAssignableFrom(Class.forName(
|
||||||
try {
|
"com.google.common.util.concurrent.TrustedListenableFutureTask"))) {
|
||||||
for (Field field : ListenableFutureTask.class.getSuperclass()
|
Class<?> trustedFutureInterruptibleTask = Class.forName(
|
||||||
.getDeclaredFields()) {
|
"com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask");
|
||||||
if (field.getType().isAssignableFrom(Callable.class)) {
|
for (Field field : runnable.getClass().getDeclaredFields()) {
|
||||||
|
if (field.getType().isAssignableFrom(trustedFutureInterruptibleTask)) {
|
||||||
field.setAccessible(true);
|
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
|
|
||||||
| IllegalAccessException e) {
|
|
||||||
errorMessage = "Cannot call toString on Callable field";
|
|
||||||
}
|
}
|
||||||
log.debug("Cannot get a proper name for ListenableFutureTask: {}",
|
} catch (ClassNotFoundException | IllegalArgumentException
|
||||||
errorMessage);
|
| IllegalAccessException e) {
|
||||||
|
log.debug("Cannot get a proper name for TrustedListenableFutureTask: {}",
|
||||||
|
e.getMessage());
|
||||||
}
|
}
|
||||||
return runnable.toString();
|
return runnable.toString();
|
||||||
}
|
}
|
||||||
|
@@ -84,7 +84,6 @@ public class PatchListLoader implements Callable<PatchList> {
|
|||||||
private final PatchListKey key;
|
private final PatchListKey key;
|
||||||
private final Project.NameKey project;
|
private final Project.NameKey project;
|
||||||
private final long timeoutMillis;
|
private final long timeoutMillis;
|
||||||
private final Object lock;
|
|
||||||
|
|
||||||
@AssistedInject
|
@AssistedInject
|
||||||
PatchListLoader(GitRepositoryManager mgr,
|
PatchListLoader(GitRepositoryManager mgr,
|
||||||
@@ -101,7 +100,6 @@ public class PatchListLoader implements Callable<PatchList> {
|
|||||||
autoMerger = am;
|
autoMerger = am;
|
||||||
key = k;
|
key = k;
|
||||||
project = p;
|
project = p;
|
||||||
lock = new Object();
|
|
||||||
timeoutMillis =
|
timeoutMillis =
|
||||||
ConfigUtil.getTimeUnit(cfg, "cache", PatchListCacheImpl.FILE_NAME,
|
ConfigUtil.getTimeUnit(cfg, "cache", PatchListCacheImpl.FILE_NAME,
|
||||||
"timeout", TimeUnit.MILLISECONDS.convert(5, TimeUnit.SECONDS),
|
"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>() {
|
Future<FileHeader> result = diffExecutor.submit(new Callable<FileHeader>() {
|
||||||
@Override
|
@Override
|
||||||
public FileHeader call() throws IOException {
|
public FileHeader call() throws IOException {
|
||||||
synchronized (lock) {
|
synchronized (diffEntry) {
|
||||||
return diffFormatter.toFileHeader(diffEntry);
|
return diffFormatter.toFileHeader(diffEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,7 +242,7 @@ public class PatchListLoader implements Callable<PatchList> {
|
|||||||
+ " comparing " + diffEntry.getOldId().name()
|
+ " comparing " + diffEntry.getOldId().name()
|
||||||
+ ".." + diffEntry.getNewId().name());
|
+ ".." + diffEntry.getNewId().name());
|
||||||
result.cancel(true);
|
result.cancel(true);
|
||||||
synchronized (lock) {
|
synchronized (diffEntry) {
|
||||||
return toFileHeaderWithoutMyersDiff(diffFormatter, diffEntry);
|
return toFileHeaderWithoutMyersDiff(diffFormatter, diffEntry);
|
||||||
}
|
}
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
|
Reference in New Issue
Block a user