/// <summary>Insert a single tree into the store, returning its unique name.</summary>
 /// <remarks>Insert a single tree into the store, returning its unique name.</remarks>
 /// <param name="formatter">the formatter containing the proposed tree's data.</param>
 /// <returns>the name of the tree object.</returns>
 /// <exception cref="System.IO.IOException">the object could not be stored.</exception>
 public ObjectId Insert(TreeFormatter formatter)
 {
     // Delegate to the formatter, as then it can pass the raw internal
     // buffer back to this inserter, avoiding unnecessary data copying.
     //
     return(formatter.InsertTo(this));
 }
Ejemplo n.º 2
0
        /// <summary>Format this Tree in canonical format.</summary>
        /// <remarks>Format this Tree in canonical format.</remarks>
        /// <returns>canonical encoding of the tree object.</returns>
        /// <exception cref="System.IO.IOException">the tree cannot be loaded, or its not in a writable state.
        ///     </exception>
        public virtual byte[] Format()
        {
            TreeFormatter fmt = new TreeFormatter();

            foreach (TreeEntry e in Members())
            {
                ObjectId id = e.GetId();
                if (id == null)
                {
                    throw new ObjectWritingException(MessageFormat.Format(JGitText.Get().objectAtPathDoesNotHaveId
                                                                          , e.GetFullName()));
                }
                fmt.Append(e.GetNameUTF8(), e.GetMode(), id);
            }
            return(fmt.ToByteArray());
        }
Ejemplo n.º 3
0
 /// <exception cref="System.IO.IOException"></exception>
 private ObjectId InsertTree(TreeFormatter tree)
 {
     ObjectInserter oi = db.NewObjectInserter();
     try
     {
         ObjectId id = oi.Insert(tree);
         oi.Flush();
         return id;
     }
     finally
     {
         oi.Release();
     }
 }
Ejemplo n.º 4
0
 public virtual void Test026_CreateCommitMultipleparents()
 {
     ObjectId treeId;
     ObjectInserter oi = db.NewObjectInserter();
     try
     {
         ObjectId blobId = oi.Insert(Constants.OBJ_BLOB, Sharpen.Runtime.GetBytesForString
             ("and this is the data in me\n", Constants.CHARSET.Name()));
         TreeFormatter fmt = new TreeFormatter();
         fmt.Append("i-am-a-file", FileMode.REGULAR_FILE, blobId);
         treeId = oi.Insert(fmt);
         oi.Flush();
     }
     finally
     {
         oi.Release();
     }
     NUnit.Framework.Assert.AreEqual(ObjectId.FromString("00b1f73724f493096d1ffa0b0f1f1482dbb8c936"
         ), treeId);
     NGit.CommitBuilder c1 = new NGit.CommitBuilder();
     c1.Author = new PersonIdent(author, 1154236443000L, -4 * 60);
     c1.Committer = new PersonIdent(committer, 1154236443000L, -4 * 60);
     c1.Message = "A Commit\n";
     c1.TreeId = treeId;
     NUnit.Framework.Assert.AreEqual(treeId, c1.TreeId);
     ObjectId actid1 = InsertCommit(c1);
     ObjectId cmtid1 = ObjectId.FromString("803aec4aba175e8ab1d666873c984c0308179099");
     NUnit.Framework.Assert.AreEqual(cmtid1, actid1);
     NGit.CommitBuilder c2 = new NGit.CommitBuilder();
     c2.Author = new PersonIdent(author, 1154236443000L, -4 * 60);
     c2.Committer = new PersonIdent(committer, 1154236443000L, -4 * 60);
     c2.Message = "A Commit 2\n";
     c2.TreeId = treeId;
     NUnit.Framework.Assert.AreEqual(treeId, c2.TreeId);
     c2.SetParentIds(actid1);
     ObjectId actid2 = InsertCommit(c2);
     ObjectId cmtid2 = ObjectId.FromString("95d068687c91c5c044fb8c77c5154d5247901553");
     NUnit.Framework.Assert.AreEqual(cmtid2, actid2);
     RevCommit rm2 = ParseCommit(cmtid2);
     NUnit.Framework.Assert.AreNotSame(c2, rm2);
     // assert the parsed objects is not from the
     // cache
     NUnit.Framework.Assert.AreEqual(c2.Author, rm2.GetAuthorIdent());
     NUnit.Framework.Assert.AreEqual(actid2, rm2.Id);
     NUnit.Framework.Assert.AreEqual(c2.Message, rm2.GetFullMessage());
     NUnit.Framework.Assert.AreEqual(c2.TreeId, rm2.Tree.Id);
     NUnit.Framework.Assert.AreEqual(1, rm2.ParentCount);
     NUnit.Framework.Assert.AreEqual(actid1, rm2.GetParent(0));
     NGit.CommitBuilder c3 = new NGit.CommitBuilder();
     c3.Author = new PersonIdent(author, 1154236443000L, -4 * 60);
     c3.Committer = new PersonIdent(committer, 1154236443000L, -4 * 60);
     c3.Message = "A Commit 3\n";
     c3.TreeId = treeId;
     NUnit.Framework.Assert.AreEqual(treeId, c3.TreeId);
     c3.SetParentIds(actid1, actid2);
     ObjectId actid3 = InsertCommit(c3);
     ObjectId cmtid3 = ObjectId.FromString("ce6e1ce48fbeeb15a83f628dc8dc2debefa066f4");
     NUnit.Framework.Assert.AreEqual(cmtid3, actid3);
     RevCommit rm3 = ParseCommit(cmtid3);
     NUnit.Framework.Assert.AreNotSame(c3, rm3);
     // assert the parsed objects is not from the
     // cache
     NUnit.Framework.Assert.AreEqual(c3.Author, rm3.GetAuthorIdent());
     NUnit.Framework.Assert.AreEqual(actid3, rm3.Id);
     NUnit.Framework.Assert.AreEqual(c3.Message, rm3.GetFullMessage());
     NUnit.Framework.Assert.AreEqual(c3.TreeId, rm3.Tree.Id);
     NUnit.Framework.Assert.AreEqual(2, rm3.ParentCount);
     NUnit.Framework.Assert.AreEqual(actid1, rm3.GetParent(0));
     NUnit.Framework.Assert.AreEqual(actid2, rm3.GetParent(1));
     NGit.CommitBuilder c4 = new NGit.CommitBuilder();
     c4.Author = new PersonIdent(author, 1154236443000L, -4 * 60);
     c4.Committer = new PersonIdent(committer, 1154236443000L, -4 * 60);
     c4.Message = "A Commit 4\n";
     c4.TreeId = treeId;
     NUnit.Framework.Assert.AreEqual(treeId, c3.TreeId);
     c4.SetParentIds(actid1, actid2, actid3);
     ObjectId actid4 = InsertCommit(c4);
     ObjectId cmtid4 = ObjectId.FromString("d1fca9fe3fef54e5212eb67902c8ed3e79736e27");
     NUnit.Framework.Assert.AreEqual(cmtid4, actid4);
     RevCommit rm4 = ParseCommit(cmtid4);
     NUnit.Framework.Assert.AreNotSame(c4, rm3);
     // assert the parsed objects is not from the
     // cache
     NUnit.Framework.Assert.AreEqual(c4.Author, rm4.GetAuthorIdent());
     NUnit.Framework.Assert.AreEqual(actid4, rm4.Id);
     NUnit.Framework.Assert.AreEqual(c4.Message, rm4.GetFullMessage());
     NUnit.Framework.Assert.AreEqual(c4.TreeId, rm4.Tree.Id);
     NUnit.Framework.Assert.AreEqual(3, rm4.ParentCount);
     NUnit.Framework.Assert.AreEqual(actid1, rm4.GetParent(0));
     NUnit.Framework.Assert.AreEqual(actid2, rm4.GetParent(1));
     NUnit.Framework.Assert.AreEqual(actid3, rm4.GetParent(2));
 }
