public virtual void TestFilter_NONE_And_MY_ALL() { RevCommit a = Commit(); RevCommit b = Commit(a); RevCommit c = Commit(b); rw.SetRevFilter(AndRevFilter.Create(RevFilter.NONE, MY_ALL)); MarkStart(c); NUnit.Framework.Assert.IsNull(rw.Next()); }
public void testFilter_NONE_And_MY_ALL() { RevCommit a = Commit(); RevCommit b = Commit(a); RevCommit c = Commit(b); rw.setRevFilter(AndRevFilter.create(RevFilter.NONE, MY_ALL)); MarkStart(c); Assert.IsNull(rw.next()); }
/// <summary> /// Executes the /// <code>Log</code> /// command with all the options and parameters /// collected by the setter methods (e.g. /// <see cref="Add(NGit.AnyObjectId)">Add(NGit.AnyObjectId)</see> /// , /// <see cref="Not(NGit.AnyObjectId)">Not(NGit.AnyObjectId)</see> /// , ..) of this class. Each instance of this class /// should only be used for one invocation of the command. Don't call this /// method twice on an instance. /// </summary> /// <returns>an iteration over RevCommits</returns> /// <exception cref="NGit.Api.Errors.NoHeadException">of the references ref cannot be resolved /// </exception> /// <exception cref="NGit.Api.Errors.GitAPIException"></exception> public override Iterable <RevCommit> Call() { CheckCallable(); if (pathFilters.Count > 0) { walk.SetTreeFilter(AndTreeFilter.Create(PathFilterGroup.Create(pathFilters), TreeFilter .ANY_DIFF)); } if (skip > -1 && maxCount > -1) { walk.SetRevFilter(AndRevFilter.Create(SkipRevFilter.Create(skip), MaxCountRevFilter .Create(maxCount))); } else { if (skip > -1) { walk.SetRevFilter(SkipRevFilter.Create(skip)); } else { if (maxCount > -1) { walk.SetRevFilter(MaxCountRevFilter.Create(maxCount)); } } } if (!startSpecified) { try { ObjectId headId = repo.Resolve(Constants.HEAD); if (headId == null) { throw new NoHeadException(JGitText.Get().noHEADExistsAndNoExplicitStartingRevisionWasSpecified ); } Add(headId); } catch (IOException e) { // all exceptions thrown by add() shouldn't occur and represent // severe low-level exception which are therefore wrapped throw new JGitInternalException(JGitText.Get().anExceptionOccurredWhileTryingToAddTheIdOfHEAD , e); } } SetCallable(false); return(walk); }
private static RevFilter ApplyNoMergesFilter(RevFilter filter) { return(AndRevFilter.Create(new[] { RevFilter.NO_MERGES, filter })); }
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()); }
/// <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()); }