コード例 #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
ファイル: RevObjectList.cs プロジェクト: shoff/ngit
        public override E Set(int index, E element)
        {
            RevObjectListBlock s = contents;

            while (index >> s.shift >= BLOCK_SIZE)
            {
                s             = new RevObjectListBlock(s.shift + BLOCK_SHIFT);
                s.contents[0] = contents;
                contents      = s;
            }
            while (s.shift > 0)
            {
                int i = index >> s.shift;
                index -= i << s.shift;
                if (s.contents[i] == null)
                {
                    s.contents[i] = new RevObjectListBlock(s.shift - BLOCK_SHIFT);
                }
                s = (RevObjectListBlock)s.contents[i];
            }
            object old = s.contents[index];

            s.contents[index] = element;
            return((E)old);
        }
コード例 #3
0
        /// <summary>Ensures all commits until the given commit are loaded.</summary>
        /// <remarks>
        /// Ensures all commits until the given commit are loaded. The revision
        /// walker specified by
        /// <see cref="RevCommitList{E}.Source(RevWalk)">RevCommitList&lt;E&gt;.Source(RevWalk)
        ///     </see>
        /// is pumped until the
        /// specified commit is loaded. Callers can test the final size of the list
        /// by
        /// <see cref="RevObjectList{E}.Count()">RevObjectList&lt;E&gt;.Count()</see>
        /// to determine if the high water mark specified was met.
        /// <p/>
        /// </remarks>
        /// <param name="commitToLoad">
        /// commit the caller wants this list to contain when the fill
        /// operation is complete.
        /// </param>
        /// <param name="highMark">
        /// maximum number of commits the caller wants this list to
        /// contain when the fill operation is complete. If highMark is 0
        /// the walk is pumped until the specified commit or the end of
        /// the walk is reached.
        /// </param>
        /// <exception cref="System.IO.IOException">
        /// see
        /// <see cref="RevWalk.Next()">RevWalk.Next()</see>
        /// </exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException">
        /// see
        /// <see cref="RevWalk.Next()">RevWalk.Next()</see>
        /// </exception>
        /// <exception cref="NGit.Errors.MissingObjectException">
        /// see
        /// <see cref="RevWalk.Next()">RevWalk.Next()</see>
        /// </exception>
        public virtual void FillTo(RevCommit commitToLoad, int highMark)
        {
            if (walker == null || commitToLoad == null || (highMark > 0 && size > highMark))
            {
                return;
            }
            RevCommit c = walker.Next();

            if (c == null)
            {
                walker = null;
                return;
            }
            Enter(size, (E)c);
            AddItem((E)c);
            while ((highMark == 0 || size <= highMark) && !c.Equals(commitToLoad))
            {
                int index            = size;
                RevObjectListBlock s = contents;
                while (index >> s.shift >= BLOCK_SIZE)
                {
                    s             = new RevObjectListBlock(s.shift + BLOCK_SHIFT);
                    s.contents[0] = contents;
                    contents      = s;
                }
                while (s.shift > 0)
                {
                    int i = index >> s.shift;
                    index -= i << s.shift;
                    if (s.contents[i] == null)
                    {
                        s.contents[i] = new RevObjectListBlock(s.shift - BLOCK_SHIFT);
                    }
                    s = (RevObjectListBlock)s.contents[i];
                }
                object[] dst = s.contents;
                while ((highMark == 0 || size <= highMark) && index < BLOCK_SIZE && !c.Equals(commitToLoad
                                                                                              ))
                {
                    c = walker.Next();
                    if (c == null)
                    {
                        walker = null;
                        return;
                    }
                    Enter(size++, (E)c);
                    dst[index++] = c;
                }
            }
        }
コード例 #4
0
ファイル: RevObjectList.cs プロジェクト: shoff/ngit
        public override E Get(int index)
        {
            RevObjectListBlock s = contents;

            if (index >> s.shift >= 1024)
            {
                return(null);
            }
            while (s != null && s.shift > 0)
            {
                int i = index >> s.shift;
                index -= i << s.shift;
                s      = (RevObjectListBlock)s.contents[i];
            }
            return(s != null ? (E)s.contents[index] : null);
        }
コード例 #5
0
 // Never happen. The filter we use does not throw any
 // exceptions, for any reason.
 /// <summary>Find the next commit that has the given flag set.</summary>
 /// <remarks>Find the next commit that has the given flag set.</remarks>
 /// <param name="flag">the flag to test commits against.</param>
 /// <param name="begin">
 /// first commit index to test at. Applications may wish to begin
 /// at 0, to test the first commit in the list.
 /// </param>
 /// <returns>
 /// index of the first commit at or after index <code>begin</code>
 /// that has the specified flag set on it; -1 if no match is found.
 /// </returns>
 public virtual int IndexOf(RevFlag flag, int begin)
 {
     while (begin < Count)
     {
         int index            = begin;
         RevObjectListBlock s = contents;
         while (s.shift > 0)
         {
             int i = index >> s.shift;
             index -= i << s.shift;
             s      = (RevObjectListBlock)s.contents[i];
         }
         while (begin++ < Count && index < BLOCK_SIZE)
         {
             RevCommit c = (RevCommit)s.contents[index++];
             if (c.Has(flag))
             {
                 return(begin);
             }
         }
     }
     return(-1);
 }
コード例 #6
0
 /// <summary>Find the next commit that has the given flag set.</summary>
 /// <remarks>Find the next commit that has the given flag set.</remarks>
 /// <param name="flag">the flag to test commits against.</param>
 /// <param name="begin">
 /// first commit index to test at. Applications may wish to begin
 /// at <code>size()-1</code>, to test the last commit in the
 /// list.
 /// </param>
 /// <returns>
 /// index of the first commit at or before index <code>begin</code>
 /// that has the specified flag set on it; -1 if no match is found.
 /// </returns>
 public virtual int LastIndexOf(RevFlag flag, int begin)
 {
     begin = Math.Min(begin, Count - 1);
     while (begin >= 0)
     {
         int index            = begin;
         RevObjectListBlock s = contents;
         while (s.shift > 0)
         {
             int i = index >> s.shift;
             index -= i << s.shift;
             s      = (RevObjectListBlock)s.contents[i];
         }
         while (begin-- >= 0 && index >= 0)
         {
             RevCommit c = (RevCommit)s.contents[index--];
             if (c.Has(flag))
             {
                 return(begin);
             }
         }
     }
     return(-1);
 }
コード例 #7
0
ファイル: RevObjectList.cs プロジェクト: shoff/ngit
 public override void Clear()
 {
     contents = new RevObjectListBlock(0);
     size     = 0;
 }