Esempio n. 1
0
        /// <summary>
        /// Apply a flag to all commits matching the specified filter.
        ///
        /// 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.
        /// </summary>
        /// <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>
        /// <remarks>
        /// Revision filter needed to Read additional objects, but an
        /// error occurred while reading the pack files or loose objects
        /// of the repository.
        /// </remarks>
        public void applyFlag(RevFilter matching, RevFlag flag, int rangeBegin, int rangeEnd)
        {
            RevWalk w = flag.Walker;

            rangeEnd = Math.Min(rangeEnd, Size);
            while (rangeBegin < rangeEnd)
            {
                int   index = rangeBegin;
                Block s     = Contents;

                while (s.Shift > 0)
                {
                    int i = index >> s.Shift;
                    index -= i << s.Shift;
                    s      = (Block)s.Contents[i];
                }

                while (rangeBegin++ < rangeEnd && index < BLOCK_SIZE)
                {
                    var c = (RevCommit)s.Contents[index++];

                    if (matching.include(w, c))
                    {
                        c.add(flag);
                    }
                    else
                    {
                        c.remove(flag);
                    }
                }
            }
        }
Esempio n. 2
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);
                    }
                }
            }
        }
Esempio n. 3
0
 public PendingGenerator(RevWalk w, DateRevQueue p, RevFilter f, GeneratorOutputType outputType)
 {
     _walker     = w;
     _pending    = p;
     _filter     = f;
     _outputType = outputType;
     CanDispose  = true;
 }
Esempio n. 4
0
 internal PendingGenerator(RevWalk w, DateRevQueue p, RevFilter f, int @out)
 {
     walker     = w;
     pending    = p;
     filter     = f;
     output     = @out;
     canDispose = true;
 }
Esempio n. 5
0
        public virtual void TestCommitTimeRevFilter()
        {
            RevCommit a = Commit();

            Tick(100);
            RevCommit b = Commit(a);

            Tick(100);
            DateTime  since = GetClock();
            RevCommit c1    = Commit(b);

            Tick(100);
            RevCommit c2 = Commit(b);

            Tick(100);
            DateTime  until = GetClock();
            RevCommit d     = Commit(c1, c2);

            Tick(100);
            RevCommit e = Commit(d);
            {
                RevFilter after = CommitTimeRevFilter.After(since);
                NUnit.Framework.Assert.IsNotNull(after);
                rw.SetRevFilter(after);
                MarkStart(e);
                AssertCommit(e, rw.Next());
                AssertCommit(d, rw.Next());
                AssertCommit(c2, rw.Next());
                AssertCommit(c1, rw.Next());
                NUnit.Framework.Assert.IsNull(rw.Next());
            }
            {
                RevFilter before = CommitTimeRevFilter.Before(until);
                NUnit.Framework.Assert.IsNotNull(before);
                rw.Reset();
                rw.SetRevFilter(before);
                MarkStart(e);
                AssertCommit(c2, rw.Next());
                AssertCommit(c1, rw.Next());
                AssertCommit(b, rw.Next());
                AssertCommit(a, rw.Next());
                NUnit.Framework.Assert.IsNull(rw.Next());
            }
            {
                RevFilter between = CommitTimeRevFilter.Between(since, until);
                NUnit.Framework.Assert.IsNotNull(between);
                rw.Reset();
                rw.SetRevFilter(between);
                MarkStart(e);
                AssertCommit(c2, rw.Next());
                AssertCommit(c1, rw.Next());
                NUnit.Framework.Assert.IsNull(rw.Next());
            }
        }
        public RevisionInfo[] GetRevisions(RevisionId fromChangeset, RevisionId toChangeset)
        {
            var revWalk = CreateRevWalker();

            try
            {
                RevFilter betweenFilter = CommitTimeRevFilter.Between(((GitRevisionId)fromChangeset).Time,
                                                                      ((GitRevisionId)toChangeset).Time);

                revWalk.SetRevFilter(ApplyNoMergesFilter(betweenFilter));
                var commits = revWalk.ToArray();
                return(commits.Select(commit => commit.ConvertToRevisionInfo(_git.GetRepository())).ToArray());
            }
            finally
            {
                revWalk.Dispose();
            }
        }
 private static RevFilter ApplyNoMergesFilter(RevFilter filter)
 {
     return(AndRevFilter.Create(new[] { RevFilter.NO_MERGES, filter }));
 }
Esempio n. 8
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>
 /// Same as <code>applyFlag(matching, flag, 0, size())</code>, but without
 /// the incremental behavior.
 /// </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>
 /// <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)
 {
     ApplyFlag(matching, flag, 0, Count);
 }
Esempio n. 9
0
 private NotRevFilter(RevFilter one)
 {
     _a = one;
 }
Esempio n. 10
0
 ///	<summary>
 /// Create a filter that negates the result of another filter.
 ///	</summary>
 ///	<param name="a">Filter to negate.</param>
 ///	<returns>
 /// A filter that does the reverse of <code>a</code>.
 /// </returns>
 public static RevFilter create(RevFilter a)
 {
     return(new NotRevFilter(a));
 }
