public void testAddTwo() { RevFlag flag1 = rw.newFlag("flag_1"); RevFlag flag2 = rw.newFlag("flag_2"); Assert.IsTrue((flag1.Mask & flag2.Mask) == 0); var flagSet = new RevFlagSet(); Assert.IsTrue(flagSet.Add(flag1)); Assert.IsTrue(flagSet.Add(flag2)); Assert.AreEqual(flag1.Mask | flag2.Mask, flagSet.Mask); Assert.AreEqual(2, flagSet.Count); }
public void testEquals() { RevFlag flag1 = rw.newFlag("flag_1"); RevFlag flag2 = rw.newFlag("flag_2"); var flagSet = new RevFlagSet(); Assert.IsTrue(flagSet.Add(flag1)); Assert.IsTrue(flagSet.Add(flag2)); Assert.IsTrue(new RevFlagSet(flagSet).Equals(flagSet)); Assert.IsTrue(new RevFlagSet(new[] { flag1, flag2 }).Equals(flagSet)); }
public virtual void testRemove() { RevFlag flag1 = rw.newFlag("flag_1"); RevFlag flag2 = rw.newFlag("flag_2"); var flagSet = new RevFlagSet(); Assert.IsTrue(flagSet.Add(flag1)); Assert.IsTrue(flagSet.Add(flag2)); Assert.IsTrue(flagSet.Remove(flag1)); Assert.IsFalse(flagSet.Remove(flag1)); Assert.AreEqual(flag2.Mask, flagSet.Mask); Assert.IsFalse(flagSet.Contains(flag1)); }
/** * Create a new filter that tests all flags in a set. * * @param a * set of flags to test. * @return filter that selects only commits with all flags in <code>a</code>. */ public static RevFilter hasAll(params RevFlag[] a) { RevFlagSet set = new RevFlagSet(); foreach (RevFlag flag in a) set.Add(flag); return new HasAll(set); }
public void testAddOne() { const string flagName = "flag"; RevFlag flag = rw.newFlag(flagName); Assert.IsTrue(0 != flag.Mask); Assert.AreSame(flagName, flag.Name); var flagSet = new RevFlagSet(); Assert.IsTrue(flagSet.Add(flag)); Assert.IsFalse(flagSet.Add(flag)); Assert.AreEqual(flag.Mask, flagSet.Mask); Assert.AreEqual(1, flagSet.Count); var i = flagSet.GetEnumerator(); Assert.IsTrue(i.MoveNext()); Assert.AreSame(flag, i.Current); Assert.IsFalse(i.MoveNext()); }
public void testContainsAll() { RevFlag flag1 = rw.newFlag("flag_1"); RevFlag flag2 = rw.newFlag("flag_2"); var set1 = new RevFlagSet(); Assert.IsTrue(set1.Add(flag1)); Assert.IsTrue(set1.Add(flag2)); Assert.IsTrue(set1.ContainsAll(set1)); Assert.IsTrue(set1.ContainsAll(new[] { flag1, flag2 })); var set2 = new RevFlagSet { rw.newFlag("flag_3") }; Assert.IsFalse(set1.ContainsAll(set2)); }
/// <summary> /// Create a new filter that tests for any flag in a set. /// </summary> /// <param name="a">Set of flags to test. </param> /// <returns> /// Filter that selects only commits with any flag in <code>a</code>. /// </returns> public static RevFilter hasAny(params RevFlag[] a) { var set = new RevFlagSet(); foreach (RevFlag flag in a) { set.Add(flag); } return(new HasAny(set)); }
public UploadPack(Repository copyFrom) { db = copyFrom; walk = new RevWalk.RevWalk(db); ADVERTISED = walk.newFlag("ADVERTISED"); WANT = walk.newFlag("WANT"); PEER_HAS = walk.newFlag("PEER_HAS"); COMMON = walk.newFlag("COMMON"); walk.carry(PEER_HAS); SAVE = new RevFlagSet(); SAVE.Add(ADVERTISED); SAVE.Add(WANT); SAVE.Add(PEER_HAS); }
/** * Create a new filter that tests for a single flag. * * @param a * the flag to test. * @return filter that selects only commits with flag <code>a</code>. */ public static RevFilter has(RevFlag a) { RevFlagSet s = new RevFlagSet(); s.Add(a); return new HasAll(s); }
/// <summary> /// Create a new filter that tests for any flag in a set. /// </summary> /// <param name="a">Set of flags to test. </param> /// <returns> /// Filter that selects only commits with any flag in <code>a</code>. /// </returns> public static RevFilter hasAny(params RevFlag[] a) { var set = new RevFlagSet(); foreach (RevFlag flag in a) { set.Add(flag); } return new HasAny(set); }