use of org.eclipse.jgit.api.MergeResult in project egit by eclipse.
the class DecoratableResourceMappingTest method testDecorationConflictingOverDirty.
/**
* Tests that if the resource mapping is both conflicting and dirty, that
* the conflicting decoration image is used over the dirty decoration image.
*
* @throws Exception
*/
@Test
public void testDecorationConflictingOverDirty() throws Exception {
// commit changes on master
gitAdd(git, rmContentA);
gitAdd(git, rmContentB);
RevCommit masterCommit = gitCommit(git);
// add change on new branch first_topic
git.checkout().setCreateBranch(true).setName("first_topic").call();
rmContentA = findFile(project, RM_CONTENT_A_FILE_NAME);
write(rmContentA.getLocation().toFile(), "First Topic Content");
project.refreshLocal(IResource.DEPTH_INFINITE, null);
gitAdd(git, rmContentA);
RevCommit firstTopicCommit = gitCommit(git);
// add change on new branch second_topic
git.checkout().setCreateBranch(true).setStartPoint(masterCommit).setName("second_topic").call();
rmContentA = findFile(project, RM_CONTENT_A_FILE_NAME);
write(rmContentA.getLocation().toFile(), "Second Topic Content");
project.refreshLocal(IResource.DEPTH_INFINITE, null);
gitAdd(git, rmContentA);
gitCommit(git);
// modify b to make it dirty
write(rmContentB.getLocation().toFile(), "Changed content");
// merge second_topic with first_topic
MergeResult mergeResult = git.merge().include(firstTopicCommit).call();
assertEquals(MergeStatus.CONFLICTING, mergeResult.getMergeStatus());
IDecoratableResource[] expectedDRs = new IDecoratableResource[] { newExpectedDecoratableResource(rmContentA).tracked().conflicts(), newExpectedDecoratableResource(rmContentB).tracked().dirty(), newExpectedDecoratableResourceMapping().tracked().dirty().conflicts() };
IndexDiffData indexDiffData = waitForIndexDiff(true);
IDecoratableResource[] actualDRs = { newDecoratableResource(indexDiffData, rmContentA), newDecoratableResource(indexDiffData, rmContentB), newDecoratableResourceMapping(resourceMapping) };
assertArrayEquals(expectedDRs, actualDRs);
assertDecorationConflicts(resourceMapping);
}
use of org.eclipse.jgit.api.MergeResult in project egit by eclipse.
the class DecoratableWorkingSetTest method testDecorationConflictingOverDirty.
@Test
public void testDecorationConflictingOverDirty() throws Exception {
// Create new file and commit
IFile file = createFile(project1, TEST_FILE, "Something");
IFile file2 = createFile(project1, TEST_FILE2, "Another Something");
gitAdd(git, file);
gitAdd(git, file2);
RevCommit masterCommit = gitCommit(git);
// Create and checkout new branch, change file content, add and commit
// file
git.checkout().setCreateBranch(true).setName("first_topic").call();
file = findFile(project1, TEST_FILE);
write(file.getLocation().toFile(), "First Topic Content");
project1.refreshLocal(IResource.DEPTH_INFINITE, null);
gitAdd(git, file);
RevCommit firstTopicCommit = gitCommit(git);
// Create and checkout new branch (from master), change file content,
// add and commit file
git.checkout().setCreateBranch(true).setStartPoint(masterCommit).setName("second_topic").call();
file = findFile(project1, TEST_FILE);
write(file.getLocation().toFile(), "Second Topic Content");
project1.refreshLocal(IResource.DEPTH_INFINITE, null);
gitAdd(git, file);
gitCommit(git);
// modify file2 to make it dirty
write(file2.getLocation().toFile(), "Changed content");
// merge second_topic with first_topic
MergeResult mergeResult = git.merge().include(firstTopicCommit).call();
assertEquals(MergeStatus.CONFLICTING, mergeResult.getMergeStatus());
IDecoratableResource[] expectedDRs = new IDecoratableResource[] { newExpectedDecoratableResource(project1).tracked().dirty().conflicts(), newExpectedDecoratableResource(file).tracked().conflicts(), newExpectedDecoratableResource(file2).tracked().dirty(), newExpectedDecoratableWorkingSet(WORKING_SET).tracked().dirty().conflicts() };
IndexDiffData indexDiffData = waitForIndexDiff(true);
IDecoratableResource[] actualDRs = { newDecoratableResource(indexDiffData, project1), newDecoratableResource(indexDiffData, file), newDecoratableResource(indexDiffData, file2), newDecoratableWorkingSet(resourceMapping) };
assertArrayEquals(expectedDRs, actualDRs);
assertHasUnstagedChanges(true, actualDRs);
assertDecorationConflicts(resourceMapping);
}
use of org.eclipse.jgit.api.MergeResult 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"));
}
use of org.eclipse.jgit.api.MergeResult in project egit by eclipse.
the class ReleaseFinishHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
if (gfRepo == null) {
return error(UIText.Handlers_noGitflowRepositoryFound);
}
final ReleaseFinishOperation releaseFinishOperation;
try {
releaseFinishOperation = new ReleaseFinishOperation(gfRepo);
String releaseBranch = gfRepo.getRepository().getBranch();
String develop = gfRepo.getConfig().getDevelop();
JobUtil.scheduleUserWorkspaceJob(releaseFinishOperation, UIText.ReleaseFinishHandler_finishingRelease, JobFamilies.GITFLOW_FAMILY);
IJobManager jobMan = Job.getJobManager();
jobMan.join(JobFamilies.GITFLOW_FAMILY, null);
MergeResult mergeResult = releaseFinishOperation.getMergeResult();
MergeStatus mergeStatus = mergeResult.getMergeStatus();
if (!MergeStatus.CONFLICTING.equals(mergeStatus)) {
return null;
}
if (handleConflictsOnMaster(gfRepo)) {
return null;
}
MultiStatus status = createMergeConflictInfo(develop, releaseBranch, mergeResult);
ErrorDialog.openError(null, UIText.ReleaseFinishHandler_Conflicts, null, status);
} catch (WrongGitFlowStateException | CoreException | IOException | OperationCanceledException | InterruptedException e) {
return error(e.getMessage(), e);
}
return null;
}
use of org.eclipse.jgit.api.MergeResult in project fuse-karaf by jboss-fuse.
the class GitConflictResolutionIT method mergeConflict.
@Test
public void mergeConflict() throws Exception {
prepareChanges();
RevWalk rw = new RevWalk(git.getRepository());
git.checkout().setName("custom").setCreateBranch(false).call();
MergeResult result = git.merge().setFastForward(MergeCommand.FastForwardMode.NO_FF).include(git.getRepository().resolve("patched")).call();
assertThat(result.getMergeStatus(), equalTo(MergeResult.MergeStatus.CONFLICTING));
assertThat(result.getConflicts().size(), equalTo(1));
Map<String, IndexDiff.StageState> conflicts = git.status().call().getConflictingStageState();
assertThat(conflicts.size(), equalTo(1));
assertThat(conflicts.get("etc/org.ops4j.pax.logging.cfg"), equalTo(IndexDiff.StageState.BOTH_MODIFIED));
}
Aggregations