Esempio n. 11
0
		private NotRevFilter(RevFilter one)
		{
			_a = one;
		}
Esempio n. 12
0
		///	<summary>
		/// Create a filter that negates the result of another filter.
		///	</summary>
		///	<param name="a">Filter to negate.</param>
		///	<returns>
		/// A filter that does the reverse of <code>a</code>.
		/// </returns>
		public static RevFilter create(RevFilter a)
		{
			return new NotRevFilter(a);
		}
Esempio n. 13
0
        public override RevCommit next()
        {
            RevWalk          w  = _walker;
            RevFilter        rf = w.getRevFilter();
            TreeFilter       tf = w.getTreeFilter();
            AbstractRevQueue q  = _walker.Queue;

            if (rf == RevFilter.MERGE_BASE)
            {
                // Computing for merge bases is a special case and does not
                // use the bulk of the generator pipeline.
                //
                if (tf != TreeFilter.ALL)
                {
                    throw new InvalidOperationException("Cannot combine TreeFilter " + tf + " with RevFilter " + rf + ".");
                }

                var mbg = new MergeBaseGenerator(w);
                _walker.Pending = mbg;
                _walker.Queue   = AbstractRevQueue.EmptyQueue;
                mbg.init(q);
                return(mbg.next());
            }

            bool uninteresting = q.anybodyHasFlag(RevWalk.UNINTERESTING);
            bool boundary      = _walker.hasRevSort(RevSort.BOUNDARY);

            if (!boundary && _walker is ObjectWalk)
            {
                // The object walker requires boundary support to color
                // trees and blobs at the boundary uninteresting so it
                // does not produce those in the result.
                //
                boundary = true;
            }

            if (boundary && !uninteresting)
            {
                // If we were not fed uninteresting commits we will never
                // construct a boundary. There is no reason to include the
                // extra overhead associated with that in our pipeline.
                //
                boundary = false;
            }

            DateRevQueue        pending           = (q as DateRevQueue);
            GeneratorOutputType pendingOutputType = 0;

            if (pending == null)
            {
                pending = new DateRevQueue(q);
            }

            if (tf != TreeFilter.ALL)
            {
                rf = AndRevFilter.create(rf, new RewriteTreeFilter(w, tf));
                pendingOutputType |= GeneratorOutputType.HasRewrite | GeneratorOutputType.NeedsRewrite;
            }

            _walker.Queue = q;
            Generator g = new PendingGenerator(w, pending, rf, pendingOutputType);

            if (boundary)
            {
                // Because the boundary generator may produce uninteresting
                // commits we cannot allow the pending generator to dispose
                // of them early.
                //
                ((PendingGenerator)g).CanDispose = false;
            }

            if ((g.OutputType & GeneratorOutputType.NeedsRewrite) != GeneratorOutputType.None)
            {
                // Correction for an upstream NEEDS_REWRITE is to buffer
                // fully and then Apply a rewrite generator that can
                // pull through the rewrite chain and produce a dense
                // output graph.
                //
                g = new FIFORevQueue(g);
                g = new RewriteGenerator(g);
            }

            if (_walker.hasRevSort(RevSort.TOPO) && (g.OutputType & GeneratorOutputType.SortTopo) == 0)
            {
                g = new TopoSortGenerator(g);
            }

            if (_walker.hasRevSort(RevSort.REVERSE))
            {
                g = new LIFORevQueue(g);
            }

            if (boundary)
            {
                g = new BoundaryGenerator(w, g);
            }
            else if (uninteresting)
            {
                // Try to protect ourselves from uninteresting commits producing
                // due to clock skew in the commit time stamps. Delay such that
                // we have a chance at coloring enough of the graph correctly,
                // and then strip any UNINTERESTING nodes that may have leaked
                // through early.
                //
                if (pending.peek() != null)
                {
                    g = new DelayRevQueue(g);
                }
                g = new FixUninterestingGenerator(g);
            }

            w.Pending = g;
            return(g.next());
        }
