コード例 #1
0
ファイル: ObjectWalk.cs プロジェクト: shoff/ngit
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        private void MarkTreeUninteresting(RevTree tree)
        {
            if ((tree.flags & UNINTERESTING) != 0)
            {
                return;
            }
            tree.flags |= UNINTERESTING;
            treeWalk    = treeWalk.ResetRoot(reader, tree);
            while (!treeWalk.Eof)
            {
                FileMode mode  = treeWalk.EntryFileMode;
                int      sType = mode.GetObjectType();
                switch (sType)
                {
                case Constants.OBJ_BLOB:
                {
                    treeWalk.GetEntryObjectId(idBuffer);
                    LookupBlob(idBuffer).flags |= UNINTERESTING;
                    break;
                }

                case Constants.OBJ_TREE:
                {
                    treeWalk.GetEntryObjectId(idBuffer);
                    RevTree t = LookupTree(idBuffer);
                    if ((t.flags & UNINTERESTING) == 0)
                    {
                        t.flags |= UNINTERESTING;
                        treeWalk = treeWalk.CreateSubtreeIterator0(reader, t);
                        continue;
                    }
                    break;
                }

                default:
                {
                    if (FileMode.GITLINK.Equals(mode))
                    {
                        break;
                    }
                    treeWalk.GetEntryObjectId(idBuffer);
                    throw new CorruptObjectException(MessageFormat.Format(JGitText.Get().corruptObjectInvalidMode3
                                                                          , mode, idBuffer.Name, treeWalk.EntryPathString, tree));
                }
                }
                treeWalk = treeWalk.Next();
            }
        }
コード例 #2
0
ファイル: ObjectWalk.cs プロジェクト: shoff/ngit
        /// <summary>Pop the next most recent object.</summary>
        /// <remarks>Pop the next most recent object.</remarks>
        /// <returns>next most recent object; null if traversal is over.</returns>
        /// <exception cref="NGit.Errors.MissingObjectException">
        /// one or or more of the next objects are not available from the
        /// object database, but were thought to be candidates for
        /// traversal. This usually indicates a broken link.
        /// </exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException">
        /// one or or more of the objects in a tree do not match the type
        /// indicated.
        /// </exception>
        /// <exception cref="System.IO.IOException">a pack file or loose object could not be read.
        ///     </exception>
        public virtual RevObject NextObject()
        {
            if (last != null)
            {
                treeWalk = last is RevTree?Enter(last) : treeWalk.Next();
            }
            while (!treeWalk.Eof)
            {
                FileMode mode = treeWalk.EntryFileMode;
                switch (mode.GetObjectType())
                {
                case Constants.OBJ_BLOB:
                {
                    treeWalk.GetEntryObjectId(idBuffer);
                    RevBlob o = LookupBlob(idBuffer);
                    if ((o.flags & SEEN) != 0)
                    {
                        break;
                    }
                    o.flags |= SEEN;
                    if (ShouldSkipObject(o))
                    {
                        break;
                    }
                    last = o;
                    return(o);
                }

                case Constants.OBJ_TREE:
                {
                    treeWalk.GetEntryObjectId(idBuffer);
                    RevTree o = LookupTree(idBuffer);
                    if ((o.flags & SEEN) != 0)
                    {
                        break;
                    }
                    o.flags |= SEEN;
                    if (ShouldSkipObject(o))
                    {
                        break;
                    }
                    last = o;
                    return(o);
                }

                default:
                {
                    if (FileMode.GITLINK.Equals(mode))
                    {
                        break;
                    }
                    treeWalk.GetEntryObjectId(idBuffer);
                    throw new CorruptObjectException(MessageFormat.Format(JGitText.Get().corruptObjectInvalidMode3
                                                                          , mode, idBuffer.Name, treeWalk.EntryPathString, currentTree.Name));
                }
                }
                treeWalk = treeWalk.Next();
            }
            if (firstCommit != null)
            {
                reader.WalkAdviceBeginTrees(this, firstCommit, lastCommit);
                firstCommit = null;
                lastCommit  = null;
            }
            last = null;
            for (; ;)
            {
                RevObject o = pendingObjects.Next();
                if (o == null)
                {
                    reader.WalkAdviceEnd();
                    return(null);
                }
                if ((o.flags & SEEN) != 0)
                {
                    continue;
                }
                o.flags |= SEEN;
                if (ShouldSkipObject(o))
                {
                    continue;
                }
                if (o is RevTree)
                {
                    currentTree = (RevTree)o;
                    treeWalk    = treeWalk.ResetRoot(reader, currentTree);
                }
                return(o);
            }
        }