A reference to a tree of subtrees/files.
Inheritance: RevObject
コード例 #1
0
 public override void Dispose()
 {
     base.Dispose();
     _pendingObjects = new BlockObjQueue();
     _nextSubtree    = null;
     _currentTree    = null;
 }
コード例 #2
0
 internal override void reset(int retainFlags)
 {
     base.reset(retainFlags);
     _pendingObjects = new BlockObjQueue();
     _treeWalk       = new CanonicalTreeParser();
     _currentTree    = null;
     last            = null;
 }
コード例 #3
0
 public override void Dispose()
 {
     base.Dispose();
     _pendingObjects = new BlockObjQueue();
     _treeWalk       = new CanonicalTreeParser();
     _currentTree    = null;
     last            = null;
 }
コード例 #4
0
        private void MarkTreeUninteresting(RevObject tree)
        {
            if ((tree.Flags & UNINTERESTING) != 0)
            {
                return;
            }
            tree.Flags |= UNINTERESTING;

            _treeWalk = _treeWalk.resetRoot(Repository, tree, WindowCursor);
            while (!_treeWalk.eof())
            {
                FileMode mode  = _treeWalk.EntryFileMode;
                var      sType = (int)mode.ObjectType;

                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(Repository, t, WindowCursor);
                        continue;
                    }
                    break;

                default:
                    if (FileMode.GitLink == FileMode.FromBits(mode.Bits))
                    {
                        break;
                    }
                    _treeWalk.getEntryObjectId(IdBuffer);

                    throw new CorruptObjectException("Invalid mode " + mode
                                                     + " for " + IdBuffer + " "
                                                     + _treeWalk.EntryPathString + " in " + tree + ".");
                }

                _treeWalk = _treeWalk.next();
            }
        }
コード例 #5
0
ファイル: ObjectWalk.cs プロジェクト: spraints/GitSharp
 public override void Dispose()
 {
     base.Dispose();
     _pendingObjects = new BlockObjQueue();
     _treeWalk = new CanonicalTreeParser();
     _currentTree = null;
     last = null;
 }
コード例 #6
0
ファイル: RevCommit.cs プロジェクト: kkl713/GitSharp
        public void parseCanonical(RevWalk walk, byte[] raw)
        {
            MutableObjectId idBuffer = walk.IdBuffer;

            idBuffer.FromString(raw, 5);
            _tree = walk.lookupTree(idBuffer);

            int ptr = 46;

            if (Parents == null)
            {
                var pList    = new RevCommit[1];
                int nParents = 0;

                while (true)
                {
                    if (raw[ptr] != (byte)'p')
                    {
                        break;
                    }
                    idBuffer.FromString(raw, ptr + 7);
                    RevCommit p = walk.lookupCommit(idBuffer);
                    if (nParents == 0)
                    {
                        pList[nParents++] = p;
                    }
                    else if (nParents == 1)
                    {
                        pList    = new[] { pList[0], p };
                        nParents = 2;
                    }
                    else
                    {
                        if (pList.Length <= nParents)
                        {
                            RevCommit[] old = pList;
                            pList = new RevCommit[pList.Length + 32];
                            Array.Copy(old, 0, pList, 0, nParents);
                        }
                        pList[nParents++] = p;
                    }
                    ptr += 48;
                }
                if (nParents != pList.Length)
                {
                    RevCommit[] old = pList;
                    pList = new RevCommit[nParents];
                    Array.Copy(old, 0, pList, 0, nParents);
                }
                Parents = pList;
            }

            // extract time from "committer "
            ptr = RawParseUtils.committer(raw, ptr);
            if (ptr > 0)
            {
                ptr = RawParseUtils.nextLF(raw, ptr, (byte)'>');

                // In 2038 commitTime will overflow unless it is changed to long.
                CommitTime = RawParseUtils.parseBase10(raw, ptr, null);
            }

            if (walk.isRetainBody())
            {
                _buffer = raw;
            }
            Flags |= PARSED;
        }
コード例 #7
0
 internal override void reset(int retainFlags)
 {
     base.reset(retainFlags);
     _pendingObjects = new BlockObjQueue();
     _nextSubtree    = null;
 }