Esempio n. 14
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        internal override RevCommit Next()
        {
            Generator        g;
            RevWalk          w  = walker;
            RevFilter        rf = w.GetRevFilter();
            TreeFilter       tf = w.GetTreeFilter();
            AbstractRevQueue q  = walker.queue;

            w.reader.WalkAdviceBeginCommits(w, w.roots);
            if (rf == RevFilter.MERGE_BASE)
            {
                // Computing for merge bases is a special case and does not
                // use the bulk of the generator pipeline.
                //
                if (tf != TreeFilter.ALL)
                {
                    throw new InvalidOperationException(MessageFormat.Format(JGitText.Get().cannotCombineTreeFilterWithRevFilter
                                                                             , tf, rf));
                }
                MergeBaseGenerator mbg = new MergeBaseGenerator(w);
                walker.pending = mbg;
                walker.queue   = AbstractRevQueue.EMPTY_QUEUE;
                mbg.Init(q);
                return(mbg.Next());
            }
            bool uninteresting = q.AnybodyHasFlag(RevWalk.UNINTERESTING);
            bool boundary      = walker.HasRevSort(RevSort.BOUNDARY);

            if (!boundary && walker is ObjectWalk)
            {
                // The object walker requires boundary support to color
                // trees and blobs at the boundary uninteresting so it
                // does not produce those in the result.
                //
                boundary = true;
            }
            if (boundary && !uninteresting)
            {
                // If we were not fed uninteresting commits we will never
                // construct a boundary. There is no reason to include the
                // extra overhead associated with that in our pipeline.
                //
                boundary = false;
            }
            DateRevQueue pending;
            int          pendingOutputType = 0;

            if (q is DateRevQueue)
            {
                pending = (DateRevQueue)q;
            }
            else
            {
                pending = new DateRevQueue(q);
            }
            if (tf != TreeFilter.ALL)
            {
                rf = AndRevFilter.Create(new RewriteTreeFilter(w, tf), rf);
                pendingOutputType |= HAS_REWRITE | NEEDS_REWRITE;
            }
            walker.queue = q;
            if (walker is DepthWalk)
            {
                DepthWalk dw = (DepthWalk)walker;
                g = new DepthGenerator(dw, pending);
            }
            else
            {
                g = new PendingGenerator(w, pending, rf, pendingOutputType);
                if (boundary)
                {
                    // Because the boundary generator may produce uninteresting
                    // commits we cannot allow the pending generator to dispose
                    // of them early.
                    //
                    ((PendingGenerator)g).canDispose = false;
                }
            }
            if ((g.OutputType() & NEEDS_REWRITE) != 0)
            {
                // Correction for an upstream NEEDS_REWRITE is to buffer
                // fully and then apply a rewrite generator that can
                // pull through the rewrite chain and produce a dense
                // output graph.
                //
                g = new FIFORevQueue(g);
                g = new RewriteGenerator(g);
            }
            if (walker.HasRevSort(RevSort.TOPO) && (g.OutputType() & SORT_TOPO) == 0)
            {
                g = new TopoSortGenerator(g);
            }
            if (walker.HasRevSort(RevSort.REVERSE))
            {
                g = new LIFORevQueue(g);
            }
            if (boundary)
            {
                g = new BoundaryGenerator(w, g);
            }
            else
            {
                if (uninteresting)
                {
                    // Try to protect ourselves from uninteresting commits producing
                    // due to clock skew in the commit time stamps. Delay such that
                    // we have a chance at coloring enough of the graph correctly,
                    // and then strip any UNINTERESTING nodes that may have leaked
                    // through early.
                    //
                    if (pending.Peek() != null)
                    {
                        g = new DelayRevQueue(g);
                    }
                    g = new FixUninterestingGenerator(g);
                }
            }
            w.pending = g;
            return(g.Next());
        }
Esempio n. 15
0
        public void testCommitTimeRevFilter()
        {
            RevCommit a = Commit();

            Tick(100);

            RevCommit b = Commit(a);

            Tick(100);

            DateTime  since = (nowTick).MillisToDateTime();
            RevCommit c1    = Commit(b);

            Tick(100);

            RevCommit c2 = Commit(b);

            Tick(100);

            DateTime  until = (nowTick).MillisToDateTime();
            RevCommit d     = Commit(c1, c2);

            Tick(100);

            RevCommit e = Commit(d);

            {
                RevFilter after = CommitTimeRevFilter.After(since);
                Assert.IsNotNull(after);
                rw.setRevFilter(after);
                MarkStart(e);
                AssertCommit(e, rw.next());
                AssertCommit(d, rw.next());
                AssertCommit(c2, rw.next());
                AssertCommit(c1, rw.next());
                Assert.IsNull(rw.next());
            }

            {
                RevFilter before = CommitTimeRevFilter.Before(until);
                Assert.IsNotNull(before);
                rw.reset();
                rw.setRevFilter(before);
                MarkStart(e);
                AssertCommit(c2, rw.next());
                AssertCommit(c1, rw.next());
                AssertCommit(b, rw.next());
                AssertCommit(a, rw.next());
                Assert.IsNull(rw.next());
            }

            {
                RevFilter between = CommitTimeRevFilter.Between(since, until);
                Assert.IsNotNull(between);
                rw.reset();
                rw.setRevFilter(between);
                MarkStart(e);
                AssertCommit(c2, rw.next());
                AssertCommit(c1, rw.next());
                Assert.IsNull(rw.next());
            }
        }
Esempio n. 16
0
 /// <summary>
 /// Apply a flag to all commits matching the specified filter.
 ///
 /// <code>applyFlag(matching, flag, 0, size())</code>, but without
 /// the incremental behavior.
 /// </summary>
 /// <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">
 /// revision filter needed to Read additional objects, but an
 /// error occurred while reading the pack files or loose objects
 /// of the repository.
 /// </param>
 public void applyFlag(RevFilter matching, RevFlag flag)
 {
     applyFlag(matching, flag, 0, Size);
 }