示例#1
0
		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());
		}
示例#2
0
        /// <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));
        }
示例#3
0
 /// <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);
     refFilter = RefFilter.DEFAULT;
 }
示例#4
0
		/// <summary>Create a new filter that tests all flags in a set.</summary>
		/// <remarks>Create a new filter that tests all flags in a set.</remarks>
		/// <param name="a">set of flags to test.</param>
		/// <returns>filter that selects only commits with all flags in <code>a</code>.</returns>
		public static RevFilter HasAllFilter(params RevFlag[] a)
		{
			RevFlagSet set = new RevFlagSet();
			foreach (RevFlag flag in a)
			{
				set.AddItem(flag);
			}
			return new RevFlagFilter.HasAll(set);
		}
示例#5
0
        /// <summary>Create a new filter that tests for any flag in a set.</summary>
        /// <remarks>Create a new filter that tests for any flag in a set.</remarks>
        /// <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 HasAnyFilter(params RevFlag[] a)
        {
            RevFlagSet set = new RevFlagSet();

            foreach (RevFlag flag in a)
            {
                set.AddItem(flag);
            }
            return(new RevFlagFilter.HasAny(set));
        }
示例#6
0
		/// <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);
		}
示例#7
0
		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));
		}
示例#8
0
		public virtual void TestAddTwo()
		{
			RevFlag flag1 = rw.NewFlag("flag_1");
			RevFlag flag2 = rw.NewFlag("flag_2");
			NUnit.Framework.Assert.AreEqual(0, (flag1.mask & flag2.mask));
			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);
		}
示例#9
0
		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"));
		}
示例#10
0
		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));
		}
示例#11
0
		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.AreEqual(set, new RevFlagSet(set));
			NUnit.Framework.Assert.IsTrue(new RevFlagSet(Arrays.AsList(new RevFlag[] { flag1, 
				flag2 })).Equals(set));
		}
示例#12
0
		/// <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);
		}
示例#13
0
		public virtual void TestRemoveRevFlagSet()
		{
			RevCommit a = Commit();
			RevFlag flag1 = rw.NewFlag("flag1");
			RevFlag flag2 = rw.NewFlag("flag2");
			RevFlag flag3 = rw.NewFlag("flag3");
			RevFlagSet s = new RevFlagSet();
			s.AddItem(flag1);
			s.AddItem(flag2);
			a.Add(flag3);
			a.Add(s);
			NUnit.Framework.Assert.AreEqual(flag1.mask | flag2.mask | flag3.mask, a.flags);
			a.Remove(s);
			NUnit.Framework.Assert.AreEqual(flag3.mask, a.flags);
		}
示例#14
0
		public virtual void TestHasAllFlag()
		{
			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.HasAll(s));
			a.flags |= flag1.mask;
			NUnit.Framework.Assert.IsFalse(a.HasAll(s));
			a.flags |= flag2.mask;
			NUnit.Framework.Assert.IsTrue(a.HasAll(s));
		}