コード例 #8
0
        /// <summary>
        /// Pop the next most recent object.
        /// </summary>
        /// <returns>next most recent object; null if traversal is over.</returns>
        /// <exception cref="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="IncorrectObjectTypeException">
        /// One or or more of the objects in a tree do not match the type indicated.
        /// </exception>
        /// <exception cref="Exception">
        /// A pack file or loose object could not be Read.
        /// </exception>
        public RevObject nextObject()
        {
            _fromTreeWalk = false;

            if (_nextSubtree != null)
            {
                _treeWalk    = _treeWalk.createSubtreeIterator0(Repository, _nextSubtree, WindowCursor);
                _nextSubtree = null;
            }

            while (!_treeWalk.eof())
            {
                FileMode mode  = _treeWalk.EntryFileMode;
                var      sType = (int)mode.ObjectType;

                switch (sType)
                {
                case Constants.OBJ_BLOB:
                    _treeWalk.getEntryObjectId(IdBuffer);

                    RevBlob blob = lookupBlob(IdBuffer);
                    if ((blob.Flags & SEEN) != 0)
                    {
                        break;
                    }

                    blob.Flags |= SEEN;
                    if (ShouldSkipObject(blob))
                    {
                        break;
                    }

                    _fromTreeWalk = true;
                    return(blob);

                case Constants.OBJ_TREE:
                    _treeWalk.getEntryObjectId(IdBuffer);

                    RevTree tree = lookupTree(IdBuffer);
                    if ((tree.Flags & SEEN) != 0)
                    {
                        break;
                    }

                    tree.Flags |= SEEN;
                    if (ShouldSkipObject(tree))
                    {
                        break;
                    }

                    _nextSubtree  = tree;
                    _fromTreeWalk = true;
                    return(tree);

                default:
                    if (FileMode.GitLink.Equals(mode.Bits))
                    {
                        break;
                    }
                    _treeWalk.getEntryObjectId(IdBuffer);

                    throw new CorruptObjectException("Invalid mode " + mode
                                                     + " for " + IdBuffer + " "
                                                     + _treeWalk.EntryPathString + " in " + _currentTree
                                                     + ".");
                }

                _treeWalk = _treeWalk.next();
            }

            while (true)
            {
                RevObject obj = _pendingObjects.next();
                if (obj == null)
                {
                    return(null);
                }
                if ((obj.Flags & SEEN) != 0)
                {
                    continue;
                }

                obj.Flags |= SEEN;
                if (ShouldSkipObject(obj))
                {
                    continue;
                }

                RevTree oTree = (obj as RevTree);
                if (oTree != null)
                {
                    _currentTree = oTree;
                    _treeWalk    = _treeWalk.resetRoot(Repository, _currentTree, WindowCursor);
                }

                return(obj);
            }
        }
コード例 #9
0
ファイル: ObjectWalk.cs プロジェクト: georgeck/GitSharp
        /// <summary>
        /// Pop the next most recent object.
        /// </summary>
        /// <returns>next most recent object; null if traversal is over.</returns>
        /// <exception cref="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="IncorrectObjectTypeException">
        /// One or or more of the objects in a tree do not match the type indicated.
        /// </exception>
        /// <exception cref="Exception">
        /// A pack file or loose object could not be Read.
        /// </exception>
        public RevObject nextObject()
        {
            _fromTreeWalk = false;

            if (_nextSubtree != null)
            {
                _treeWalk = _treeWalk.createSubtreeIterator0(Repository, _nextSubtree, WindowCursor);
                _nextSubtree = null;
            }

            while (!_treeWalk.eof())
            {
                FileMode mode = _treeWalk.EntryFileMode;
                var sType = (int)mode.ObjectType;

                switch (sType)
                {
                    case Constants.OBJ_BLOB:
                        _treeWalk.getEntryObjectId(IdBuffer);

                        RevBlob blob = lookupBlob(IdBuffer);
                        if ((blob.Flags & SEEN) != 0) break;

                        blob.Flags |= SEEN;
                        if (ShouldSkipObject(blob)) break;

                        _fromTreeWalk = true;
                        return blob;

                    case Constants.OBJ_TREE:
                        _treeWalk.getEntryObjectId(IdBuffer);

                        RevTree tree = lookupTree(IdBuffer);
                        if ((tree.Flags & SEEN) != 0) break;

                        tree.Flags |= SEEN;
                        if (ShouldSkipObject(tree)) break;

                        _nextSubtree = tree;
                        _fromTreeWalk = true;
                        return tree;

                    default:
                        if (FileMode.GitLink.Equals(mode.Bits)) break;
                        _treeWalk.getEntryObjectId(IdBuffer);

                        throw new CorruptObjectException("Invalid mode " + mode
                                + " for " + IdBuffer + " "
                                + _treeWalk.EntryPathString + " in " + _currentTree
                                + ".");
                }

                _treeWalk = _treeWalk.next();
            }

            while (true)
            {
                RevObject obj = _pendingObjects.next();
                if (obj == null) return null;
                if ((obj.Flags & SEEN) != 0) continue;

                obj.Flags |= SEEN;
                if (ShouldSkipObject(obj)) continue;

                if (obj is RevTree)
                {
                    _currentTree = (RevTree)obj;
                    _treeWalk = _treeWalk.resetRoot(Repository, _currentTree, WindowCursor);
                }

                return obj;
            }
        }
