コード例 #1
0
ファイル: RevCommit.cs プロジェクト: ArildF/GitSharp
        public static void carryFlags(RevCommit c, int carry)
        {
            for (; ; )
            {
                RevCommit[] pList = c.parents;
                if (pList == null)
                    return;
                int n = pList.Length;
                if (n == 0)
                    return;

                for (int i = 1; i < n; i++)
                {
                    RevCommit p = pList[i];
                    if ((p.flags & carry) == carry)
                        continue;
                    p.flags |= carry;
                    carryFlags(p, carry);
                }

                c = pList[0];
                if ((c.flags & carry) == carry)
                    return;
                c.flags |= carry;
            }
        }
コード例 #2
0
ファイル: AbstractRevQueue.cs プロジェクト: ArildF/GitSharp
 /**
  * Add a commit if it does not have a flag set yet, then set the flag.
  * <p>
  * This method permits the application to test if the commit has the given
  * flag; if it does not already have the flag than the commit is added to
  * the queue and the flag is set. This later will prevent the commit from
  * being added twice.
  *
  * @param c
  *            commit to add.
  * @param queueControl
  *            flag that controls admission to the queue.
  */
 public void add(RevCommit c, RevFlag queueControl)
 {
     if (!c.has(queueControl))
     {
         c.add(queueControl);
         add(c);
     }
 }
コード例 #3
0
ファイル: LIFORevQueue.cs プロジェクト: ArildF/GitSharp
 public override void add(RevCommit c)
 {
     Block b = head;
     if (b == null || !b.canUnpop())
     {
         b = free.newBlock();
         b.resetToEnd();
         b.next = head;
         head = b;
     }
     b.unpop(c);
 }
コード例 #4
0
ファイル: FIFORevQueue.cs プロジェクト: ArildF/GitSharp
 public override void add(RevCommit c)
 {
     Block b = tail;
     if (b == null)
     {
         b = free.newBlock();
         b.add(c);
         head = b;
         tail = b;
         return;
     }
     else if (b.isFull())
     {
         b = free.newBlock();
         tail.next = b;
         tail = b;
     }
     b.add(c);
 }
コード例 #5
0
ファイル: FIFORevQueue.cs プロジェクト: HackerBaloo/GitSharp
        public override void add(RevCommit c)
        {
            Block b = _tail;
            if (b == null)
            {
                b = Free.newBlock();
                b.add(c);
                _head = b;
                _tail = b;
                return;
            }

            if (b.isFull())
            {
                b = Free.newBlock();
                _tail.Next = b;
                _tail = b;
            }
            b.add(c);
        }
コード例 #6
0
        public void testParse_explicit_bad_encoded()
        {
            RevCommit c;
            using (var b = new BinaryWriter(new MemoryStream()))
            {
                b.Write(_utf8Enc.GetBytes("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"));
                b.Write(_isoEnc.GetBytes("author F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n"));
                b.Write(_utf8Enc.GetBytes("committer C O. Miter <*****@*****.**> 1218123390 -0500\n"));
                b.Write(_utf8Enc.GetBytes("encoding EUC-JP\n"));
                b.Write(_utf8Enc.GetBytes("\n"));
                b.Write(_utf8Enc.GetBytes("\u304d\u308c\u3044\n"));
                b.Write(_utf8Enc.GetBytes("\n"));
                b.Write(_utf8Enc.GetBytes("Hi\n"));

                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new GitSharp.RevWalk.RevWalk(db), ((MemoryStream) b.BaseStream).ToArray());
            }
            Assert.AreEqual("F\u00f6r fattare", c.getAuthorIdent().Name);
            Assert.AreEqual("\u304d\u308c\u3044", c.getShortMessage());
            Assert.AreEqual("\u304d\u308c\u3044\n\nHi\n", c.getFullMessage());
        }
コード例 #7
0
ファイル: DateRevQueue.cs プロジェクト: ArildF/GitSharp
 public override void add(RevCommit c)
 {
     Entry q = head;
     long when = c.commitTime;
     Entry n = newEntry(c);
     if (q == null || when > q.commit.commitTime)
     {
         n.next = q;
         head = n;
     }
     else
     {
         Entry p = q.next;
         while (p != null && p.commit.commitTime > when)
         {
             q = p;
             p = q.next;
         }
         n.next = q.next;
         q.next = n;
     }
 }
