Search in sources :

Example 1 with GitSynchronizeDataSet

use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet in project egit by eclipse.

the class GitChangeSetModelProvider method getMappings.

@Override
public ResourceMapping[] getMappings(IResource resource, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
    if (context instanceof GitSubscriberResourceMappingContext) {
        GitSubscriberResourceMappingContext gitContext = (GitSubscriberResourceMappingContext) context;
        GitSynchronizeDataSet gsds = gitContext.getSyncData();
        GitSynchronizeData data = gsds.getData(resource.getProject());
        if (data != null) {
            GitModelObject object = null;
            try {
                object = GitModelObject.createRoot(data);
            } catch (IOException e) {
                Activator.logError(e.getMessage(), e);
            }
            if (object != null) {
                ResourceMapping rm = AdapterUtils.adapt(object, ResourceMapping.class);
                return new ResourceMapping[] { rm };
            }
        }
    }
    return super.getMappings(resource, context, monitor);
}
Also used : GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) GitSubscriberResourceMappingContext(org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) ResourceMapping(org.eclipse.core.resources.mapping.ResourceMapping) IOException(java.io.IOException) GitModelObject(org.eclipse.egit.ui.internal.synchronize.model.GitModelObject)

Example 2 with GitSynchronizeDataSet

use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet in project egit by eclipse.

the class GitModelSynchronizeParticipant method init.

@Override
public void init(String secondaryId, IMemento memento) throws PartInitException {
    try {
        boolean forceFetchPref = Activator.getDefault().getPreferenceStore().getBoolean(UIPreferences.SYNC_VIEW_FETCH_BEFORE_LAUNCH);
        boolean forceFetch = getBoolean(memento.getBoolean(FORCE_FETCH_KEY), forceFetchPref);
        gsds = new GitSynchronizeDataSet(forceFetch);
        IMemento[] children = memento.getChildren(DATA_NODE_KEY);
        if (children != null)
            restoreSynchronizationData(children);
    } finally {
        super.init(secondaryId, memento);
    }
}
Also used : GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) IMemento(org.eclipse.ui.IMemento)

Example 3 with GitSynchronizeDataSet

use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet in project egit by eclipse.

the class GitSynchronizeWizard method performFinish.

@Override
public boolean performFinish() {
    GitSynchronizeDataSet gsdSet = new GitSynchronizeDataSet(page.forceFetch());
    Map<Repository, String> branches = page.getSelectedBranches();
    boolean shouldIncludeLocal = page.shouldIncludeLocal();
    for (Entry<Repository, String> branchesEntry : branches.entrySet()) try {
        Repository repo = branchesEntry.getKey();
        GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, branchesEntry.getValue(), shouldIncludeLocal);
        Set<IResource> resources = getSelectedResources(repo);
        if (resources != null && resources.size() > 0)
            data.setIncludedResources(resources);
        gsdSet.add(data);
    } catch (IOException e) {
        Activator.logError(e.getMessage(), e);
    }
    Set<IProject> selectedProjects = page.getSelectedProjects();
    GitModelSynchronize.launch(gsdSet, selectedProjects.toArray(new IResource[selectedProjects.size()]));
    return true;
}
Also used : GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) Repository(org.eclipse.jgit.lib.Repository) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) Set(java.util.Set) HashSet(java.util.HashSet) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource)

Example 4 with GitSynchronizeDataSet

use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet in project egit by eclipse.

the class ModelAwareGitSynchronizer method createResourceMappingContext.

/**
 * @param resources
 * @param repository
 * @param leftRev
 * @param rightRev
 * @param includeLocal
 * @param monitor
 * @return A resource mapping context to access the versions of the content
 *         of the resources involved in the synchronization.
 */
protected ResourceMappingContext createResourceMappingContext(Set<IResource> resources, Repository repository, String leftRev, String rightRev, boolean includeLocal, IProgressMonitor monitor) {
    try {
        GitSynchronizeData gsd = new GitSynchronizeData(repository, leftRev, rightRev, includeLocal, resources);
        GitSynchronizeDataSet gsds = new GitSynchronizeDataSet(gsd);
        GitLazyResourceVariantTreeSubscriber subscriber = new GitLazyResourceVariantTreeSubscriber(gsds);
        subscriber.init(monitor);
        return new GitSubscriberResourceMappingContext(subscriber, gsds);
    } catch (IOException e) {
        Activator.logError(e.getMessage(), e);
    }
    return ResourceMappingContext.LOCAL_CONTEXT;
}
Also used : GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) GitSubscriberResourceMappingContext(org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext) GitLazyResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitLazyResourceVariantTreeSubscriber) IOException(java.io.IOException)

Example 5 with GitSynchronizeDataSet

use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet in project egit by eclipse.

the class GitModelRootTest method shouldIgnoreEmptyRepositories.

@Test
public void shouldIgnoreEmptyRepositories() throws Exception {
    // given
    touchAndSubmit("second commit");
    GitSynchronizeDataSet gsds = new GitSynchronizeDataSet();
    gsds.add(new GitSynchronizeData(repo1, HEAD, HEAD + "^1", false));
    gsds.add(new GitSynchronizeData(repo2, HEAD, HEAD, false));
    // when
    GitModelRoot root = new GitModelRoot(gsds);
    // then
    assertThat(Integer.valueOf(root.getChildren().length), is(Integer.valueOf(1)));
}
Also used : GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) Test(org.junit.Test)

Aggregations

GitSynchronizeDataSet (org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet)29 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)26 Test (org.junit.Test)15 IFile (org.eclipse.core.resources.IFile)9 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 IResourceVariant (org.eclipse.team.core.variants.IResourceVariant)8 IResource (org.eclipse.core.resources.IResource)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 HashSet (java.util.HashSet)6 IStorage (org.eclipse.core.resources.IStorage)6 ResourceMapping (org.eclipse.core.resources.mapping.ResourceMapping)6 IOException (java.io.IOException)4 GitResourceVariantTreeSubscriber (org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber)4 GitSubscriberResourceMappingContext (org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext)4 Git (org.eclipse.jgit.api.Git)4 Repository (org.eclipse.jgit.lib.Repository)4 File (java.io.File)3 SubscriberScopeManager (org.eclipse.team.core.subscribers.SubscriberScopeManager)3 LinkedHashSet (java.util.LinkedHashSet)2