public virtual void TestLeaf()
        {
            Ref         a;
            SymbolicRef b;
            SymbolicRef c;
            SymbolicRef d;

            a = new ObjectIdRef.PeeledTag(RefStorage.PACKED, targetName, ID_A, ID_B);
            b = new SymbolicRef("B", a);
            c = new SymbolicRef("C", b);
            d = new SymbolicRef("D", c);
            NUnit.Framework.Assert.AreSame(c, d.GetTarget());
            NUnit.Framework.Assert.AreSame(b, c.GetTarget());
            NUnit.Framework.Assert.AreSame(a, b.GetTarget());
            NUnit.Framework.Assert.AreSame(a, d.GetLeaf());
            NUnit.Framework.Assert.AreSame(a, c.GetLeaf());
            NUnit.Framework.Assert.AreSame(a, b.GetLeaf());
            NUnit.Framework.Assert.AreSame(a, a.GetLeaf());
            NUnit.Framework.Assert.AreSame(ID_A, d.GetObjectId());
            NUnit.Framework.Assert.AreSame(ID_A, c.GetObjectId());
            NUnit.Framework.Assert.AreSame(ID_A, b.GetObjectId());
            NUnit.Framework.Assert.IsTrue(d.IsPeeled());
            NUnit.Framework.Assert.IsTrue(c.IsPeeled());
            NUnit.Framework.Assert.IsTrue(b.IsPeeled());
            NUnit.Framework.Assert.AreSame(ID_B, d.GetPeeledObjectId());
            NUnit.Framework.Assert.AreSame(ID_B, c.GetPeeledObjectId());
            NUnit.Framework.Assert.AreSame(ID_B, b.GetPeeledObjectId());
        }
        public virtual void TestToString()
        {
            Ref         a;
            SymbolicRef b;
            SymbolicRef c;
            SymbolicRef d;

            a = new ObjectIdRef.PeeledTag(RefStorage.PACKED, targetName, ID_A, ID_B);
            b = new SymbolicRef("B", a);
            c = new SymbolicRef("C", b);
            d = new SymbolicRef("D", c);
            NUnit.Framework.Assert.AreEqual("SymbolicRef[D -> C -> B -> " + targetName + "="
                                            + ID_A.Name + "]", d.ToString());
        }
        public virtual void TestConstructor_Peeled()
        {
            ObjectIdRef r;

            r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, name, ID_A);
            NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, r.GetStorage());
            NUnit.Framework.Assert.AreSame(name, r.GetName());
            NUnit.Framework.Assert.AreSame(ID_A, r.GetObjectId());
            NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled");
            NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id");
            NUnit.Framework.Assert.AreSame(r, r.GetLeaf(), "leaf is this");
            NUnit.Framework.Assert.AreSame(r, r.GetTarget(), "target is this");
            NUnit.Framework.Assert.IsFalse(r.IsSymbolic(), "not symbolic");
            r = new ObjectIdRef.PeeledNonTag(RefStorage.LOOSE, name, ID_A);
            NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled");
            NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id");
            r = new ObjectIdRef.PeeledTag(RefStorage.LOOSE, name, ID_A, ID_B);
            NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled");
            NUnit.Framework.Assert.AreSame(ID_B, r.GetPeeledObjectId());
        }
		/// <exception cref="System.IO.IOException"></exception>
		private void ReadPackedRefsImpl(IDictionary<string, Ref> avail, BufferedReader br
			)
		{
			Ref last = null;
			bool peeled = false;
			for (; ; )
			{
				string line = br.ReadLine();
				if (line == null)
				{
					break;
				}
				if (line[0] == '#')
				{
					if (line.StartsWith(RefDirectory.PACKED_REFS_HEADER))
					{
						line = Sharpen.Runtime.Substring(line, RefDirectory.PACKED_REFS_HEADER.Length);
						peeled = line.Contains(RefDirectory.PACKED_REFS_PEELED);
					}
					continue;
				}
				if (line[0] == '^')
				{
					if (last == null)
					{
						throw new TransportException(JGitText.Get().peeledLineBeforeRef);
					}
					ObjectId id = ObjectId.FromString(Sharpen.Runtime.Substring(line, 1));
					last = new ObjectIdRef.PeeledTag(RefStorage.PACKED, last.GetName(), last.GetObjectId
						(), id);
					avail.Put(last.GetName(), last);
					continue;
				}
				int sp = line.IndexOf(' ');
				if (sp < 0)
				{
					throw new TransportException(MessageFormat.Format(JGitText.Get().unrecognizedRef, 
						line));
				}
				ObjectId id_1 = ObjectId.FromString(Sharpen.Runtime.Substring(line, 0, sp));
				string name = Sharpen.Runtime.Substring(line, sp + 1);
				if (peeled)
				{
					last = new ObjectIdRef.PeeledNonTag(RefStorage.PACKED, name, id_1);
				}
				else
				{
					last = new ObjectIdRef.Unpeeled(RefStorage.PACKED, name, id_1);
				}
				avail.Put(last.GetName(), last);
			}
		}
