use of org.eclipse.egit.core.op.MergeOperation in project egit by eclipse.
the class MergeHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ObjectId commitId = getSelectedCommitId(event);
Repository repository = getRepository(event);
if (repository == null) {
return null;
}
Shell shell = HandlerUtil.getActiveShellChecked(event);
if (!MergeActionHandler.checkMergeIsPossible(repository, shell) || LaunchFinder.shouldCancelBecauseOfRunningLaunches(repository, null)) {
return null;
}
List<Ref> nodes;
try {
nodes = getBranchesOfCommit(getSelection(event), repository, true);
} catch (IOException e) {
throw new ExecutionException(UIText.AbstractHistoryCommitHandler_cantGetBranches, e);
}
String refName;
if (nodes.isEmpty()) {
refName = commitId.getName();
} else if (nodes.size() == 1) {
refName = nodes.get(0).getName();
} else {
BranchSelectionDialog<Ref> dlg = new BranchSelectionDialog<>(shell, nodes, UIText.MergeHandler_SelectBranchTitle, UIText.MergeHandler_SelectBranchMessage, SWT.SINGLE);
if (dlg.open() == Window.OK) {
refName = dlg.getSelectedNode().getName();
} else {
return null;
}
}
MergeOperation op = new MergeOperation(repository, refName);
MergeActionHandler.doMerge(repository, op, refName);
return null;
}
use of org.eclipse.egit.core.op.MergeOperation in project egit by eclipse.
the class MergeOperationTest method testMergeFFOnly.
@Test
public void testMergeFFOnly() throws Exception {
setMerge(FastForwardMode.FF_ONLY);
File file2 = testRepository.createFile(project.getProject(), "file2");
testRepository.appendFileContent(file2, "file2-1");
RevCommit commit = testRepository.addAndCommit(project.getProject(), file2, "side commit 1");
MergeOperation operation = new MergeOperation(testRepository.getRepository(), MASTER);
operation.execute(new NullProgressMonitor());
assertTrue(testRepository.getRepository().resolve(SIDE).equals(commit));
}
use of org.eclipse.egit.core.op.MergeOperation in project egit by eclipse.
the class MergeOperationTest method testMergeFF.
@Test
public void testMergeFF() throws Exception {
MergeOperation operation = new MergeOperation(testRepository.getRepository(), MASTER);
operation.execute(new NullProgressMonitor());
assertTrue(testRepository.getRepository().resolve(SIDE).equals(secondCommit));
assertEquals(2, countCommitsInHead());
}
use of org.eclipse.egit.core.op.MergeOperation in project egit by eclipse.
the class MergeOperationTest method testMergeNoFF.
@Test
public void testMergeNoFF() throws Exception {
setMerge(FastForwardMode.NO_FF);
MergeOperation operation = new MergeOperation(testRepository.getRepository(), MASTER);
operation.execute(new NullProgressMonitor());
assertEquals(3, countCommitsInHead());
}
use of org.eclipse.egit.core.op.MergeOperation in project egit by eclipse.
the class MergeWithPreferredStrategyTest method testStrategyCanBeOverridden.
@Test
public void testStrategyCanBeOverridden() throws Exception {
MergeOperation operation = new MergeOperation(testRepository.getRepository(), SIDE, "recursive");
operation.execute(new NullProgressMonitor());
// With the MergeStrategy RECURSIVE, new files from branch 'master' and
// 'side' should be present
assertEquals(4, countCommitsInHead());
assertTrue(testRepository.getIFile(project.getProject(), file2).exists());
assertTrue(testRepository.getIFile(project.getProject(), file3).exists());
}
Aggregations