Ejemplo n.º 5
0
 /// <summary>Insert a single tree into the store, returning its unique name.</summary>
 /// <remarks>Insert a single tree into the store, returning its unique name.</remarks>
 /// <param name="formatter">the formatter containing the proposed tree's data.</param>
 /// <returns>the name of the tree object.</returns>
 /// <exception cref="System.IO.IOException">the object could not be stored.</exception>
 public ObjectId Insert(TreeFormatter formatter)
 {
     // Delegate to the formatter, as then it can pass the raw internal
     // buffer back to this inserter, avoiding unnecessary data copying.
     //
     return formatter.InsertTo(this);
 }
Ejemplo n.º 6
0
 /// <summary>Compute the ObjectId for the given tree without inserting it.</summary>
 /// <remarks>Compute the ObjectId for the given tree without inserting it.</remarks>
 /// <param name="formatter"></param>
 /// <returns>the computed ObjectId</returns>
 public virtual ObjectId IdFor(TreeFormatter formatter)
 {
     return formatter.ComputeId(this);
 }
Ejemplo n.º 7
0
		internal virtual void Format(TreeFormatter fmt)
		{
			fmt.Append(name, mode, this);
		}
Ejemplo n.º 8
0
		/// <summary>Format this Tree in canonical format.</summary>
		/// <remarks>Format this Tree in canonical format.</remarks>
		/// <returns>canonical encoding of the tree object.</returns>
		/// <exception cref="System.IO.IOException">the tree cannot be loaded, or its not in a writable state.
		/// 	</exception>
		public virtual byte[] Format()
		{
			TreeFormatter fmt = new TreeFormatter();
			foreach (TreeEntry e in Members())
			{
				ObjectId id = e.GetId();
				if (id == null)
				{
					throw new ObjectWritingException(MessageFormat.Format(JGitText.Get().objectAtPathDoesNotHaveId
						, e.GetFullName()));
				}
				fmt.Append(e.GetNameUTF8(), e.GetMode(), id);
			}
			return fmt.ToByteArray();
		}
 /// <summary>Compute the ObjectId for the given tree without inserting it.</summary>
 /// <remarks>Compute the ObjectId for the given tree without inserting it.</remarks>
 /// <param name="formatter"></param>
 /// <returns>the computed ObjectId</returns>
 public virtual ObjectId IdFor(TreeFormatter formatter)
 {
     return(formatter.ComputeId(this));
 }
 public override ObjectId IdFor(TreeFormatter formatter)
 {
     return(Delegate().IdFor(formatter));
 }
Ejemplo n.º 11
0
			public override ObjectId IdFor(TreeFormatter formatter)
			{
				return Delegate().IdFor(formatter);
			}