/// <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); } } } }
/// <summary>Add a commit if it does not have a flag set yet, then set the flag.</summary> /// <remarks> /// 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. /// </remarks> /// <param name="c">commit to add.</param> /// <param name="queueControl">flag that controls admission to the queue.</param> public void Add(RevCommit c, RevFlag queueControl) { if (!c.Has(queueControl)) { c.Add(queueControl); Add(c); } }
/// <summary>Carry a RevFlag set on this commit to its parents.</summary> /// <remarks> /// Carry a RevFlag set on this commit to its parents. /// <p> /// If this commit is parsed, has parents, and has the supplied flag set on /// it we automatically add it to the parents, grand-parents, and so on until /// an unparsed commit or a commit with no parents is discovered. This /// permits applications to force a flag through the history chain when /// necessary. /// </remarks> /// <param name="flag">the single flag value to carry back onto parents.</param> public virtual void Carry(RevFlag flag) { int carry = flags & flag.mask; if (carry != 0) { CarryFlags(this, carry); } }
/// <summary>Remove the given flag from all commits.</summary> /// <remarks> /// Remove the given flag from all commits. /// <p> /// This method is actually implemented in terms of: /// <code>applyFlag(RevFilter.NONE, flag, rangeBegin, rangeEnd)</code>. /// </remarks> /// <param name="flag"> /// the flag to 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> public virtual void ClearFlag(RevFlag flag, int rangeBegin, int rangeEnd) { try { ApplyFlag(RevFilter.NONE, flag, rangeBegin, rangeEnd); } catch (IOException) { } }
public virtual void TestContains() { RevFlag flag1 = rw.NewFlag("flag_1"); RevFlag flag2 = rw.NewFlag("flag_2"); RevFlagSet set = new RevFlagSet(); set.AddItem(flag1); NUnit.Framework.Assert.IsTrue(set.Contains(flag1)); NUnit.Framework.Assert.IsFalse(set.Contains(flag2)); NUnit.Framework.Assert.IsFalse(set.Contains("bob")); }
public virtual void TestEquals() { RevFlag flag1 = rw.NewFlag("flag_1"); RevFlag flag2 = rw.NewFlag("flag_2"); RevFlagSet set = new RevFlagSet(); NUnit.Framework.Assert.IsTrue(set.AddItem(flag1)); NUnit.Framework.Assert.IsTrue(set.AddItem(flag2)); NUnit.Framework.Assert.IsTrue(new RevFlagSet(set).Equals(set)); NUnit.Framework.Assert.IsTrue(new RevFlagSet(Arrays.AsList(new RevFlag[] { flag1, flag2 })).Equals(set)); }
/// <summary>Add a commit's parents if one does not have a flag set yet.</summary> /// <remarks> /// 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. /// </remarks> /// <param name="c">commit whose parents should be added.</param> /// <param name="queueControl">flag that controls admission to the queue.</param> public void AddParents(RevCommit c, RevFlag queueControl) { RevCommit[] pList = c.parents; if (pList == null) { return; } foreach (RevCommit p in pList) { Add(p, queueControl); } }
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); }
public virtual void TestRemove() { RevFlag flag1 = rw.NewFlag("flag_1"); RevFlag flag2 = rw.NewFlag("flag_2"); RevFlagSet set = new RevFlagSet(); NUnit.Framework.Assert.IsTrue(set.AddItem(flag1)); NUnit.Framework.Assert.IsTrue(set.AddItem(flag2)); NUnit.Framework.Assert.IsTrue(set.Remove(flag1)); NUnit.Framework.Assert.IsFalse(set.Remove(flag1)); NUnit.Framework.Assert.AreEqual(flag2.mask, set.mask); NUnit.Framework.Assert.IsFalse(set.Contains(flag1)); }
public virtual void TestAddTwo() { RevFlag flag1 = rw.NewFlag("flag_1"); RevFlag flag2 = rw.NewFlag("flag_2"); NUnit.Framework.Assert.IsTrue((flag1.mask & flag2.mask) == 0); RevFlagSet set = new RevFlagSet(); NUnit.Framework.Assert.IsTrue(set.AddItem(flag1)); NUnit.Framework.Assert.IsTrue(set.AddItem(flag2)); NUnit.Framework.Assert.AreEqual(flag1.mask | flag2.mask, set.mask); NUnit.Framework.Assert.AreEqual(2, set.Count); }
public virtual void TestAddRevFlagSet() { RevCommit a = Commit(); RevFlag flag1 = rw.NewFlag("flag1"); RevFlag flag2 = rw.NewFlag("flag2"); RevFlagSet s = new RevFlagSet(); s.AddItem(flag1); s.AddItem(flag2); NUnit.Framework.Assert.AreEqual(0, a.flags); a.Add(s); NUnit.Framework.Assert.AreEqual(flag1.mask | flag2.mask, a.flags); }
public virtual void TestHasAnyFlag() { RevCommit a = Commit(); RevFlag flag1 = rw.NewFlag("flag1"); RevFlag flag2 = rw.NewFlag("flag2"); RevFlagSet s = new RevFlagSet(); s.AddItem(flag1); s.AddItem(flag2); NUnit.Framework.Assert.IsFalse(a.HasAny(s)); a.flags |= flag1.mask; NUnit.Framework.Assert.IsTrue(a.HasAny(s)); }
public virtual void TestContainsAll() { RevFlag flag1 = rw.NewFlag("flag_1"); RevFlag flag2 = rw.NewFlag("flag_2"); RevFlagSet set1 = new RevFlagSet(); NUnit.Framework.Assert.IsTrue(set1.AddItem(flag1)); NUnit.Framework.Assert.IsTrue(set1.AddItem(flag2)); NUnit.Framework.Assert.IsTrue(set1.ContainsAll(set1)); NUnit.Framework.Assert.IsTrue(set1.ContainsAll(Arrays.AsList(new RevFlag[] { flag1 , flag2 }))); RevFlagSet set2 = new RevFlagSet(); set2.AddItem(rw.NewFlag("flag_3")); NUnit.Framework.Assert.IsFalse(set1.ContainsAll(set2)); }
public virtual void TestAddOne() { string flagName = "flag"; RevFlag flag = rw.NewFlag(flagName); NUnit.Framework.Assert.IsTrue(0 != flag.mask); NUnit.Framework.Assert.AreSame(flagName, flag.name); RevFlagSet set = new RevFlagSet(); NUnit.Framework.Assert.IsTrue(set.AddItem(flag)); NUnit.Framework.Assert.IsFalse(set.AddItem(flag)); NUnit.Framework.Assert.AreEqual(flag.mask, set.mask); NUnit.Framework.Assert.AreEqual(1, set.Count); Iterator <RevFlag> i = set.Iterator(); NUnit.Framework.Assert.IsTrue(i.HasNext()); NUnit.Framework.Assert.AreSame(flag, i.Next()); NUnit.Framework.Assert.IsFalse(i.HasNext()); }
// 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); }
/// <param name="w"></param> /// <param name="s">Parent generator</param> /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException /// </exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException /// </exception> /// <exception cref="System.IO.IOException">System.IO.IOException</exception> internal DepthGenerator(DepthWalk w, Generator s) { pending = new FIFORevQueue(); walk = (RevWalk)w; this.depth = w.GetDepth(); this.UNSHALLOW = w.GetUnshallowFlag(); this.REINTERESTING = w.GetReinterestingFlag(); s.ShareFreeList(pending); // Begin by sucking out all of the source's commits, and // adding them to the pending queue for (; ;) { RevCommit c = s.Next(); if (c == null) { break; } if (((NGit.Revwalk.Depthwalk.Commit)c).GetDepth() == 0) { pending.Add(c); } } }
/// <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); }
/// <summary>Add a commit's parents if one does not have a flag set yet.</summary> /// <remarks> /// 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. /// </remarks> /// <param name="c">commit whose parents should be added.</param> /// <param name="queueControl">flag that controls admission to the queue.</param> public void AddParents(RevCommit c, RevFlag queueControl) { RevCommit[] pList = c.parents; if (pList == null) { return; } foreach (RevCommit p in pList) { Add(p, queueControl); } }
/// <summary>Remove the given flag from all commits.</summary> /// <remarks> /// Remove the given flag from all commits. /// <p> /// Same as <code>clearFlag(flag, 0, size())</code>, but without the /// incremental behavior. /// </remarks> /// <param name="flag"> /// the flag to remove. Applications are responsible for /// allocating this flag from the source RevWalk. /// </param> public virtual void ClearFlag(RevFlag flag) { ClearFlag(flag, 0, Count); }
/// <summary>Initialize a new advertisement formatter.</summary> /// <remarks>Initialize a new advertisement formatter.</remarks> /// <param name="protoWalk">the RevWalk used to parse objects that are advertised.</param> /// <param name="advertisedFlag"> /// flag marked on any advertised objects parsed out of the /// <code>protoWalk</code> /// 's object pool, permitting the caller to /// later quickly determine if an object was advertised (or not). /// </param> public virtual void Init(RevWalk protoWalk, RevFlag advertisedFlag) { walk = protoWalk; ADVERTISED = advertisedFlag; }
/// <summary>Create a new filter that tests for a single flag.</summary> /// <remarks>Create a new filter that tests for a single flag.</remarks> /// <param name="a">the flag to test.</param> /// <returns>filter that selects only commits with flag <code>a</code>.</returns> public static RevFilter Has(RevFlag a) { RevFlagSet s = new RevFlagSet(); s.AddItem(a); return new RevFlagFilter.HasAll(s); }
internal override void Add(RevFlag flag) { }
/// <summary>Test to see if the flag has been set on this object.</summary> /// <remarks>Test to see if the flag has been set on this object.</remarks> /// <param name="flag">the flag to test.</param> /// <returns>true if the flag has been added to this object; false if not.</returns> public bool Has(RevFlag flag) { return (flags & flag.mask) != 0; }
/// <summary>Remove a flag from this object.</summary> /// <remarks> /// Remove a flag from this object. /// <p> /// If the flag is not set on this object then the method has no effect. /// </remarks> /// <param name="flag">the flag to remove from this object.</param> public void Remove(RevFlag flag) { flags &= ~flag.mask; }
/// <summary>Add a flag to this object.</summary> /// <remarks> /// Add a flag to this object. /// <p> /// If the flag is already set on this object then the method has no effect. /// </remarks> /// <param name="flag">the flag to mark on this object, for later testing.</param> public void Add(RevFlag flag) { flags |= flag.mask; }
/// <param name="w"></param> /// <param name="s">Parent generator</param> /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException /// </exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException /// </exception> /// <exception cref="System.IO.IOException">System.IO.IOException</exception> internal DepthGenerator(DepthWalk w, Generator s) { pending = new FIFORevQueue(); walk = (RevWalk)w; this.depth = w.GetDepth(); this.UNSHALLOW = w.GetUnshallowFlag(); this.REINTERESTING = w.GetReinterestingFlag(); s.ShareFreeList(pending); // Begin by sucking out all of the source's commits, and // adding them to the pending queue for (; ; ) { RevCommit c = s.Next(); if (c == null) { break; } if (((NGit.Revwalk.Depthwalk.Commit)c).GetDepth() == 0) { pending.Add(c); } } }
internal WalkFetchConnection(WalkTransport t, WalkRemoteObjectDatabase w) { NGit.Transport.Transport wt = (NGit.Transport.Transport)t; local = wt.local; objCheck = wt.IsCheckFetchedObjects() ? new ObjectChecker() : null; inserter = local.NewObjectInserter(); reader = local.NewObjectReader(); remotes = new AList<WalkRemoteObjectDatabase>(); remotes.AddItem(w); unfetchedPacks = new List<WalkFetchConnection.RemotePack>(); packsConsidered = new HashSet<string>(); noPacksYet = new List<WalkRemoteObjectDatabase>(); noPacksYet.AddItem(w); noAlternatesYet = new List<WalkRemoteObjectDatabase>(); noAlternatesYet.AddItem(w); fetchErrors = new Dictionary<ObjectId, IList<Exception>>(); packLocks = new AList<PackLock>(4); revWalk = new RevWalk(reader); revWalk.SetRetainBody(false); treeWalk = new TreeWalk(reader); COMPLETE = revWalk.NewFlag("COMPLETE"); IN_WORK_QUEUE = revWalk.NewFlag("IN_WORK_QUEUE"); LOCALLY_SEEN = revWalk.NewFlag("LOCALLY_SEEN"); localCommitQueue = new DateRevQueue(); workQueue = new List<ObjectId>(); }
/// <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); }
/// <summary>Create a new pack upload for an open repository.</summary> /// <remarks>Create a new pack upload for an open repository.</remarks> /// <param name="copyFrom">the source repository.</param> public UploadPack(Repository copyFrom) { db = copyFrom; walk = new RevWalk(db); walk.SetRetainBody(false); WANT = walk.NewFlag("WANT"); PEER_HAS = walk.NewFlag("PEER_HAS"); COMMON = walk.NewFlag("COMMON"); SATISFIED = walk.NewFlag("SATISFIED"); walk.Carry(PEER_HAS); SAVE = new RevFlagSet(); SAVE.AddItem(WANT); SAVE.AddItem(PEER_HAS); SAVE.AddItem(COMMON); SAVE.AddItem(SATISFIED); }
internal virtual void Add(RevFlag flag) { sourceCommit.Add(flag); }
/// <param name="repo">Repository to walk</param> /// <param name="depth">Maximum depth to return</param> public ObjectWalk(Repository repo, int depth) : base(repo) { this.depth = depth; this.UNSHALLOW = NewFlag("UNSHALLOW"); this.REINTERESTING = NewFlag("REINTERESTING"); }
/// <param name="or">Object Reader</param> /// <param name="depth">Maximum depth to return</param> public ObjectWalk(ObjectReader or, int depth) : base(or) { this.depth = depth; this.UNSHALLOW = NewFlag("UNSHALLOW"); this.REINTERESTING = NewFlag("REINTERESTING"); }
/// <summary>Test to see if the flag has been set on this object.</summary> /// <remarks>Test to see if the flag has been set on this object.</remarks> /// <param name="flag">the flag to test.</param> /// <returns>true if the flag has been added to this object; false if not.</returns> public bool Has(RevFlag flag) { return((flags & flag.mask) != 0); }