Search in sources :

Example 11 with MergeOperation

use of org.eclipse.egit.core.op.MergeOperation in project egit by eclipse.

the class MergeWithPreferredStrategyTest method testMergeUsesPreferredStrategyRegisteredWithExplicitName.

@Test
public void testMergeUsesPreferredStrategyRegisteredWithExplicitName() throws Exception {
    InstanceScope.INSTANCE.getNode(Activator.getPluginId()).put(GitCorePreferences.core_preferredMergeStrategy, "org.eclipse.egit.core.test.theirs");
    MergeOperation operation = new MergeOperation(testRepository.getRepository(), SIDE);
    operation.execute(new NullProgressMonitor());
    // With the MergeStrategy THEIRS, new files from branch 'master' should
    // be ignored and new files from branch 'side' should be present
    assertEquals(4, countCommitsInHead());
    assertFalse(testRepository.getIFile(project.getProject(), file2).exists());
    assertTrue(testRepository.getIFile(project.getProject(), file3).exists());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MergeOperation(org.eclipse.egit.core.op.MergeOperation) Test(org.junit.Test)

Example 12 with MergeOperation

use of org.eclipse.egit.core.op.MergeOperation in project egit by eclipse.

the class MergeToolTest method useHeadOptionShouldCauseFileToNotHaveConflictMarkers.

@Test
public void useHeadOptionShouldCauseFileToNotHaveConflictMarkers() throws Exception {
    IPath path = new Path(PROJ1).append("folder/test.txt");
    testRepository.branch("stable").commit().add(path.toString(), "stable").create();
    touchAndSubmit("master", "master");
    MergeOperation mergeOp = new MergeOperation(testRepository.getRepository(), "stable");
    mergeOp.execute(null);
    MergeResult mergeResult = mergeOp.getResult();
    assertThat(mergeResult.getMergeStatus(), is(MergeStatus.CONFLICTING));
    assertThat(mergeResult.getConflicts().keySet(), hasItem(path.toString()));
    IndexDiffCache cache = Activator.getDefault().getIndexDiffCache();
    cache.getIndexDiffCacheEntry(testRepository.getRepository());
    TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
    SWTBotTree packageExplorer = TestUtil.getExplorerTree();
    SWTBotTreeItem project1 = getProjectItem(packageExplorer, PROJ1).select();
    SWTBotTreeItem folderNode = TestUtil.expandAndWait(project1).getNode(FOLDER);
    SWTBotTreeItem fileNode = TestUtil.expandAndWait(folderNode).getNode(FILE1);
    fileNode.select();
    ContextMenuHelper.clickContextMenu(packageExplorer, util.getPluginLocalizedValue("TeamMenu.label"), util.getPluginLocalizedValue("MergeToolAction.label"));
    CompareEditorTester compareEditor = CompareEditorTester.forTitleContaining("Merging");
    String text = compareEditor.getLeftEditor().getText();
    assertThat(text, is("master"));
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) MergeOperation(org.eclipse.egit.core.op.MergeOperation) IPath(org.eclipse.core.runtime.IPath) CompareEditorTester(org.eclipse.egit.ui.common.CompareEditorTester) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) MergeResult(org.eclipse.jgit.api.MergeResult) IndexDiffCache(org.eclipse.egit.core.internal.indexdiff.IndexDiffCache) Test(org.junit.Test)

Example 13 with MergeOperation

use of org.eclipse.egit.core.op.MergeOperation in project egit by eclipse.

the class MergeOperationTest method testMergeoptionsNoFF.

@Test
public void testMergeoptionsNoFF() throws Exception {
    setMergeOptions("side", FastForwardMode.NO_FF);
    MergeOperation operation = new MergeOperation(testRepository.getRepository(), MASTER);
    operation.execute(new NullProgressMonitor());
    assertEquals(3, countCommitsInHead());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MergeOperation(org.eclipse.egit.core.op.MergeOperation) Test(org.junit.Test)

Example 14 with MergeOperation

use of org.eclipse.egit.core.op.MergeOperation in project egit by eclipse.

the class MergeOperationTest method testMergeoptionsFFOnly.

@Test
public void testMergeoptionsFFOnly() throws Exception {
    setMergeOptions("side", 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));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MergeOperation(org.eclipse.egit.core.op.MergeOperation) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Aggregations

MergeOperation (org.eclipse.egit.core.op.MergeOperation)14 Test (org.junit.Test)9 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 IOException (java.io.IOException)3 Repository (org.eclipse.jgit.lib.Repository)3 Shell (org.eclipse.swt.widgets.Shell)3 File (java.io.File)2 CoreException (org.eclipse.core.runtime.CoreException)2 MergeTargetSelectionDialog (org.eclipse.egit.ui.internal.dialogs.MergeTargetSelectionDialog)2 MergeResult (org.eclipse.jgit.api.MergeResult)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 ExecutionException (org.eclipse.core.commands.ExecutionException)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Path (org.eclipse.core.runtime.Path)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 Job (org.eclipse.core.runtime.jobs.Job)1