Package org.eclipse.jgit.treewalk

Examples of org.eclipse.jgit.treewalk.AbstractTreeIterator


    filters.add(new SkipWorkTreeFilter(INDEX));
    indexDiffFilter = new IndexDiffFilter(INDEX, WORKDIR);
    filters.add(indexDiffFilter);
    treeWalk.setFilter(AndTreeFilter.create(filters));
    while (treeWalk.next()) {
      AbstractTreeIterator treeIterator = treeWalk.getTree(TREE,
          AbstractTreeIterator.class);
      DirCacheIterator dirCacheIterator = treeWalk.getTree(INDEX,
          DirCacheIterator.class);
      WorkingTreeIterator workingTreeIterator = treeWalk.getTree(WORKDIR,
          WorkingTreeIterator.class);

      if (dirCacheIterator != null) {
        final DirCacheEntry dirCacheEntry = dirCacheIterator
            .getDirCacheEntry();
        if (dirCacheEntry != null && dirCacheEntry.getStage() > 0) {
          conflicts.add(treeWalk.getPathString());
          continue;
        }
      }

      if (treeIterator != null) {
        if (dirCacheIterator != null) {
          if (!treeIterator.idEqual(dirCacheIterator)
              || treeIterator.getEntryRawMode()
              != dirCacheIterator.getEntryRawMode()) {
            // in repo, in index, content diff => changed
            changed.add(treeWalk.getPathString());
          }
        } else {
View Full Code Here


        MutableObjectId id = new MutableObjectId();
        List<PathEdit> wtEdits = new ArrayList<PathEdit>();
        List<String> wtDeletes = new ArrayList<String>();
        do {
          AbstractTreeIterator headIter = treeWalk.getTree(0,
              AbstractTreeIterator.class);
          DirCacheIterator indexIter = treeWalk.getTree(1,
              DirCacheIterator.class);
          WorkingTreeIterator wtIter = treeWalk.getTree(2,
              WorkingTreeIterator.class);
View Full Code Here

      walk.setRecursive(true);
      walk.setFilter(AndTreeFilter.create(PathSuffixFilter
          .create(IProjectDescription.DESCRIPTION_FILE_NAME),
          TreeFilter.ANY_DIFF));
      while (walk.next()) {
        AbstractTreeIterator targetIter = walk.getTree(0,
            AbstractTreeIterator.class);
        if (targetIter != null)
          continue;

        AbstractTreeIterator currentIter = walk.getTree(1,
            AbstractTreeIterator.class);
        AbstractTreeIterator workingIter = walk.getTree(2,
            AbstractTreeIterator.class);
        if (currentIter == null || workingIter == null)
          continue;

        IProject project = locations.get(new File(root, walk
View Full Code Here

            .getDirCacheEntry();

        boolean conflicting = dirCacheEntry != null
            && dirCacheEntry.getStage() > 0;

        AbstractTreeIterator rt = tw.getTree(repositoryTreeIndex,
            AbstractTreeIterator.class);

        // compare local file against HEAD to see if it was modified
        boolean modified = rt != null
            && !fit.getEntryObjectId()
                .equals(rt.getEntryObjectId());

        // if this is neither conflicting nor changed, we skip it
        if (!conflicting && !modified)
          continue;
View Full Code Here

      if (monitor.isCanceled())
        throw new InterruptedException();
      while (tw.next()) {
        if (monitor.isCanceled())
          throw new InterruptedException();
        AbstractTreeIterator compareVersionIterator = tw.getTree(
            compareTreeIndex, AbstractTreeIterator.class);
        AbstractTreeIterator baseVersionIterator = tw.getTree(
            baseTreeIndex, AbstractTreeIterator.class);

        IFileRevision left = null;
        IFileRevision right = null;
        String repoRelativePath = baseVersionIterator != null
            ? baseVersionIterator.getEntryPathString()
            : compareVersionIterator.getEntryPathString();
        IPath currentPath = new Path(repoRelativePath);

        // Updating the progress bar is slow, so just sample it. To
        // make sure slow compares are reflected in the progress
        // monitor also update before comparing large files.
        long currentTimeMilliseconds = System.currentTimeMillis();
        long size1 = -1;
        long size2 = -1;
        if (compareVersionIterator != null
            && baseVersionIterator != null) {
          size1 = getEntrySize(tw, compareVersionIterator);
          size2 = getEntrySize(tw, baseVersionIterator);
        }
        final long REPORTSIZE = 100000;
        if (size1 > REPORTSIZE
            || size2 > REPORTSIZE
            || currentTimeMilliseconds - previousTimeMilliseconds > 500) {
          monitor.setTaskName(currentPath.toString());
          previousTimeMilliseconds = currentTimeMilliseconds;
        }

        Type type = null;
        if (compareVersionIterator != null
            && baseVersionIterator != null) {
          boolean equalContent = compareVersionIterator
              .getEntryObjectId().equals(
                  baseVersionIterator.getEntryObjectId());
          type = equalContent ? Type.FILE_BOTH_SIDES_SAME
              : Type.FILE_BOTH_SIDES_DIFFER;
        } else if (compareVersionIterator != null
            && baseVersionIterator == null) {
          type = Type.FILE_DELETED;
View Full Code Here

    try {
      while (tw.next()) {
        if (monitor.isCanceled())
          throw new InterruptedException();
        AbstractTreeIterator compareVersionIterator = tw.getTree(
            compareTreeIndex, AbstractTreeIterator.class);
        AbstractTreeIterator baseVersionIterator = tw.getTree(
            baseTreeIndex, AbstractTreeIterator.class);
        if (checkIgnored
            && baseVersionIterator != null
            && ((WorkingTreeIterator) baseVersionIterator)
                .isEntryIgnored())
          continue;


        if (compareVersionIterator != null
            && baseVersionIterator != null) {
          boolean equalContent = compareVersionIterator
              .getEntryObjectId().equals(
                  baseVersionIterator.getEntryObjectId());
          if (equalContent)
            continue;
        }

        String encoding = null;

        GitFileRevision compareRev = null;
        if (compareVersionIterator != null) {
          String entryPath = compareVersionIterator.getEntryPathString();
          encoding = CompareCoreUtils.getResourceEncoding(repository, entryPath);
          if (!useIndex)
            compareRev = GitFileRevision.inCommit(repository,
                compareCommit, entryPath,
                tw.getObjectId(compareTreeIndex));
          else
            compareRev = GitFileRevision.inIndex(repository,
                entryPath);
        }

        GitFileRevision baseRev = null;
        if (baseVersionIterator != null) {
          String entryPath = baseVersionIterator.getEntryPathString();
          if (encoding == null) {
            encoding = CompareCoreUtils.getResourceEncoding(repository, entryPath);
          }
          baseRev = GitFileRevision.inCommit(repository, baseCommit,
              entryPath, tw.getObjectId(baseTreeIndex));
        }

        if (compareVersionIterator != null
            && baseVersionIterator != null) {
          monitor.setTaskName(baseVersionIterator
              .getEntryPathString());
          // content exists on both sides
          add(result, baseVersionIterator.getEntryPathString(),
              new DiffNode(new FileRevisionTypedElement(compareRev, encoding),
                  new FileRevisionTypedElement(baseRev, encoding)));
        } else if (baseVersionIterator != null
            && compareVersionIterator == null) {
          monitor.setTaskName(baseVersionIterator
              .getEntryPathString());
          // only on base side
          add(result, baseVersionIterator.getEntryPathString(),
              new DiffNode(Differencer.DELETION | Differencer.RIGHT, null, null,
                  new FileRevisionTypedElement(baseRev, encoding)));
        } else if (compareVersionIterator != null
            && baseVersionIterator == null) {
          monitor.setTaskName(compareVersionIterator
View Full Code Here

    public static void main(String[] args) throws IOException, GitAPIException {
        Repository repository = CookbookHelper.openJGitCookbookRepository();

        // the diff works on TreeIterators, we prepare two for the two branches
        AbstractTreeIterator oldTreeParser = prepareTreeParser(repository, "09c65401f3730eb3e619c33bf31e2376fb393727");
        AbstractTreeIterator newTreeParser = prepareTreeParser(repository, "aa31703b65774e4a06010824601e56375a70078c");

        // then the procelain diff-command returns a list of diff entries
        List<DiffEntry> diff = new Git(repository).diff().
                setOldTree(oldTreeParser).
                setNewTree(newTreeParser).
View Full Code Here

    public static void main(String[] args) throws IOException, GitAPIException {
        Repository repository = CookbookHelper.openJGitCookbookRepository();

        // the diff works on TreeIterators, we prepare two for the two branches
        AbstractTreeIterator oldTreeParser = prepareTreeParser(repository, "refs/heads/testbranch");
        AbstractTreeIterator newTreeParser = prepareTreeParser(repository, "refs/heads/master");

        // then the procelain diff-command returns a list of diff entries
        List<DiffEntry> diff = new Git(repository).diff().setOldTree(oldTreeParser).setNewTree(newTreeParser).call();
        for (DiffEntry entry : diff) {
            System.out.println("Entry: " + entry);
View Full Code Here

    ContainerTreeIterator tree = new ContainerTreeIterator(repository, project.getProject());
    int treeIndex = treeWalk.addTree(tree);
    treeWalk.setRecursive(true);
    List<Entry> entries = new ArrayList<Entry>();
    while (treeWalk.next()) {
      AbstractTreeIterator it = treeWalk.getTree(treeIndex, AbstractTreeIterator.class);
      Entry entry = new Entry(treeWalk.getPathString(), it.getClass());
      entries.add(entry);
    }
    return entries;
  }
View Full Code Here

      walk.addTree(commit.getTree());
      walk.addTree(new DirCacheIterator(dc));
      walk.setRecursive(true);

      while (walk.next()) {
        AbstractTreeIterator cIter = walk.getTree(0,
            AbstractTreeIterator.class);
        if (cIter == null) {
          editor.add(new DeletePath(walk.getPathString()));
          continue;
        }

        final DirCacheEntry entry = new DirCacheEntry(walk.getRawPath());
        entry.setFileMode(cIter.getEntryFileMode());
        entry.setObjectIdFromRaw(cIter.idBuffer(), cIter.idOffset());

        DirCacheIterator dcIter = walk.getTree(1,
            DirCacheIterator.class);
        if (dcIter != null && dcIter.idEqual(cIter)) {
          DirCacheEntry indexEntry = dcIter.getDirCacheEntry();
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.treewalk.AbstractTreeIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.