use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class GitSubscriberResourceMappingContextTest method hasRemoteChangeInNewFolder.
@Test
public void hasRemoteChangeInNewFolder() throws Exception {
File file1 = testRepo.createFile(iProject, "file1.sample");
String initialContent1 = "some content for the first file";
testRepo.appendContentAndCommit(iProject, file1, initialContent1, "first file - initial commit");
IFile iFile1 = testRepo.getIFile(iProject, file1);
testRepo.createAndCheckoutBranch(MASTER, BRANCH);
iProject.getFolder("folder").create(true, true, new NullProgressMonitor());
File file2 = testRepo.createFile(iProject, "folder/file2.sample");
String initialContent2 = "some content for the second file";
testRepo.appendContentAndCommit(iProject, file2, initialContent2, "second file - initial commit");
IFile iFile2 = testRepo.getIFile(iProject, file2);
testRepo.checkoutBranch(MASTER);
RemoteResourceMappingContext context = prepareContext(MASTER, BRANCH);
assertFalse(context.hasRemoteChange(iFile1, new NullProgressMonitor()));
assertTrue(context.hasRemoteChange(iFile2, new NullProgressMonitor()));
}
use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class GitSubscriberResourceMappingContextTest method hasDeletion.
@Test
public void hasDeletion() throws Exception {
File file1 = testRepo.createFile(iProject, "file1.sample");
testRepo.appendContentAndCommit(iProject, file1, "initial content", "first commit in master");
IFile iFile1 = testRepo.getIFile(iProject, file1);
testRepo.createAndCheckoutBranch(MASTER, BRANCH);
iFile1.delete(true, new NullProgressMonitor());
try (Git git = new Git(testRepo.getRepository())) {
git.add().addFilepattern(iProject.getName() + '/' + iFile1.getName()).setUpdate(true).call();
}
testRepo.commit("Deleted file1.sample");
RemoteResourceMappingContext context = prepareContext(BRANCH, MASTER);
boolean hasFile1 = false;
for (IResource member : context.fetchMembers(iProject, new NullProgressMonitor())) {
if (iFile1.getName().equals(member.getName())) {
hasFile1 = true;
break;
}
}
assertTrue(hasFile1);
assertFalse(context.hasRemoteChange(iFile1, new NullProgressMonitor()));
assertTrue(context.hasLocalChange(iFile1, new NullProgressMonitor()));
}
use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class MockLogicalResourceMapping method getTraversals.
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
SubMonitor sm = SubMonitor.convert(monitor, 3);
Set<IFile> result = new LinkedHashSet<IFile>();
result.add(file);
try {
List<IFile> dependencies = getDependencies(file, file.getParent());
result.addAll(dependencies);
sm.worked(1);
if (context instanceof RemoteResourceMappingContext) {
RemoteResourceMappingContext rmc = (RemoteResourceMappingContext) context;
IStorage baseContents = rmc.fetchBaseContents(file, sm.newChild(1));
if (baseContents != null) {
result.addAll(getDependencies(baseContents, file.getParent()));
}
IStorage remoteContents = rmc.fetchRemoteContents(file, sm.newChild(1));
if (remoteContents != null) {
result.addAll(getDependencies(remoteContents, file.getParent()));
}
}
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.egit.ui.test", "Exception while computing logical model", e));
}
final IResource[] resourceArray = result.toArray(new IResource[result.size()]);
return new ResourceTraversal[] { new ResourceTraversal(resourceArray, IResource.DEPTH_ONE, IResource.NONE) };
}
Aggregations