コード例 #8
0
ファイル: AbstractRevQueue.cs プロジェクト: ArildF/GitSharp
 /**
  * Add a commit's parents if one does not have a flag set yet.
  * <p>
  * This method permits the application to test if the commit has the given
  * flag; if it does not already have the flag than the commit is added to
  * the queue and the flag is set. This later will prevent the commit from
  * being added twice.
  *
  * @param c
  *            commit whose parents should be added.
  * @param queueControl
  *            flag that controls admission to the queue.
  */
 public void addParents(RevCommit c, RevFlag queueControl)
 {
     RevCommit[] pList = c.parents;
     if (pList == null)
         return;
     foreach (RevCommit p in pList)
         add(p, queueControl);
 }
コード例 #9
0
ファイル: AbstractRevQueue.cs プロジェクト: ArildF/GitSharp
 internal static void describe(StringBuilder s, RevCommit c)
 {
     s.Append(c.ToString());
     s.Append('\n');
 }
コード例 #10
0
        public override RevCommit next()
        {
            try
            {
                while (true)
                {
                    RevCommit c = _pending.next();
                    if (c == null)
                    {
                        _walker.WindowCursor.Release();
                        return null;
                    }

                    bool produce = !((c.Flags & UNINTERESTING) != 0) && _filter.include(_walker, c);

                    foreach (RevCommit p in c.Parents)
                    {
                        if ((p.Flags & SEEN) != 0) continue;
                        if ((p.Flags & PARSED) == 0)
                        {
                            p.parseHeaders(_walker);
                        }
                        p.Flags |= SEEN;
                        _pending.add(p);
                    }
                    _walker.carryFlagsImpl(c);

                    if ((c.Flags & UNINTERESTING) != 0)
                    {
                        if (_pending.everbodyHasFlag(UNINTERESTING))
                        {
                            RevCommit n = _pending.peek();
                            if (n != null && n.CommitTime >= _last.CommitTime)
                            {
                                // This is too close to call. The Next commit we
                                // would pop is dated After the last one produced.
                                // We have to keep going to ensure that we carry
                                // flags as much as necessary.
                                //
                                _overScan = OVER_SCAN;
                            }
                            else if (--_overScan == 0)
                            {
                                throw StopWalkException.INSTANCE;
                            }
                        }
                        else
                        {
                            _overScan = OVER_SCAN;
                        }
                        if (CanDispose)
                        {
                            c.DisposeBody();
                        }
                        continue;
                    }

                    if (produce)
                    {
                        return _last = c;
                    }

                    if (CanDispose)
                    {
                        c.DisposeBody();
                    }
                }
            }
            catch (StopWalkException)
            {
                _walker.WindowCursor.Release();
                _pending.clear();
                return null;
            }
        }
コード例 #11
0
 static PendingGenerator()
 {
     InitLast = new RevCommit(ObjectId.ZeroId) { CommitTime = int.MaxValue };
 }
コード例 #12
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;
        }
コード例 #13
0
		public boolean include(RevWalk walker, RevCommit cmit)
コード例 #14
0
ファイル: UploadPack.cs プロジェクト: gilran/GitSharp
 private bool wantSatisfied(RevCommit want)
 {
     walk.resetRetain(SAVE);
     walk.markStart(want);
     for (;;)
     {
         RevCommit c = walk.next();
         if (c == null) break;
         if (c.has(PEER_HAS))
         {
             if (!c.has(COMMON))
             {
                 c.add(COMMON);
                 commonBase.Add(c);
             }
             return true;
         }
         c.dispose();
     }
     return false;            
 }