コード例 #10
0
ファイル: RevCommit.cs プロジェクト: jagregory/GitSharp
        public void parseCanonical(RevWalk walk, byte[] raw)
        {
            MutableObjectId idBuffer = walk.IdBuffer;
            idBuffer.FromString(raw, 5);
            _tree = walk.lookupTree(idBuffer);

            int ptr = 46;
            if (Parents == null)
            {
                var pList = new RevCommit[1];
                int nParents = 0;

                while (true)
                {
                    if (raw[ptr] != (byte)'p') break;
                    idBuffer.FromString(raw, ptr + 7);
                    RevCommit p = walk.lookupCommit(idBuffer);
                    if (nParents == 0)
                    {
                        pList[nParents++] = p;
                    }
                    else if (nParents == 1)
                    {
                        pList = new[] { pList[0], p };
                        nParents = 2;
                    }
                    else
                    {
                        if (pList.Length <= nParents)
                        {
                            RevCommit[] old = pList;
                            pList = new RevCommit[pList.Length + 32];
                            Array.Copy(old, 0, pList, 0, nParents);
                        }
                        pList[nParents++] = p;
                    }
                    ptr += 48;
                }
                if (nParents != pList.Length)
                {
                    RevCommit[] old = pList;
                    pList = new RevCommit[nParents];
                    Array.Copy(old, 0, pList, 0, nParents);
                }
                Parents = pList;
            }

            // extract time from "committer "
            ptr = RawParseUtils.committer(raw, ptr);
            if (ptr > 0)
            {
                ptr = RawParseUtils.nextLF(raw, ptr, (byte)'>');

                // In 2038 commitTime will overflow unless it is changed to long.
                CommitTime = RawParseUtils.parseBase10(raw, ptr, null);
            }

            if (walk.isRetainBody())
                _buffer = raw;
            Flags |= PARSED;
        }
コード例 #11
0
ファイル: ThreeWayMerger.cs プロジェクト: dev218/GitSharp
		/// <summary>
		/// Set the common ancestor tree.
		/// </summary>
		/// <param name="id">
		/// Common base treeish; null to automatically compute the common
		/// base from the input commits during
		/// <see cref="Merge(AnyObjectId, AnyObjectId)"/>.
		/// </param>
		/// <exception cref="IncorrectObjectTypeException">
		/// The object is not a <see cref="Treeish"/>.
		/// </exception>
		/// <exception cref="MissingObjectException">
		/// The object does not exist.
		/// </exception>
		/// <exception cref="IOException">
		/// The object could not be read.
		/// </exception>
		public void SetBase(AnyObjectId id)
		{
			_baseTree = id != null ? Walk.parseTree(id) : null;
		}
コード例 #12
0
        private void MarkTreeComplete(RevTree tree)
        {
            if (tree.has(COMPLETE)) return;

            tree.add(COMPLETE);
            _treeWalk.reset(tree);
            while (_treeWalk.next())
            {
                FileMode mode = _treeWalk.getFileMode(0);
                int sType = (int)mode.ObjectType;

                switch (sType)
                {
                    case Constants.OBJ_BLOB:
                        _treeWalk.getObjectId(_idBuffer, 0);
                        _revWalk.lookupAny(_idBuffer, sType).add(COMPLETE);
                        continue;

                    case Constants.OBJ_TREE:
                        {
                            _treeWalk.getObjectId(_idBuffer, 0);
                            RevObject o = _revWalk.lookupAny(_idBuffer, sType);
                            if (!o.has(COMPLETE))
                            {
                                o.add(COMPLETE);
                                _treeWalk.enterSubtree();
                            }
                            continue;
                        }

                    default:
                        if (FileMode.GitLink.Equals(sType))
                            continue;
                        _treeWalk.getObjectId(_idBuffer, 0);
                        throw new CorruptObjectException("Invalid mode " + mode.ObjectType + " for " + _idBuffer.Name + " " +
                                                         _treeWalk.getPathString() + " in " + tree.Name);
                }
            }
        }
コード例 #13
0
ファイル: ObjectWalk.cs プロジェクト: georgeck/GitSharp
 internal override void reset(int retainFlags)
 {
     base.reset(retainFlags);
     _pendingObjects = new BlockObjQueue();
     _nextSubtree = null;
 }
