Merge "Add 'Parent $x' options to diff for merge commits"
This commit is contained in:
@@ -19,9 +19,13 @@ import static com.google.gerrit.acceptance.GitUtil.initSsh;
|
||||
import static com.google.gerrit.extensions.api.changes.SubmittedTogetherOption.NON_VISIBLE_CHANGES;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.HEAD;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.primitives.Chars;
|
||||
@@ -497,6 +501,29 @@ public abstract class AbstractDaemonTest {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected PushOneCommit.Result createMergeCommitChange(String ref)
|
||||
throws Exception {
|
||||
ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
|
||||
|
||||
PushOneCommit.Result p1 = pushFactory.create(db, admin.getIdent(),
|
||||
testRepo, "parent 1", ImmutableMap.of("foo", "foo-1", "bar", "bar-1"))
|
||||
.to(ref);
|
||||
|
||||
// reset HEAD in order to create a sibling of the first change
|
||||
testRepo.reset(initial);
|
||||
|
||||
PushOneCommit.Result p2 = pushFactory.create(db, admin.getIdent(),
|
||||
testRepo, "parent 2", ImmutableMap.of("foo", "foo-2", "bar", "bar-2"))
|
||||
.to(ref);
|
||||
|
||||
PushOneCommit m = pushFactory.create(db, admin.getIdent(), testRepo, "merge",
|
||||
ImmutableMap.of("foo", "foo-1", "bar", "bar-2"));
|
||||
m.setParents(ImmutableList.of(p1.getCommit(), p2.getCommit()));
|
||||
PushOneCommit.Result result = m.to(ref);
|
||||
result.assertOkStatus();
|
||||
return result;
|
||||
}
|
||||
|
||||
protected PushOneCommit.Result createDraftChange() throws Exception {
|
||||
return pushTo("refs/drafts/master");
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.pushHead;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
@@ -44,6 +45,7 @@ import org.eclipse.jgit.transport.RemoteRefUpdate;
|
||||
import org.eclipse.jgit.transport.RemoteRefUpdate.Status;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PushOneCommit {
|
||||
public static final String SUBJECT = "test commit";
|
||||
@@ -87,6 +89,13 @@ public class PushOneCommit {
|
||||
@Assisted("fileName") String fileName,
|
||||
@Assisted("content") String content);
|
||||
|
||||
PushOneCommit create(
|
||||
ReviewDb db,
|
||||
PersonIdent i,
|
||||
TestRepository<?> testRepo,
|
||||
@Assisted String subject,
|
||||
@Assisted Map<String, String> files);
|
||||
|
||||
PushOneCommit create(
|
||||
ReviewDb db,
|
||||
PersonIdent i,
|
||||
@@ -123,8 +132,7 @@ public class PushOneCommit {
|
||||
private final TestRepository<?> testRepo;
|
||||
|
||||
private final String subject;
|
||||
private final String fileName;
|
||||
private final String content;
|
||||
private final Map<String, String> files;
|
||||
private String changeId;
|
||||
private Tag tag;
|
||||
private boolean force;
|
||||
@@ -168,6 +176,19 @@ public class PushOneCommit {
|
||||
db, i, testRepo, subject, fileName, content, null);
|
||||
}
|
||||
|
||||
@AssistedInject
|
||||
PushOneCommit(ChangeNotes.Factory notesFactory,
|
||||
ApprovalsUtil approvalsUtil,
|
||||
Provider<InternalChangeQuery> queryProvider,
|
||||
@Assisted ReviewDb db,
|
||||
@Assisted PersonIdent i,
|
||||
@Assisted TestRepository<?> testRepo,
|
||||
@Assisted String subject,
|
||||
@Assisted Map<String, String> files) throws Exception {
|
||||
this(notesFactory, approvalsUtil, queryProvider, db, i, testRepo,
|
||||
subject, files, null);
|
||||
}
|
||||
|
||||
@AssistedInject
|
||||
PushOneCommit(ChangeNotes.Factory notesFactory,
|
||||
ApprovalsUtil approvalsUtil,
|
||||
@@ -179,14 +200,26 @@ public class PushOneCommit {
|
||||
@Assisted("fileName") String fileName,
|
||||
@Assisted("content") String content,
|
||||
@Nullable @Assisted("changeId") String changeId) throws Exception {
|
||||
this(notesFactory, approvalsUtil, queryProvider, db, i, testRepo,
|
||||
subject, ImmutableMap.of(fileName, content), changeId);
|
||||
}
|
||||
|
||||
private PushOneCommit(ChangeNotes.Factory notesFactory,
|
||||
ApprovalsUtil approvalsUtil,
|
||||
Provider<InternalChangeQuery> queryProvider,
|
||||
ReviewDb db,
|
||||
PersonIdent i,
|
||||
TestRepository<?> testRepo,
|
||||
String subject,
|
||||
Map<String, String> files,
|
||||
String changeId) throws Exception {
|
||||
this.db = db;
|
||||
this.testRepo = testRepo;
|
||||
this.notesFactory = notesFactory;
|
||||
this.approvalsUtil = approvalsUtil;
|
||||
this.queryProvider = queryProvider;
|
||||
this.subject = subject;
|
||||
this.fileName = fileName;
|
||||
this.content = content;
|
||||
this.files = files;
|
||||
this.changeId = changeId;
|
||||
if (changeId != null) {
|
||||
commitBuilder = testRepo.amendRef("HEAD")
|
||||
@@ -212,12 +245,16 @@ public class PushOneCommit {
|
||||
}
|
||||
|
||||
public Result to(String ref) throws Exception {
|
||||
commitBuilder.add(fileName, content);
|
||||
for (Map.Entry<String, String> e : files.entrySet()) {
|
||||
commitBuilder.add(e.getKey(), e.getValue());
|
||||
}
|
||||
return execute(ref);
|
||||
}
|
||||
|
||||
public Result rm(String ref) throws Exception {
|
||||
commitBuilder.rm(fileName);
|
||||
for (String fileName : files.keySet()) {
|
||||
commitBuilder.rm(fileName);
|
||||
}
|
||||
return execute(ref);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user