コード例 #15
0
ファイル: RefUpdateTest.cs プロジェクト: drothmaler/GitSharp
 public void testNewNamespaceConflictWithLoosePrefixOfExisting()
 {
     string newRef = "refs/heads/z/a";
     RefUpdate ru = updateRef(newRef);
     RevCommit newid = new RevCommit(ru.NewObjectId)
     {
         // empty
     };
     ru.NewObjectId = newid;
     RefUpdate.RefUpdateResult update = ru.Update();
     Assert.AreEqual(RefUpdate.RefUpdateResult.New, update);
     // end setup
     string newRef2 = "refs/heads/z";
     RefUpdate ru2 = updateRef(newRef2);
     RevCommit newid2 = new RevCommit(ru2.NewObjectId)
     {
         // empty
     };
     ru.NewObjectId = newid2;
     RefUpdate.RefUpdateResult update2 = ru2.Update();
     Assert.AreEqual(RefUpdate.RefUpdateResult.LockFailure, update2);
 }
コード例 #16
0
ファイル: DateRevQueue.cs プロジェクト: ArildF/GitSharp
 private Entry newEntry(RevCommit c)
 {
     Entry r = free;
     if (r == null)
         r = new Entry();
     else
         free = r.next;
     r.commit = c;
     return r;
 }
コード例 #17
0
        public override bool include(RevWalk walker, RevCommit c)
        {
            // Reset the tree filter to scan this commit and parents.
            //
            RevCommit[] pList = c.Parents;
            int nParents = pList.Length;
            TreeWalk.TreeWalk tw = _pathFilter;
            var trees = new ObjectId[nParents + 1];

            for (int i = 0; i < nParents; i++)
            {
                RevCommit p = c.Parents[i];
                if ((p.Flags & Parsed) == 0)
                {
                    p.parseHeaders(walker);
                }
                trees[i] = p.Tree;
            }

            trees[nParents] = c.Tree;
            tw.reset(trees);

            if (nParents == 1)
            {
                // We have exactly one parent. This is a very common case.
                //
                int chgs = 0, adds = 0;
                while (tw.next())
                {
                    chgs++;
                    if (tw.getRawMode(0) == 0 && tw.getRawMode(1) != 0)
                        adds++;
                    else
                        break; // no point in looking at this further.
                }

                if (chgs == 0)
                {
                    // No changes, so our tree is effectively the same as
                    // our parent tree. We pass the buck to our parent.
                    //
                    c.Flags |= Rewrite;
                    return false;
                }

                // We have interesting items, but neither of the special
                // cases denoted above.
                //
                return true;
            }

            if (nParents == 0)
            {
                // We have no parents to compare against. Consider us to be
                // Rewrite only if we have no paths matching our filter.
                //
                if (tw.next()) return true;

                c.Flags |= Rewrite;
                return false;
            }

            // We are a merge commit. We can only be Rewrite if we are same
            // to _all_ parents. We may also be able to eliminate a parent if
            // it does not contribute changes to us. Such a parent may be an
            // uninteresting side branch.
            //
            var chgs_ = new int[nParents];
            var adds_ = new int[nParents];
            while (tw.next())
            {
                int myMode = tw.getRawMode(nParents);
                for (int i = 0; i < nParents; i++)
                {
                    int pMode = tw.getRawMode(i);
                    if (myMode == pMode && tw.idEqual(i, nParents)) continue;

                    chgs_[i]++;
                    if (pMode == 0 && myMode != 0)
                    {
                        adds_[i]++;
                    }
                }
            }

            bool same = false;
            bool diff = false;
            for (int i = 0; i < nParents; i++)
            {
                if (chgs_[i] == 0)
                {
                    // No changes, so our tree is effectively the same as
                    // this parent tree. We pass the buck to only this one
                    // parent commit.
                    //

                    RevCommit p = pList[i];
                    if ((p.Flags & Uninteresting) != 0)
                    {
                        // This parent was marked as not interesting by the
                        // application. We should look for another parent
                        // that is interesting.
                        //
                        same = true;
                        continue;
                    }

                    c.Flags |= Rewrite;
                    c.Parents = new[] { p };
                    return false;
                }

                if (chgs_[i] == adds_[i])
                {
                    // All of the differences from this parent were because we
                    // added files that they did not have. This parent is our
                    // "empty tree root" and thus their history is not relevant.
                    // Cut our grandparents to be an empty list.
                    //
                    pList[i].Parents = RevCommit.NoParents;
                }

                // We have an interesting difference relative to this parent.
                //
                diff = true;
            }

            if (diff && !same)
            {
                // We did not abort above, so we are different in at least one
                // way from all of our parents. We have to take the blame for
                // that difference.
                //
                return true;
            }

            // We are the same as all of our parents. We must keep them
            // as they are and allow those parents to flow into pending
            // for further scanning.
            //
            c.Flags |= Rewrite;
            return false;
        }
