use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeData in project egit by eclipse.
the class GitLazyResourceVariantTreeSubscriber method getSyncInfo.
@Override
protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote) throws TeamException {
if (getDataSet().shouldBeIncluded(local)) {
return super.getSyncInfo(local, base, remote);
}
// Otherwise, the given resource was not in the original scope this
// subscriber was built. However, we want to access it anyway.
IProject project = local.getProject();
Repository repo = ResourceUtil.getRepository(local);
if (repo == null) {
return null;
}
GitSynchronizeData data = getDataSet().getData(project);
if (data == null) {
for (GitSynchronizeData sd : getDataSet()) {
if (repo.equals(sd.getRepository())) {
data = sd;
break;
}
}
}
if (data == null) {
return null;
}
return getSyncInfo(local, base, remote, data);
}
use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeData 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);
}
use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeData 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;
}
use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeData 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;
}
use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeData in project egit by eclipse.
the class SynchronizeFetchJob method runInWorkspace.
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
SubMonitor progress = SubMonitor.convert(monitor, gsdSet.size());
progress.setTaskName(UIText.SynchronizeFetchJob_TaskName);
for (GitSynchronizeData gsd : gsdSet) {
Repository repo = gsd.getRepository();
StoredConfig repoConfig = repo.getConfig();
String remoteName = gsd.getDstRemoteName();
if (remoteName == null) {
progress.worked(1);
continue;
}
progress.subTask(NLS.bind(UIText.SynchronizeFetchJob_SubTaskName, remoteName));
RemoteConfig config;
try {
config = new RemoteConfig(repoConfig, remoteName);
} catch (URISyntaxException e) {
Activator.logError(e.getMessage(), e);
progress.worked(1);
continue;
}
FetchOperationUI fetchOperationUI = new FetchOperationUI(repo, config, timeout, false);
fetchOperationUI.setCredentialsProvider(new EGitCredentialsProvider());
try {
fetchOperationUI.execute(progress.newChild(1));
gsd.updateRevs();
} catch (Exception e) {
showInformationDialog(remoteName);
Activator.logError(e.getMessage(), e);
}
}
return Status.OK_STATUS;
}
Aggregations