コード例 #14
0
ファイル: ObjectWalk.cs プロジェクト: spraints/GitSharp
        /// <summary>
        /// Pop the next most recent object.
        /// </summary>
        /// <returns>next most recent object; null if traversal is over.</returns>
        /// <exception cref="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="IncorrectObjectTypeException">
        /// One or or more of the objects in a tree do not match the type indicated.
        /// </exception>
        /// <exception cref="Exception">
        /// A pack file or loose object could not be Read.
        /// </exception>
        public RevObject nextObject()
        {
            if (last != null)
            {
                _treeWalk = last is RevTree ? enter(last) : _treeWalk.next();
            }

            while (!_treeWalk.eof())
            {
                FileMode mode = _treeWalk.EntryFileMode;

                switch ((int)mode.ObjectType)
                {
                    case Constants.OBJ_BLOB:
                        _treeWalk.getEntryObjectId(IdBuffer);

                        RevBlob blob = lookupBlob(IdBuffer);
                        if ((blob.Flags & SEEN) != 0) break;

                        blob.Flags |= SEEN;
                        if (ShouldSkipObject(blob)) break;

                        last = blob;
                        return blob;

                    case Constants.OBJ_TREE:
                        _treeWalk.getEntryObjectId(IdBuffer);

                        RevTree tree = lookupTree(IdBuffer);
                        if ((tree.Flags & SEEN) != 0) break;

                        tree.Flags |= SEEN;
                        if (ShouldSkipObject(tree)) break;

                        last = tree;
                        return tree;

                    default:
                        if (FileMode.GitLink.Equals(mode.Bits)) break;
                        _treeWalk.getEntryObjectId(IdBuffer);

                        throw new CorruptObjectException("Invalid mode " + mode
                                + " for " + IdBuffer.Name + " '"
                                + _treeWalk.EntryPathString + "' in "
                                + _currentTree.Name + ".");
                }

                _treeWalk = _treeWalk.next();
            }

            last = null;
            while (true)
            {
                RevObject obj = _pendingObjects.next();
                if (obj == null) return null;
                if ((obj.Flags & SEEN) != 0) continue;

                obj.Flags |= SEEN;
                if (ShouldSkipObject(obj)) continue;

                RevTree oTree = (obj as RevTree);
                if (oTree != null)
                {
                    _currentTree = oTree;
                    _treeWalk = _treeWalk.resetRoot(Repository, _currentTree, WindowCursor);
                }

                return obj;
            }
        }
コード例 #15
0
ファイル: Merger.cs プロジェクト: jagregory/GitSharp
        ///	<summary>
        /// Merge together two or more tree-ish objects.
        /// <para />
        /// Any tree-ish may be supplied as inputs. Commits and/or tags pointing at
        /// trees or commits may be passed as input objects.
        /// </summary>
        /// <param name="tips">
        /// source trees to be combined together. The merge base is not
        /// included in this set. </param>
        /// <returns>
        /// True if the merge was completed without conflicts; false if the
        /// merge strategy cannot handle this merge or there were conflicts
        /// preventing it from automatically resolving all paths.
        /// </returns>
        /// <exception cref="IncorrectObjectTypeException">
        /// one of the input objects is not a commit, but the strategy
        /// requires it to be a commit.
        /// </exception>
        /// <exception cref="IOException">
        /// one or more sources could not be read, or outputs could not
        /// be written to the Repository.
        /// </exception>
        public virtual bool Merge(AnyObjectId[] tips)
        {
            _sourceObjects = new RevObject[tips.Length];
            for (int i = 0; i < tips.Length; i++)
                _sourceObjects[i] = _walk.parseAny(tips[i]);

            _sourceCommits = new RevCommit[_sourceObjects.Length];
            for (int i = 0; i < _sourceObjects.Length; i++)
            {
                try
                {
                    _sourceCommits[i] = _walk.parseCommit(_sourceObjects[i]);
                }
                catch (IncorrectObjectTypeException)
                {
                    _sourceCommits[i] = null;
                }
            }

            SourceTrees = new RevTree[_sourceObjects.Length];
            for (int i = 0; i < _sourceObjects.Length; i++)
                SourceTrees[i] = _walk.parseTree(_sourceObjects[i]);

            return MergeImpl();
        }
コード例 #16
0
ファイル: ObjectWalk.cs プロジェクト: spraints/GitSharp
 internal override void reset(int retainFlags)
 {
     base.reset(retainFlags);
     _pendingObjects = new BlockObjQueue();
     _treeWalk = new CanonicalTreeParser();
     _currentTree = null;
     last = null;
 }
コード例 #17
0
ファイル: ObjectWalk.cs プロジェクト: georgeck/GitSharp
 public override void Dispose()
 {
     base.Dispose();
     _pendingObjects = new BlockObjQueue();
     _nextSubtree = null;
     _currentTree = null;
 }