コード例 #1
0
ファイル: CommitUI.java プロジェクト: chengn/egit
  private void buildIndexHeadDiffList(IProject[] selectedProjects, IProgressMonitor monitor)
      throws IOException, OperationCanceledException {

    monitor.beginTask(UIText.CommitActionHandler_calculatingChanges, 1000);
    EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(monitor);
    CountingVisitor counter = new CountingVisitor();
    for (IProject p : selectedProjects) {
      try {
        p.accept(counter);
      } catch (CoreException e) {
        // ignore
      }
    }
    WorkingTreeIterator it = IteratorService.createInitialIterator(repo);
    if (it == null) throw new OperationCanceledException(); // workspace is closed
    indexDiff = new IndexDiff(repo, Constants.HEAD, it);
    indexDiff.diff(
        jgitMonitor,
        counter.count,
        0,
        NLS.bind(UIText.CommitActionHandler_repository, repo.getDirectory().getPath()));

    includeList(indexDiff.getAdded(), indexChanges);
    includeList(indexDiff.getChanged(), indexChanges);
    includeList(indexDiff.getRemoved(), indexChanges);
    includeList(indexDiff.getMissing(), notIndexed);
    includeList(indexDiff.getModified(), notIndexed);
    includeList(indexDiff.getUntracked(), notTracked);
    if (monitor.isCanceled()) throw new OperationCanceledException();
    monitor.done();
  }
コード例 #2
0
  private IndexDiffData calcIndexDiffDataFull(IProgressMonitor monitor, String jobName)
      throws IOException {
    EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(monitor);

    IndexDiff newIndexDiff;
    WorkingTreeIterator iterator = IteratorService.createInitialIterator(repository);
    if (iterator == null) return null; // workspace is closed
    newIndexDiff = new IndexDiff(repository, Constants.HEAD, iterator);
    newIndexDiff.diff(jgitMonitor, 0, 0, jobName);
    return new IndexDiffData(newIndexDiff);
  }
コード例 #3
0
  private static Set<String> getCommitableChanges(
      Repository repo, IServer server, IProgressMonitor monitor) throws IOException {

    EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(monitor);
    IndexDiff indexDiff =
        new IndexDiff(repo, Constants.HEAD, IteratorService.createInitialIterator(repo));
    indexDiff.diff(jgitMonitor, 0, 0, NLS.bind("Repository: {0}", repo.getDirectory().getPath()));
    Set<String> set = new HashSet<String>();
    if (commitAddedResources(server)) set.addAll(indexDiff.getAdded());
    if (commitChangedResources(server)) set.addAll(indexDiff.getChanged());
    if (commitConflictingResources(server)) set.addAll(indexDiff.getConflicting());
    if (commitMissingResources(server)) set.addAll(indexDiff.getMissing());
    if (commitModifiedResources(server)) set.addAll(indexDiff.getModified());
    if (commitRemovedResources(server)) set.addAll(indexDiff.getRemoved());
    if (commitUntrackedResources(server)) set.addAll(indexDiff.getUntracked());

    return set;
  }
コード例 #4
0
  private IndexDiffData calcIndexDiffDataIncremental(
      IProgressMonitor monitor,
      String jobName,
      Collection<String> filesToUpdate,
      Collection<IResource> resourcesToUpdate)
      throws IOException {
    if (indexDiffData == null)
      // Incremental update not possible without prior indexDiffData
      // -> do full refresh instead
      return calcIndexDiffDataFull(monitor, jobName);

    EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(monitor);

    List<String> treeFilterPaths = calcTreeFilterPaths(filesToUpdate);

    WorkingTreeIterator iterator = IteratorService.createInitialIterator(repository);
    if (iterator == null) return null; // workspace is closed
    IndexDiff diffForChangedResources = new IndexDiff(repository, Constants.HEAD, iterator);
    diffForChangedResources.setFilter(PathFilterGroup.createFromStrings(treeFilterPaths));
    diffForChangedResources.diff(jgitMonitor, 0, 0, jobName);
    return new IndexDiffData(
        indexDiffData, filesToUpdate, resourcesToUpdate, diffForChangedResources);
  }