use of org.eclipse.jgit.lib.IndexDiff in project egit by eclipse.
the class IndexDiffCacheEntry method calcIndexDiffDataIncremental.
private IndexDiffData calcIndexDiffDataIncremental(IProgressMonitor monitor, String jobName, Repository repository, Collection<String> filesToUpdate, Collection<IResource> resourcesToUpdate) throws IOException {
if (indexDiffData == null)
// -> do full refresh instead
return calcIndexDiffDataFull(monitor, jobName, repository);
EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(monitor);
List<String> treeFilterPaths = calcTreeFilterPaths(filesToUpdate);
WorkingTreeIterator iterator = IteratorService.createInitialIterator(repository);
if (iterator == null)
// workspace is closed
return null;
IndexDiff diffForChangedResources = new IndexDiff(repository, Constants.HEAD, iterator);
diffForChangedResources.setFilter(PathFilterGroup.createFromStrings(treeFilterPaths));
diffForChangedResources.diff(jgitMonitor, 0, 0, jobName);
IndexDiffData previous = indexDiffData;
if (previous == null) {
// but the updateJob is still running (and about to cancel).
return null;
}
return new IndexDiffData(previous, filesToUpdate, resourcesToUpdate, diffForChangedResources);
}
use of org.eclipse.jgit.lib.IndexDiff in project egit by eclipse.
the class CommitViewerComparator method getFileStatus.
/**
* Retrieve file status
* @param path
* @return file status
* @throws IOException
*/
private Status getFileStatus(String path) throws IOException {
FileTreeIterator fileTreeIterator = new FileTreeIterator(repository);
IndexDiff indexDiff = new IndexDiff(repository, Constants.HEAD, fileTreeIterator);
Set<String> repositoryPaths = Collections.singleton(path);
indexDiff.setFilter(PathFilterGroup.createFromStrings(repositoryPaths));
// $NON-NLS-1$
indexDiff.diff(null, 0, 0, "");
return getFileStatus(path, indexDiff);
}
use of org.eclipse.jgit.lib.IndexDiff in project egit by eclipse.
the class IndexDiffCacheEntry method calcIndexDiffDataFull.
private IndexDiffData calcIndexDiffDataFull(IProgressMonitor monitor, String jobName, Repository repository) throws IOException {
EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(monitor);
IndexDiff newIndexDiff;
WorkingTreeIterator iterator = IteratorService.createInitialIterator(repository);
if (iterator == null)
// workspace is closed
return null;
newIndexDiff = new IndexDiff(repository, Constants.HEAD, iterator);
newIndexDiff.diff(jgitMonitor, 0, 0, jobName);
return new IndexDiffData(newIndexDiff);
}
use of org.eclipse.jgit.lib.IndexDiff in project egit by eclipse.
the class CommitUI method getIndexDiff.
/**
* Calculates a fresh {@link IndexDiff} for the given repository.
*
* @param repository
* to compute the {@link IndexDiff} for
* @param selectedProjects
* of the repository; used to get an estimate for the progress
* monitor; may be empty
* @param monitor
* for progress reporting and cancellation
* @return the {@link IndexDiff}
* @throws IOException
* if an error occurred
* @throws OperationCanceledException
* if the operation was cancelled
*/
public static IndexDiff getIndexDiff(Repository repository, IProject[] selectedProjects, IProgressMonitor monitor) throws IOException, OperationCanceledException {
SubMonitor progress = SubMonitor.convert(monitor, UIText.CommitActionHandler_calculatingChanges, 1000);
EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(progress);
CountingVisitor counter = new CountingVisitor();
for (IProject p : selectedProjects) {
try {
p.accept(counter);
} catch (CoreException e) {
// ignore
}
}
WorkingTreeIterator it = IteratorService.createInitialIterator(repository);
if (it == null) {
// Workspace is closed
throw new OperationCanceledException();
}
IndexDiff diff = new IndexDiff(repository, Constants.HEAD, it);
diff.diff(jgitMonitor, counter.count, 0, NLS.bind(UIText.CommitActionHandler_repository, repository.getDirectory().getPath()));
if (progress.isCanceled()) {
throw new OperationCanceledException();
}
return diff;
}
Aggregations