use of org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber in project egit by eclipse.
the class GitModelSynchronizeParticipant method asCompareInput.
@Override
public ICompareInput asCompareInput(Object object) {
final ICompareInput input = super.asCompareInput(object);
final ISynchronizationContext ctx = getContext();
if (input instanceof ResourceDiffCompareInput && ctx instanceof SubscriberMergeContext) {
// Team only considers local resources as "left"
// We'll use the cached data instead as left could be remote
final IResource resource = ((ResourceNode) input.getLeft()).getResource();
final Subscriber subscriber = ((SubscriberMergeContext) ctx).getSubscriber();
if (resource instanceof IFile && subscriber instanceof GitResourceVariantTreeSubscriber) {
try {
final IFileRevision revision = ((GitResourceVariantTreeSubscriber) subscriber).getSourceFileRevision((IFile) resource);
if (revision == null) {
final ITypedElement newSource = new GitCompareFileRevisionEditorInput.EmptyTypedElement(resource.getName());
((ResourceDiffCompareInput) input).setLeft(newSource);
} else if (!(revision instanceof WorkspaceFileRevision)) {
final ITypedElement newSource = new FileRevisionTypedElement(revision, getLocalEncoding(resource));
((ResourceDiffCompareInput) input).setLeft(newSource);
}
} catch (TeamException e) {
// Keep the input from super as-is
String error = NLS.bind(UIText.GitModelSynchronizeParticipant_noCachedSourceVariant, resource.getName());
Activator.logError(error, e);
}
}
}
return input;
}
use of org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber in project egit by eclipse.
the class GitModelSynchronizeParticipant method createScopeManager.
@Override
protected ISynchronizationScopeManager createScopeManager(ResourceMapping[] mappings) {
GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds);
subscriber.init(new NullProgressMonitor());
GitSubscriberResourceMappingContext context = new GitSubscriberResourceMappingContext(subscriber, gsds);
return new SynchronizationScopeManager(UIText.GitModelSynchronizeParticipant_initialScopeName, mappings, context, true);
}
use of org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber in project egit by eclipse.
the class GitScopeUtil method createScopeManager.
/**
* Creates a new {@link SubscriberScopeManager} for the given set of
* {@link IResource}s
*
* @param resources
* @param monitor
* @return {@link SubscriberScopeManager}
*/
private static SubscriberScopeManager createScopeManager(final IResource[] resources, IProgressMonitor monitor) {
ResourceMapping[] mappings = GitScopeUtil.getResourceMappings(resources);
GitSynchronizeDataSet set = new GitSynchronizeDataSet();
final GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(set);
monitor.setTaskName(UIText.GitModelSynchronize_fetchGitDataJobName);
subscriber.init(monitor);
SubscriberScopeManager manager = new SubscriberScopeManager(UIText.GitScopeOperation_GitScopeManager, mappings, subscriber, true);
return manager;
}
Aggregations