示例#5
0
		public virtual void TestConstructor_Peeled()
		{
			ObjectIdRef r;
			r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, name, ID_A);
			NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, r.GetStorage());
			NUnit.Framework.Assert.AreSame(name, r.GetName());
			NUnit.Framework.Assert.AreSame(ID_A, r.GetObjectId());
			NUnit.Framework.Assert.IsFalse(r.IsPeeled(), "not peeled");
			NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id");
			NUnit.Framework.Assert.AreSame(r, r.GetLeaf(), "leaf is this");
			NUnit.Framework.Assert.AreSame(r, r.GetTarget(), "target is this");
			NUnit.Framework.Assert.IsFalse(r.IsSymbolic(), "not symbolic");
			r = new ObjectIdRef.PeeledNonTag(RefStorage.LOOSE, name, ID_A);
			NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled");
			NUnit.Framework.Assert.IsNull(r.GetPeeledObjectId(), "no peel id");
			r = new ObjectIdRef.PeeledTag(RefStorage.LOOSE, name, ID_A, ID_B);
			NUnit.Framework.Assert.IsTrue(r.IsPeeled(), "is peeled");
			NUnit.Framework.Assert.AreSame(ID_B, r.GetPeeledObjectId());
		}
示例#6
0
		public virtual void TestLeaf()
		{
			Ref a;
			SymbolicRef b;
			SymbolicRef c;
			SymbolicRef d;
			a = new ObjectIdRef.PeeledTag(RefStorage.PACKED, targetName, ID_A, ID_B);
			b = new SymbolicRef("B", a);
			c = new SymbolicRef("C", b);
			d = new SymbolicRef("D", c);
			NUnit.Framework.Assert.AreSame(c, d.GetTarget());
			NUnit.Framework.Assert.AreSame(b, c.GetTarget());
			NUnit.Framework.Assert.AreSame(a, b.GetTarget());
			NUnit.Framework.Assert.AreSame(a, d.GetLeaf());
			NUnit.Framework.Assert.AreSame(a, c.GetLeaf());
			NUnit.Framework.Assert.AreSame(a, b.GetLeaf());
			NUnit.Framework.Assert.AreSame(a, a.GetLeaf());
			NUnit.Framework.Assert.AreSame(ID_A, d.GetObjectId());
			NUnit.Framework.Assert.AreSame(ID_A, c.GetObjectId());
			NUnit.Framework.Assert.AreSame(ID_A, b.GetObjectId());
			NUnit.Framework.Assert.IsTrue(d.IsPeeled());
			NUnit.Framework.Assert.IsTrue(c.IsPeeled());
			NUnit.Framework.Assert.IsTrue(b.IsPeeled());
			NUnit.Framework.Assert.AreSame(ID_B, d.GetPeeledObjectId());
			NUnit.Framework.Assert.AreSame(ID_B, c.GetPeeledObjectId());
			NUnit.Framework.Assert.AreSame(ID_B, b.GetPeeledObjectId());
		}
示例#7
0
		public virtual void TestToString()
		{
			Ref a;
			SymbolicRef b;
			SymbolicRef c;
			SymbolicRef d;
			a = new ObjectIdRef.PeeledTag(RefStorage.PACKED, targetName, ID_A, ID_B);
			b = new SymbolicRef("B", a);
			c = new SymbolicRef("C", b);
			d = new SymbolicRef("D", c);
			NUnit.Framework.Assert.AreEqual("SymbolicRef[D -> C -> B -> " + targetName + "=" 
				+ ID_A.Name + "]", d.ToString());
		}