コード例 #1
0
        /// <summary>Apply a flag to all commits matching the specified filter.</summary>
        /// <remarks>
        /// Apply a flag to all commits matching the specified filter.
        /// <p>
        /// This version allows incremental testing and application, such as from a
        /// background thread that needs to periodically halt processing and send
        /// updates to the UI.
        /// </remarks>
        /// <param name="matching">
        /// the filter to test commits with. If the filter includes a
        /// commit it will have the flag set; if the filter does not
        /// include the commit the flag will be unset.
        /// </param>
        /// <param name="flag">
        /// the flag to apply (or remove). Applications are responsible
        /// for allocating this flag from the source RevWalk.
        /// </param>
        /// <param name="rangeBegin">
        /// first commit within the list to begin testing at, inclusive.
        /// Must not be negative, but may be beyond the end of the list.
        /// </param>
        /// <param name="rangeEnd">
        /// last commit within the list to end testing at, exclusive. If
        /// smaller than or equal to <code>rangeBegin</code> then no
        /// commits will be tested.
        /// </param>
        /// <exception cref="System.IO.IOException">
        /// revision filter needed to read additional objects, but an
        /// error occurred while reading the pack files or loose objects
        /// of the repository.
        /// </exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException">
        /// revision filter needed to read additional objects, but an
        /// object was not of the correct type. Repository corruption may
        /// have occurred.
        /// </exception>
        /// <exception cref="NGit.Errors.MissingObjectException">
        /// revision filter needed to read additional objects, but an
        /// object that should be present was not found. Repository
        /// corruption may have occurred.
        /// </exception>
        public virtual void ApplyFlag(RevFilter matching, RevFlag flag, int rangeBegin, int
                                      rangeEnd)
        {
            RevWalk w = flag.GetRevWalk();

            rangeEnd = Math.Min(rangeEnd, Count);
            while (rangeBegin < rangeEnd)
            {
                int index            = rangeBegin;
                RevObjectListBlock s = contents;
                while (s.shift > 0)
                {
                    int i = index >> s.shift;
                    index -= i << s.shift;
                    s      = (RevObjectListBlock)s.contents[i];
                }
                while (rangeBegin++ < rangeEnd && index < BLOCK_SIZE)
                {
                    RevCommit c = (RevCommit)s.contents[index++];
                    if (matching.Include(w, c))
                    {
                        c.Add(flag);
                    }
                    else
                    {
                        c.Remove(flag);
                    }
                }
            }
        }
コード例 #2
0
ファイル: RevObjectTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestRemoveRevFlag()
        {
            RevCommit a     = Commit();
            RevFlag   flag1 = rw.NewFlag("flag1");
            RevFlag   flag2 = rw.NewFlag("flag2");

            a.Add(flag1);
            a.Add(flag2);
            NUnit.Framework.Assert.AreEqual(flag1.mask | flag2.mask, a.flags);
            a.Remove(flag2);
            NUnit.Framework.Assert.AreEqual(flag1.mask, a.flags);
        }