コード例 #18
0
ファイル: PendingGenerator.cs プロジェクト: ArildF/GitSharp
 static PendingGenerator()
 {
     INIT_LAST = new RevCommit(ObjectId.ZeroId);
     INIT_LAST.commitTime = int.MaxValue;
 }
コード例 #19
0
ファイル: PendingGenerator.cs プロジェクト: ArildF/GitSharp
        public override RevCommit next()
        {
            try
            {
                for (; ; )
                {
                    RevCommit c = pending.next();
                    if (c == null)
                    {
                        walker.curs.release();
                        return null;
                    }

                    bool produce;
                    if ((c.flags & UNINTERESTING) != 0)
                        produce = false;
                    else
                        produce = filter.include(walker, c);

                    foreach (RevCommit p in c.parents)
                    {
                        if ((p.flags & SEEN) != 0)
                            continue;
                        if ((p.flags & PARSED) == 0)
                            p.parse(walker);
                        p.flags |= SEEN;
                        pending.add(p);
                    }
                    walker.carryFlagsImpl(c);

                    if ((c.flags & UNINTERESTING) != 0)
                    {
                        if (pending.everbodyHasFlag(UNINTERESTING))
                        {
                            RevCommit n = pending.peek();
                            if (n != null && n.commitTime >= last.commitTime)
                            {
                                // This is too close to call. The next commit we
                                // would pop is dated after the last one produced.
                                // We have to keep going to ensure that we carry
                                // flags as much as necessary.
                                //
                                overScan = OVER_SCAN;
                            }
                            else if (--overScan == 0)
                                throw StopWalkException.INSTANCE;
                        }
                        else
                        {
                            overScan = OVER_SCAN;
                        }
                        if (canDispose)
                            c.dispose();
                        continue;
                    }

                    if (produce)
                        return last = c;
                    else if (canDispose)
                        c.dispose();
                }
            }
            catch (StopWalkException swe)
            {
                walker.curs.release();
                pending.clear();
                return null;
            }
        }
コード例 #20
0
        public override void setUp()
        {
            base.setUp();

            // Test graph was stolen from git-core t6012-rev-list-simplify
            // (by Junio C Hamano in 65347030590bcc251a9ff2ed96487a0f1b9e9fa8)
            //
            RevBlob zF = blob("zF");
            RevBlob zH = blob("zH");
            RevBlob zI = blob("zI");
            RevBlob zS = blob("zS");
            RevBlob zY = blob("zY");

            a = Commit(tree(File(pF, zH)));
            b = Commit(tree(File(pF, zI)), a);
            c = Commit(tree(File(pF, zI)), a);
            d = Commit(tree(File(pA, zS), File(pF, zI)), c);
            Parse(d);

            e = Commit(d.Tree, d, b);
            f = Commit(tree(File(pA, zS), File(pE, zY), File(pF, zI)), e);
            Parse(f);

            g = Commit(tree(File(pE, zY), File(pF, zI)), b);
            h = Commit(f.Tree, g, f);
            i = Commit(tree(File(pA, zS), File(pE, zY), File(pF, zF)), h);

            byName = new Dictionary<RevCommit, string>();
            var fields = typeof(RevWalkPathFilter6012Test).GetFields(BindingFlags.NonPublic | BindingFlags.Instance)
                .Where(x => x.FieldType == typeof(RevCommit));

            foreach (FieldInfo z in fields)
            {
                byName.Add((RevCommit)z.GetValue(this), z.Name);
            }
        }
コード例 #21
0
ファイル: AbstractRevQueue.cs プロジェクト: ArildF/GitSharp
 public override void add(RevCommit c)
 {
     throw new InvalidOperationException();
 }
