Search in sources :

Example 1 with GitResourceVariantTreeSubscriber

use of org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber 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();
}
Also used : GitSubscriberResourceMappingContext(org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext) SubscriberScopeManager(org.eclipse.team.core.subscribers.SubscriberScopeManager) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber) RemoteResourceMappingContext(org.eclipse.core.resources.mapping.RemoteResourceMappingContext) Job(org.eclipse.core.runtime.jobs.Job) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) ISynchronizeParticipant(org.eclipse.team.ui.synchronize.ISynchronizeParticipant) GitSubscriberMergeContext(org.eclipse.egit.core.synchronize.GitSubscriberMergeContext)

Example 2 with GitResourceVariantTreeSubscriber

use of org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber in project egit by eclipse.

the class GitModelSynchronizeParticipant method restoreContext.

@Override
protected MergeContext restoreContext(ISynchronizationScopeManager manager) throws CoreException {
    GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds);
    subscriber.init(new NullProgressMonitor());
    return new GitSubscriberMergeContext(subscriber, manager, gsds);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber) GitSubscriberMergeContext(org.eclipse.egit.core.synchronize.GitSubscriberMergeContext)

Example 3 with GitResourceVariantTreeSubscriber

use of org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber in project egit by eclipse.

the class HistoryTest method queryHistoryThroughTeam.

/*
	 * This aims at exerting the behavior of the EGit history provider when used
	 * through the Team APIs. This is the behavior extenders will see when
	 * interfacing with EGit through the synchronize view.
	 *
	 * The exact comparison with which we've reached the synchronize perspective
	 * should not be relevant. To keep this test as short as possible, we'll
	 * only test a single comparison.
	 */
@Test
public void queryHistoryThroughTeam() throws IOException, CoreException {
    GitSynchronizeData gsd = new GitSynchronizeData(testRepository.getRepository(), MASTER, BRANCH, false);
    GitSynchronizeDataSet gsds = new GitSynchronizeDataSet(gsd);
    GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds);
    subscriber.init(new NullProgressMonitor());
    IDiff diff = subscriber.getDiff(iFile2);
    assertTrue(diff instanceof IThreeWayDiff);
    IFileRevision sourceRevision = getSource(diff);
    IFileRevision destinationRevision = getDestination(diff);
    IFileRevision baseRevision = getBase(diff);
    assertRevisionMatchCommit(baseRevision, masterCommit2);
    assertRevisionMatchCommit(destinationRevision, branchCommit2);
    assertRevisionMatchCommit(sourceRevision, masterCommit3);
    final IFileHistory history = historyProvider.getFileHistoryFor(iFile2, IFileHistoryProvider.NONE, new NullProgressMonitor());
    assertNotNull(history);
    // no parent of masterCommit2 in file2's history
    IFileRevision[] parents = history.getContributors(baseRevision);
    assertEquals(0, parents.length);
    /*
		 * branchCommit1 did not contain file2, so the "child" of masterCommit2
		 * (branching point) in file2's history is branchCommit2.
		 */
    IFileRevision[] children = history.getTargets(baseRevision);
    List<RevCommit> expectedChildren = new ArrayList<RevCommit>(Arrays.asList(masterCommit3, branchCommit2));
    assertEquals(expectedChildren.size(), children.length);
    assertMatchingRevisions(Arrays.asList(children), expectedChildren);
}
Also used : GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistory(org.eclipse.team.core.history.IFileHistory) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) IThreeWayDiff(org.eclipse.team.core.diff.IThreeWayDiff) IFileRevision(org.eclipse.team.core.history.IFileRevision) ArrayList(java.util.ArrayList) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber) IDiff(org.eclipse.team.core.diff.IDiff) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 4 with GitResourceVariantTreeSubscriber

use of org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber in project egit by eclipse.

the class ModelTestCase method prepareContext.

protected IMergeContext prepareContext(Repository repository, IFile workspaceFile, String srcRev, String dstRev) throws Exception {
    GitSynchronizeData gsd = new GitSynchronizeData(repository, srcRev, dstRev, true, Collections.<IResource>singleton(workspaceFile));
    GitSynchronizeDataSet gsds = new GitSynchronizeDataSet(gsd);
    GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds);
    subscriber.init(new NullProgressMonitor());
    ResourceMapping mapping = AdapterUtils.adapt(workspaceFile, ResourceMapping.class);
    SubscriberScopeManager manager = new SubscriberScopeManager(subscriber.getName(), new ResourceMapping[] { mapping }, subscriber, true);
    manager.initialize(new NullProgressMonitor());
    GitSubscriberMergeContext mergeContext = new GitSubscriberMergeContext(subscriber, manager, gsds);
    // Wait for asynchronous update of the diff tree to end
    Job.getJobManager().join(mergeContext, new NullProgressMonitor());
    return mergeContext;
}
Also used : GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) SubscriberScopeManager(org.eclipse.team.core.subscribers.SubscriberScopeManager) ResourceMapping(org.eclipse.core.resources.mapping.ResourceMapping) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber) GitSubscriberMergeContext(org.eclipse.egit.core.synchronize.GitSubscriberMergeContext)

