use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class GitModelSynchronize method fireSynchronizeAction.
private static void fireSynchronizeAction(final IWorkbenchWindow window, final GitSynchronizeDataSet gsdSet, final ResourceMapping[] mappings) {
final GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsdSet);
Job syncJob = new WorkspaceJob(UIText.GitModelSynchronize_fetchGitDataJobName) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
subscriber.init(monitor);
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
if (JobFamilies.SYNCHRONIZE_READ_DATA.equals(family))
return true;
return super.belongsTo(family);
}
};
syncJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
RemoteResourceMappingContext remoteContext = new GitSubscriberResourceMappingContext(subscriber, gsdSet);
SubscriberScopeManager manager = new SubscriberScopeManager(subscriber.getName(), mappings, subscriber, remoteContext, true);
GitSubscriberMergeContext context = new GitSubscriberMergeContext(subscriber, manager, gsdSet);
final GitModelSynchronizeParticipant participant = new GitModelSynchronizeParticipant(context);
TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] { participant });
IWorkbenchPart activePart = null;
if (window != null)
activePart = window.getActivePage().getActivePart();
participant.run(activePart);
}
});
syncJob.setUser(true);
syncJob.schedule();
}
use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class GitSubscriberResourceMappingContextTest method hasLocalAndRemoteChangeInSubFolder.
@Test
public void hasLocalAndRemoteChangeInSubFolder() throws Exception {
File file1 = testRepo.createFile(iProject, "folder/file1.sample");
testRepo.appendContentAndCommit(iProject, file1, "initial content", "first commit in master");
IFile iFile1 = testRepo.getIFile(iProject, file1);
testRepo.createAndCheckoutBranch(MASTER, BRANCH);
setContentsAndCommit(iFile1, "changed content in branch", "first commit in BRANCH");
testRepo.checkoutBranch(MASTER);
setContentsAndCommit(iFile1, "changed content in master", "second commit in MASTER");
RemoteResourceMappingContext context = prepareContext(MASTER, BRANCH);
assertTrue(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 GitSubscriberResourceMappingContextTest method hasRemoteChanges.
@Test
public void hasRemoteChanges() throws Exception {
File file1 = testRepo.createFile(iProject, "file1.sample");
File file2 = testRepo.createFile(iProject, "file2.sample");
testRepo.appendContentAndCommit(iProject, file1, "initial content - file 1", "first file - initial commit MASTER");
testRepo.appendContentAndCommit(iProject, file2, "initial content - file 2", "second file - initial commit MASTER");
IFile iFile1 = testRepo.getIFile(iProject, file1);
IFile iFile2 = testRepo.getIFile(iProject, file2);
testRepo.createAndCheckoutBranch(MASTER, BRANCH);
setContentsAndCommit(iFile1, "change in branch - file 1", "branch commit - file1");
setContentsAndCommit(iFile2, "change in branch - file 2", "branch commit - file2");
testRepo.checkoutBranch(MASTER);
RemoteResourceMappingContext context = prepareContext(MASTER, BRANCH);
assertFalse(context.hasLocalChange(iFile1, new NullProgressMonitor()));
assertTrue(context.hasRemoteChange(iFile1, new NullProgressMonitor()));
assertFalse(context.hasLocalChange(iFile2, new NullProgressMonitor()));
assertTrue(context.hasRemoteChange(iFile2, new NullProgressMonitor()));
setContents(iFile1, "change in master - file 1");
refresh(context, iFile1);
assertTrue(context.hasLocalChange(iFile1, new NullProgressMonitor()));
assertTrue(context.hasRemoteChange(iFile1, new NullProgressMonitor()));
setContents(iFile2, "change in branch - file 2");
refresh(context, iFile2);
assertTrue(context.hasLocalChange(iFile2, new NullProgressMonitor()));
assertTrue(context.hasRemoteChange(iFile2, new NullProgressMonitor()));
setContentsAndCommit(iFile1, "change in branch - file 1", "change in master (same as in branch) - file 2");
refresh(context, iFile1);
assertTrue(context.hasLocalChange(iFile1, new NullProgressMonitor()));
assertTrue(context.hasRemoteChange(iFile1, new NullProgressMonitor()));
}
use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class GitSubscriberResourceMappingContextTest method hasLocalChangeWhenRefreshingParentFolder.
@Test
public void hasLocalChangeWhenRefreshingParentFolder() throws Exception {
IFolder folder = iProject.getFolder("newfolder");
folder.create(false, true, null);
IFile file = folder.getFile("a.txt");
file.create(new ByteArrayInputStream("a".getBytes("UTF-8")), false, null);
RemoteResourceMappingContext context = prepareContext(MASTER, MASTER);
refresh(context, file);
assertTrue(context.hasLocalChange(file, new NullProgressMonitor()));
file.delete(false, null);
// Refresh of folder, not file directly
refresh(context, folder);
assertFalse(context.hasLocalChange(file, new NullProgressMonitor()));
}
use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class GitSubscriberResourceMappingContextTest method hasLocalChangeWithFileRemoval.
@Test
public void hasLocalChangeWithFileRemoval() throws Exception {
File file1 = testRepo.createFile(iProject, "a.txt");
File file2 = testRepo.createFile(iProject, "b.txt");
File file3 = testRepo.createFile(iProject, "c.txt");
IFile iFile1 = testRepo.getIFile(iProject, file1);
IFile iFile2 = testRepo.getIFile(iProject, file2);
IFile iFile3 = testRepo.getIFile(iProject, file3);
RemoteResourceMappingContext context = prepareContext(MASTER, MASTER);
assertTrue(context.hasLocalChange(iFile1, new NullProgressMonitor()));
assertTrue(context.hasLocalChange(iFile2, new NullProgressMonitor()));
assertTrue(context.hasLocalChange(iFile3, new NullProgressMonitor()));
iFile1.delete(false, null);
refresh(context, iFile1, iFile2, iFile3);
assertTrue(context.hasLocalChange(iFile2, new NullProgressMonitor()));
assertTrue(context.hasLocalChange(iFile3, new NullProgressMonitor()));
}
Aggregations