コード例 #1
0
ファイル: ThreeWayMerger.cs プロジェクト: gilran/GitSharp
	    /**
	     * Set the common ancestor tree.
	     *
	     * @param id
	     *            common base treeish; null to automatically compute the common
	     *            base from the input commits during
	     *            {@link #merge(AnyObjectId, AnyObjectId)}.
	     * @throws IncorrectObjectTypeException
	     *             the object is not a treeish.
	     * @throws MissingObjectException
	     *             the object does not exist.
	     * @throws IOException
	     *             the object could not be read.
	     */
	    public void SetBase(AnyObjectId id)
        {
		    if (id != null) 
            {
			    _baseTree = Walk.parseTree(id);
		    } 
            else 
            {
			    _baseTree = null;
		    }
	    }
コード例 #2
0
ファイル: ObjectWalk.cs プロジェクト: HackerBaloo/GitSharp
 internal override void reset(int retainFlags)
 {
     base.reset(retainFlags);
     _pendingObjects = new BlockObjQueue();
     _nextSubtree = null;
 }
コード例 #3
0
ファイル: ObjectWalk.cs プロジェクト: HackerBaloo/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;
            }
        }
コード例 #4
0
ファイル: ObjectWalk.cs プロジェクト: HackerBaloo/GitSharp
 public override void Dispose()
 {
     base.Dispose();
     _pendingObjects = new BlockObjQueue();
     _nextSubtree = null;
     _currentTree = null;
 }
コード例 #5
0
ファイル: ObjectWalk.cs プロジェクト: ArildF/GitSharp
        private void markTreeUninteresting(RevTree tree)
        {
            if ((tree.flags & UNINTERESTING) != 0)
                return;
            tree.flags |= UNINTERESTING;

            treeWalk = treeWalk.resetRoot(db, tree, curs);
            while (!treeWalk.eof())
            {
                FileMode mode = treeWalk.getEntryFileMode();
                int 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(db, t, curs);
                                continue;
                            }
                            break;
                        }
                    default:
                        if (FileMode.GitLink.Equals(mode.Bits))
                            break;
                        treeWalk.getEntryObjectId(idBuffer);
                        throw new CorruptObjectException("Invalid mode " + mode
                                + " for " + idBuffer.ToString() + " "
                                + treeWalk.getEntryPathString() + " in " + tree + ".");
                }

                treeWalk = treeWalk.next();
            }
        }
コード例 #6
0
ファイル: ObjectWalk.cs プロジェクト: ArildF/GitSharp
        /**
         * Pop the next most recent object.
         *
         * @return next most recent object; null if traversal is over.
         * @throws 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.
         * @throws IncorrectObjectTypeException
         *             one or or more of the objects in a tree do not match the type
         *             indicated.
         * @
         *             a pack file or loose object could not be read.
         */
        public RevObject nextObject()
        {
            fromTreeWalk = false;

            if (nextSubtree != null)
            {
                treeWalk = treeWalk.createSubtreeIterator0(db, nextSubtree, curs);
                nextSubtree = null;
            }

            while (!treeWalk.eof())
            {
                FileMode mode = treeWalk.getEntryFileMode();
                int sType = (int)mode.ObjectType;

                switch (sType)
                {
                    case Constants.OBJ_BLOB:
                        {
                            treeWalk.getEntryObjectId(idBuffer);
                            RevBlob o = lookupBlob(idBuffer);
                            if ((o.flags & SEEN) != 0)
                                break;
                            o.flags |= SEEN;
                            if (shouldSkipObject(o))
                                break;
                            fromTreeWalk = true;
                            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;
                            nextSubtree = o;
                            fromTreeWalk = true;
                            return o;
                        }
                    default:
                        if (FileMode.GitLink.Equals(mode.Bits))
                            break;
                        treeWalk.getEntryObjectId(idBuffer);
                        throw new CorruptObjectException("Invalid mode " + mode
                                + " for " + idBuffer.ToString() + " "
                                + treeWalk.getEntryPathString() + " in " + currentTree
                                + ".");
                }

                treeWalk = treeWalk.next();
            }

            for (; ; )
            {
                RevObject o = pendingObjects.next();
                if (o == null)
                    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(db, currentTree, curs);
                }
                return o;
            }
        }
コード例 #7
0
ファイル: ObjectWalk.cs プロジェクト: ArildF/GitSharp
 public override void dispose()
 {
     base.dispose();
     pendingObjects = new BlockObjQueue();
     nextSubtree = null;
     currentTree = null;
 }
コード例 #8
0
ファイル: RevCommit.cs プロジェクト: ArildF/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)
            {
                RevCommit[] pList = new RevCommit[1];
                int nParents = 0;
                for (; ; )
                {
                    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 RevCommit[] { 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);
            }

            buffer = raw;
            flags |= PARSED;
        }
コード例 #9
0
ファイル: Merger.cs プロジェクト: HackerBaloo/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();
        }