コード例 #22
0
ファイル: RefUpdateTest.cs プロジェクト: drothmaler/GitSharp
        public void testNoCacheObjectIdSubclass()
        {
            string newRef = "refs/heads/abc";
            RefUpdate ru = updateRef(newRef);
            RevCommit newid = new RevCommit(ru.NewObjectId)
            {
                // empty
            };

            ru.NewObjectId = newid;
            RefUpdate.RefUpdateResult update = ru.Update();
            Assert.AreEqual(RefUpdate.RefUpdateResult.New, update);
            Ref r = db.getAllRefs()[newRef];
            Assert.IsNotNull(r);
            Assert.AreEqual(newRef, r.Name);
            Assert.IsNotNull(r.ObjectId);
            Assert.AreNotSame(newid, r.ObjectId);
            Assert.AreSame(typeof(ObjectId), r.ObjectId.GetType());
            Assert.AreEqual(newid.Copy(), r.ObjectId);
        }
コード例 #23
0
ファイル: AbstractRevQueue.cs プロジェクト: ArildF/GitSharp
 /**
  * Add a commit to the queue.
  * <p>
  * This method always adds the commit, even if it is already in the queue or
  * previously was in the queue but has already been removed. To control
  * queue admission use {@link #add(RevCommit, RevFlag)}.
  *
  * @param c
  *            commit to add.
  */
 public abstract void add(RevCommit c);
コード例 #24
0
ファイル: RefUpdateTest.cs プロジェクト: drothmaler/GitSharp
 public void testNewNamespaceConflictWithPackedPrefixOfExisting()
 {
     string newRef = "refs/heads/prefix";
     RefUpdate ru = updateRef(newRef);
     RevCommit newid = new RevCommit(ru.NewObjectId)
     {
         // empty
     };
     ru.NewObjectId = newid;
     RefUpdate.RefUpdateResult update = ru.Update();
     Assert.AreEqual(RefUpdate.RefUpdateResult.LockFailure, update);
 }
コード例 #25
0
ファイル: BundleWriter.cs プロジェクト: mneedham/GitSharp
 public void assume(RevCommit c)
 {
     if (c != null)
         assumeCommits.Add(c);
 }
コード例 #26
0
ファイル: UploadPack.cs プロジェクト: HackerBaloo/GitSharp
        private bool WantSatisfied(RevCommit want)
        {
            _walk.resetRetain(SAVE);
            _walk.markStart(want);

            while (true)
            {
                RevCommit c = _walk.next();
                if (c == null) break;
                if (c.has(PEER_HAS))
                {
                    AddCommonBase(c);
                    return true;
                }
            }
            return false;
        }
コード例 #27
0
 private void PushLocalCommit(RevCommit p)
 {
     if (p.has(LOCALLY_SEEN)) return;
     _revWalk.parseHeaders(p);
     p.add(LOCALLY_SEEN);
     p.add(COMPLETE);
     p.carry(COMPLETE);
     p.DisposeBody();
     _localCommitQueue.add(p);
 }
コード例 #28
0
 public override bool include(GitSharp.RevWalk.RevWalk walker, RevCommit cmit)
 {
     bool remoteKnowsIsCommon = cmit.has(COMMON);
     if (cmit.has(ADVERTISED))
     {
         cmit.add(COMMON);
     }
     return !remoteKnowsIsCommon;
 }
コード例 #29
0
ファイル: DateRevQueue.cs プロジェクト: HackerBaloo/GitSharp
 private Entry NewEntry(RevCommit c)
 {
     Entry r = _free;
     if (r == null)
     {
         r = new Entry();
     }
     else
     {
         _free = r.Next;
     }
     r.Commit = c;
     return r;
 }
コード例 #30
0
ファイル: FIFORevQueue.cs プロジェクト: ArildF/GitSharp
        /**
         * Insert the commit pointer at the front of the queue.
         *
         * @param c
         *            the commit to insert into the queue.
         */
        public void unpop(RevCommit c)
        {
            Block b = head;
            if (b == null)
            {
                b = free.newBlock();
                b.resetToMiddle();
                b.add(c);
                head = b;
                tail = b;
                return;
            }
            else if (b.canUnpop())
            {
                b.unpop(c);
                return;
            }

            b = free.newBlock();
            b.resetToEnd();
            b.unpop(c);
            b.next = head;
            head = b;
        }