use of org.eclipse.egit.core.internal.indexdiff.IndexDiffCache in project egit by eclipse.
the class GitSubscriberMergeContext method dispose.
@Override
public void dispose() {
Activator activator = Activator.getDefault();
if (activator == null)
return;
IndexDiffCache indexDiffCache = activator.getIndexDiffCache();
if (indexDiffCache != null)
indexDiffCache.removeIndexDiffChangedListener(indexChangeListener);
ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
subscriber.dispose();
super.dispose();
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffCache in project egit by eclipse.
the class MergeToolActionHandler method isEnabled.
@Override
public boolean isEnabled() {
IPath[] paths = getSelectedLocations();
Map<Repository, Collection<String>> pathsByRepository = ResourceUtil.splitPathsByRepository(Arrays.asList(paths));
Set<Repository> repos = pathsByRepository.keySet();
if (repos.size() != 1)
return false;
Repository repo = repos.iterator().next();
Collection<String> selectedRepoPaths = pathsByRepository.get(repo);
if (selectedRepoPaths.isEmpty())
return false;
IndexDiffCache cache = org.eclipse.egit.core.Activator.getDefault().getIndexDiffCache();
if (cache == null)
return false;
IndexDiffCacheEntry entry = cache.getIndexDiffCacheEntry(repo);
if (entry == null || entry.getIndexDiff() == null)
return false;
Set<String> conflictingFiles = entry.getIndexDiff().getConflicting();
if (conflictingFiles.isEmpty())
return false;
for (String selectedRepoPath : selectedRepoPaths) {
Path selectedPath = new Path(selectedRepoPath);
for (String conflictingFile : conflictingFiles) if (selectedPath.isPrefixOf(new Path(conflictingFile)))
return true;
}
return false;
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffCache in project egit by eclipse.
the class IndexDiffCacheTest method tearDown.
@Override
@After
public void tearDown() throws Exception {
IndexDiffCache indexDiffCache = Activator.getDefault().getIndexDiffCache();
indexDiffCache.removeIndexDiffChangedListener(indexDiffListener);
testRepository.dispose();
repository = null;
super.tearDown();
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffCache in project egit by eclipse.
the class LocalRepositoryTestCase method createProjectAndCommitToRepository.
protected File createProjectAndCommitToRepository(String repoName, String project1Name, String project2Name) throws Exception {
Repository myRepository = createLocalTestRepository(repoName);
File gitDir = myRepository.getDirectory();
// we need to commit into master first
IProject firstProject = createStandardTestProjectInRepository(myRepository, project1Name);
try {
new ConnectProviderOperation(firstProject, gitDir).execute(null);
} catch (Exception e) {
Activator.logError("Failed to connect project to repository", e);
}
assertConnected(firstProject);
IProject secondProject = null;
if (project2Name != null) {
secondProject = createStandardTestProjectInRepository(myRepository, project2Name);
try {
new ConnectProviderOperation(secondProject, gitDir).execute(null);
} catch (Exception e) {
Activator.logError("Failed to connect project to repository", e);
}
assertConnected(secondProject);
}
IFile dotProject = firstProject.getFile(".project");
assertTrue(".project is not accessible: " + dotProject, dotProject.isAccessible());
IFolder folder = firstProject.getFolder(FOLDER);
IFile textFile = folder.getFile(FILE1);
IFile textFile2 = folder.getFile(FILE2);
IFile[] commitables = null;
if (secondProject != null) {
folder = secondProject.getFolder(FOLDER);
IFile secondtextFile = folder.getFile(FILE1);
IFile secondtextFile2 = folder.getFile(FILE2);
commitables = new IFile[] { dotProject, textFile, textFile2, secondtextFile, secondtextFile2 };
} else {
commitables = new IFile[] { dotProject, textFile, textFile2 };
}
ArrayList<IFile> untracked = new ArrayList<IFile>();
untracked.addAll(Arrays.asList(commitables));
// commit to stable
CommitOperation op = new CommitOperation(commitables, untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER, "Initial commit");
op.execute(null);
// now create a stable branch (from master)
createStableBranch(myRepository);
// and check in some stuff into master again
String newContent = "Touched at " + System.currentTimeMillis();
IFile file = touch(firstProject.getName(), FOLDER + '/' + FILE1, newContent);
addAndCommit(file, newContent);
// Make sure cache entry is already listening for changes
IndexDiffCache cache = Activator.getDefault().getIndexDiffCache();
cache.getIndexDiffCacheEntry(lookupRepository(gitDir));
return gitDir;
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffCache 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"));
}
Aggregations