Example 5 with GitResourceVariantTreeSubscriber

use of org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber in project egit by eclipse.

the class ModelTestCase method prepareModelContext.

protected IMergeContext prepareModelContext(Repository repository, IFile workspaceFile, String srcRev, String dstRev) throws Exception {
    Set<IResource> includedResources = new HashSet<IResource>(Arrays.asList(workspaceFile));
    Set<IResource> newResources = new HashSet<IResource>(includedResources);
    Set<ResourceMapping> allMappings = new HashSet<ResourceMapping>();
    ResourceMappingContext mappingContext = ResourceMappingContext.LOCAL_CONTEXT;
    ModelProvider provider = ModelProvider.getModelProviderDescriptor(SampleModelProvider.SAMPLE_PROVIDER_ID).getModelProvider();
    do {
        Set<IResource> copy = newResources;
        newResources = new HashSet<IResource>();
        for (IResource resource : copy) {
            ResourceMapping[] mappings = provider.getMappings(resource, mappingContext, new NullProgressMonitor());
            allMappings.addAll(Arrays.asList(mappings));
            newResources.addAll(collectResources(mappings, mappingContext));
        }
    } while (includedResources.addAll(newResources));
    ResourceMapping[] mappings = allMappings.toArray(new ResourceMapping[allMappings.size()]);
    GitSynchronizeData gsd = new GitSynchronizeData(repository, srcRev, dstRev, true, includedResources);
    GitSynchronizeDataSet gsds = new GitSynchronizeDataSet(gsd);
    GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds);
    subscriber.init(new NullProgressMonitor());
    GitSubscriberResourceMappingContext resourceMappingContext = new GitSubscriberResourceMappingContext(subscriber, gsds);
    SubscriberScopeManager manager = new SubscriberScopeManager(subscriber.getName(), mappings, subscriber, resourceMappingContext, true);
    manager.initialize(new NullProgressMonitor());
    GitSubscriberMergeContext mergeContext = new GitSubscriberMergeContext(subscriber, manager, gsds);
    // Wait for asynchronous update of the diff tree to end
    Job.getJobManager().join(mergeContext, new NullProgressMonitor());
    return mergeContext;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) GitSubscriberResourceMappingContext(org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext) ModelProvider(org.eclipse.core.resources.mapping.ModelProvider) SubscriberScopeManager(org.eclipse.team.core.subscribers.SubscriberScopeManager) GitSubscriberResourceMappingContext(org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext) ResourceMappingContext(org.eclipse.core.resources.mapping.ResourceMappingContext) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) ResourceMapping(org.eclipse.core.resources.mapping.ResourceMapping) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber) GitSubscriberMergeContext(org.eclipse.egit.core.synchronize.GitSubscriberMergeContext) IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet)

Aggregations

GitResourceVariantTreeSubscriber (org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 GitSubscriberMergeContext (org.eclipse.egit.core.synchronize.GitSubscriberMergeContext)5 GitSynchronizeDataSet (org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet)4 SubscriberScopeManager (org.eclipse.team.core.subscribers.SubscriberScopeManager)4 ResourceMapping (org.eclipse.core.resources.mapping.ResourceMapping)3 GitSubscriberResourceMappingContext (org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext)3 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)3 IResource (org.eclipse.core.resources.IResource)2 IFileRevision (org.eclipse.team.core.history.IFileRevision)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ITypedElement (org.eclipse.compare.ITypedElement)1 ResourceNode (org.eclipse.compare.ResourceNode)1 ICompareInput (org.eclipse.compare.structuremergeviewer.ICompareInput)1 IFile (org.eclipse.core.resources.IFile)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 ModelProvider (org.eclipse.core.resources.mapping.ModelProvider)1 RemoteResourceMappingContext (org.eclipse.core.resources.mapping.RemoteResourceMappingContext)1 ResourceMappingContext (org.eclipse.core.resources.mapping.ResourceMappingContext)1