use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeData 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;
}
use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeData 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;
}
use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeData in project egit by eclipse.
the class GitModelSynchronizeParticipant method saveState.
@Override
public void saveState(IMemento memento) {
super.saveState(memento);
for (GitSynchronizeData gsd : gsds) {
Repository repo = gsd.getRepository();
RepositoryMapping mapping = RepositoryMapping.findRepositoryMapping(repo);
if (mapping != null) {
IMemento child = memento.createChild(DATA_NODE_KEY);
child.putString(CONTAINER_PATH_KEY, getPathForResource(mapping.getContainer()));
child.putString(SRC_REV_KEY, gsd.getSrcRev());
child.putString(DST_REV_KEY, gsd.getDstRev());
child.putBoolean(INCLUDE_LOCAL_KEY, gsd.shouldIncludeLocal());
Set<IResource> includedResources = gsd.getIncludedResources();
if (includedResources != null && !includedResources.isEmpty()) {
IMemento paths = child.createChild(INCLUDED_PATHS_NODE_KEY);
for (IResource resource : includedResources) {
String path = getPathForResource(resource);
paths.createChild(INCLUDED_PATH_KEY).putString(INCLUDED_PATH_KEY, path);
}
}
}
}
memento.putBoolean(FORCE_FETCH_KEY, gsds.forceFetch());
}
use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeData in project egit by eclipse.
the class GitModelSynchronizeParticipant method restoreSynchronizationData.
private void restoreSynchronizationData(IMemento[] children) {
for (IMemento child : children) {
String containerPath = child.getString(CONTAINER_PATH_KEY);
Repository repo = getRepositoryForPath(containerPath);
if (repo == null)
continue;
String srcRev = child.getString(SRC_REV_KEY);
String dstRev = child.getString(DST_REV_KEY);
boolean includeLocal = getBoolean(child.getBoolean(INCLUDE_LOCAL_KEY), true);
Set<IResource> includedResources = getIncludedResources(child);
try {
GitSynchronizeData data = new GitSynchronizeData(repo, srcRev, dstRev, includeLocal);
if (includedResources != null)
data.setIncludedResources(includedResources);
gsds.add(data);
} catch (IOException e) {
Activator.logError(e.getMessage(), e);
continue;
}
}
}
use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeData in project egit by eclipse.
the class GitModelSynchronizeParticipant method run.
@Override
public void run(final IWorkbenchPart part) {
boolean fetchPossible = false;
for (GitSynchronizeData data : gsds) if (data.getDstRemoteName() != null)
fetchPossible = true;
boolean launchFetch = Activator.getDefault().getPreferenceStore().getBoolean(UIPreferences.SYNC_VIEW_FETCH_BEFORE_LAUNCH);
if (fetchPossible && (launchFetch || gsds.forceFetch())) {
Job fetchJob = new SynchronizeFetchJob(gsds);
fetchJob.setUser(true);
fetchJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
GitModelSynchronizeParticipant.super.run(part);
}
});
fetchJob.schedule();
} else
super.run(part);
}
Aggregations