当前位置: 首页>>代码示例>>C#>>正文


C# Tree.Accept方法代码示例

本文整理汇总了C#中GitSharp.Core.Tree.Accept方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.Accept方法的具体用法?C# Tree.Accept怎么用?C# Tree.Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GitSharp.Core.Tree的用法示例。


在下文中一共展示了Tree.Accept方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: test002_WriteEmptyTree

 public void test002_WriteEmptyTree()
 {
     // One of our test packs contains the empty tree object. If the pack is
     // open when we Create it we won't write the object file out as a loose
     // object (as it already exists in the pack).
     //
     Core.Repository newdb = createNewEmptyRepo();
     var t = new Tree(newdb);
     t.Accept(new WriteTree(trash, newdb), TreeEntry.MODIFIED_ONLY);
     Assert.AreEqual("4b825dc642cb6eb9a060e54bf8d69288fbee4904", t.Id.Name);
     var o = new FileInfo(newdb.Directory + "/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904");
     Assert.IsTrue(o.IsFile(), "Exists " + o);
     Assert.IsTrue(o.IsReadOnly, "Read-only " + o);
 }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:14,代码来源:T0003_Basic_Write.cs

示例2: Write_Simple_Commit

        public void Write_Simple_Commit()
        {
            var t = new Tree(db);
            FileTreeEntry f = t.AddFile("i-am-a-file");
            writeTrashFile(f.Name, "and this is the data in me\r\n\r\n");
            t.Accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
            //new ObjectChecker().checkBlob(Constants.CHARSET.GetString(db.OpenObject(t.TreeId).getBytes()).ToCharArray());

            string s = new Inspector(db).Inspect(t.Id);
            string s1 = Inspector.Inspect("Resources/single_file_commit", "16c0beaf7523eb3ef5df45bd42dd4fc6343de864");
            string s2 = Inspector.Inspect("Resources/single_file_commit", "917c130bd4fa5bf2df0c399dc1b03401860aa448");
            string s3 = Inspector.Inspect("Resources/single_file_commit", "95ea6a6859af6791464bd8b6de76ad5a6f9fad81");

            //tree 917c130bd4fa5bf2df0c399dc1b03401860aa448\nauthor henon <[email protected]> 1245946742 +0200\ncommitter henon <[email protected]> 1245946742 +0200\n\nA Commit\n"

            Assert.AreEqual(ObjectId.FromString("917c130bd4fa5bf2df0c399dc1b03401860aa448"), t.Id);

            var c = new Commit(db)
                        {
                            Author = (new PersonIdent("henon", "[email protected]", 1245946742000L, 2*60)),
                            Committer = (new PersonIdent("henon", "[email protected]", 1245946742000L, 2*60)),
                            Message = ("A Commit\n"),
                            TreeEntry = (t)
                        };
            Assert.AreEqual(t.TreeId, c.TreeId);
            c.Save();

            string s_c = new Inspector(db).Inspect(c.CommitId);
            ObjectId cmtid = ObjectId.FromString("16c0beaf7523eb3ef5df45bd42dd4fc6343de864");
            Assert.AreEqual(cmtid, c.CommitId);

            // Verify the commit we just wrote is in the correct format.
            //using (var xis = new XInputStream(new FileStream(db.ToFile(cmtid).FullName, System.IO.FileMode.Open, FileAccess.Read)))
            //{
            //    Assert.AreEqual(0x78, xis.ReadUInt8());
            //    Assert.AreEqual(0x9c, xis.ReadUInt8());
            //    Assert.IsTrue(0x789c % 31 == 0);
            //}

            // Verify we can Read it.
            Commit c2 = db.MapCommit(cmtid.ToString());
            Assert.IsNotNull(c2);
            Assert.AreEqual(c.Message, c2.Message);
            Assert.AreEqual(c.TreeId, c2.TreeId);
            Assert.AreEqual(c.Author, c2.Author);
            Assert.AreEqual(c.Committer, c2.Committer);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:47,代码来源:T0003_Basic_Write.cs

示例3: Write_Tree

        public void Write_Tree()
        {
            var t = new Tree(db);
            FileTreeEntry f = t.AddFile("i-am-a-file");
            writeTrashFile(f.Name, "and this is the data in me\r\n\r\n");
            Assert.AreEqual(File.ReadAllText("Resources/single_file_commit/i-am-a-file"), File.ReadAllText(trash + "/i-am-a-file"));
            t.Accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
            var id = t.Id;

            var b1 = new BinaryReader(new Inspector(db).ContentStream(id));
            b1.BaseStream.Position = b1.BaseStream.Length - 21;

            var b2 = new BinaryReader(Inspector.ContentStream("Resources/single_file_commit", "917c130bd4fa5bf2df0c399dc1b03401860aa448"));
            b2.BaseStream.Position = b2.BaseStream.Length - 21;
            Assert.AreEqual(b2.ReadByte(), b1.ReadByte());

            var git_w1=b2.ReadInt32();
            var git_w2=b2.ReadInt32();
            var git_w3 = b2.ReadInt32();
            var git_w4 = b2.ReadInt32();
            var git_w5 = b2.ReadInt32();
            b2.BaseStream.Position = b2.BaseStream.Length-20;
            var git_id = ObjectId.FromRaw(b2.ReadBytes(20));
            var w1 = b1.ReadInt32();
            var w2= b1.ReadInt32();
            b1.Close();
            b2.Close();

            Assert.AreEqual(git_w1,w1);
            Assert.AreEqual(git_w2, w2);

            Assert.AreEqual("917c130bd4fa5bf2df0c399dc1b03401860aa448", id.ToString());
            var s_git = Inspector.Inspect("Resources/single_file_commit", "917c130bd4fa5bf2df0c399dc1b03401860aa448");
            var s = new Inspector(db).Inspect(id);
            Assert.AreEqual(s_git, s);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:36,代码来源:T0003_Basic_Write.cs

示例4: test026_CreateCommitMultipleparents

        public void test026_CreateCommitMultipleparents()
        {
            db.Config.load();

            var t = new Tree(db);
            FileTreeEntry f = t.AddFile("i-am-a-file");
            writeTrashFile(f.Name, "and this is the data in me\n");
            t.Accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
            Assert.AreEqual(ObjectId.FromString("00b1f73724f493096d1ffa0b0f1f1482dbb8c936"),
                    t.TreeId);

            var c1 = new Commit(db)
                     	{
                     		Author = new PersonIdent(jauthor, 1154236443000L, -4*60),
                     		Committer = new PersonIdent(jcommitter, 1154236443000L, -4*60),
                     		Message = "A Commit\n",
                     		TreeEntry = t
                     	};

            Assert.AreEqual(t.TreeId, c1.TreeId);
            c1.Save();
            ObjectId cmtid1 = ObjectId.FromString("803aec4aba175e8ab1d666873c984c0308179099");
            Assert.AreEqual(cmtid1, c1.CommitId);

            var c2 = new Commit(db)
                     	{
                     		Author = new PersonIdent(jauthor, 1154236443000L, -4*60),
                     		Committer = new PersonIdent(jcommitter, 1154236443000L, -4*60),
                     		Message = "A Commit 2\n",
                     		TreeEntry = t
                     	};

            Assert.AreEqual(t.TreeId, c2.TreeId);
            c2.ParentIds = new[] { c1.CommitId };
            c2.Save();
            ObjectId cmtid2 = ObjectId.FromString("95d068687c91c5c044fb8c77c5154d5247901553");
            Assert.AreEqual(cmtid2, c2.CommitId);

            Commit rm2 = db.MapCommit(cmtid2);
            Assert.AreNotSame(c2, rm2); // assert the parsed objects is not from the cache
            Assert.AreEqual(c2.Author, rm2.Author);
            Assert.AreEqual(c2.CommitId, rm2.CommitId);
            Assert.AreEqual(c2.Message, rm2.Message);
            Assert.AreEqual(c2.TreeEntry.TreeId, rm2.TreeEntry.TreeId);
            Assert.AreEqual(1, rm2.ParentIds.Length);
            Assert.AreEqual(c1.CommitId, rm2.ParentIds[0]);

            var c3 = new Commit(db)
                     	{
                     		Author = new PersonIdent(jauthor, 1154236443000L, -4*60),
                     		Committer = new PersonIdent(jcommitter, 1154236443000L, -4*60),
                     		Message = "A Commit 3\n",
                     		TreeEntry = t
                     	};

            Assert.AreEqual(t.TreeId, c3.TreeId);
            c3.ParentIds = new[] { c1.CommitId, c2.CommitId };
            c3.Save();
            ObjectId cmtid3 = ObjectId.FromString("ce6e1ce48fbeeb15a83f628dc8dc2debefa066f4");
            Assert.AreEqual(cmtid3, c3.CommitId);

            Commit rm3 = db.MapCommit(cmtid3);
            Assert.AreNotSame(c3, rm3); // assert the parsed objects is not from the cache
            Assert.AreEqual(c3.Author, rm3.Author);
            Assert.AreEqual(c3.CommitId, rm3.CommitId);
            Assert.AreEqual(c3.Message, rm3.Message);
            Assert.AreEqual(c3.TreeEntry.TreeId, rm3.TreeEntry.TreeId);
            Assert.AreEqual(2, rm3.ParentIds.Length);
            Assert.AreEqual(c1.CommitId, rm3.ParentIds[0]);
            Assert.AreEqual(c2.CommitId, rm3.ParentIds[1]);

            var c4 = new Commit(db)
                     	{
                     		Author = new PersonIdent(jauthor, 1154236443000L, -4*60),
                     		Committer = new PersonIdent(jcommitter, 1154236443000L, -4*60),
                     		Message = "A Commit 4\n",
                     		TreeEntry = t
                     	};

            Assert.AreEqual(t.TreeId, c3.TreeId);
            c4.ParentIds = new[] { c1.CommitId, c2.CommitId, c3.CommitId };
            c4.Save();
            ObjectId cmtid4 = ObjectId.FromString("d1fca9fe3fef54e5212eb67902c8ed3e79736e27");
            Assert.AreEqual(cmtid4, c4.CommitId);

            Commit rm4 = db.MapCommit(cmtid4);
            Assert.AreNotSame(c4, rm3); // assert the parsed objects is not from the cache
            Assert.AreEqual(c4.Author, rm4.Author);
            Assert.AreEqual(c4.CommitId, rm4.CommitId);
            Assert.AreEqual(c4.Message, rm4.Message);
            Assert.AreEqual(c4.TreeEntry.TreeId, rm4.TreeEntry.TreeId);
            Assert.AreEqual(3, rm4.ParentIds.Length);
            Assert.AreEqual(c1.CommitId, rm4.ParentIds[0]);
            Assert.AreEqual(c2.CommitId, rm4.ParentIds[1]);
            Assert.AreEqual(c3.CommitId, rm4.ParentIds[2]);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:96,代码来源:T0003_Basic_Write.cs

示例5: test012_SubtreeExternalSorting

        public void test012_SubtreeExternalSorting()
        {
            ObjectId emptyBlob = new ObjectWriter(db).WriteBlob(new byte[0]);
            var t = new Tree(db);
            FileTreeEntry e0 = t.AddFile("a-");
            FileTreeEntry e1 = t.AddFile("a-b");
            FileTreeEntry e2 = t.AddFile("a/b");
            FileTreeEntry e3 = t.AddFile("a=");
            FileTreeEntry e4 = t.AddFile("a=b");

            e0.Id = emptyBlob;
            e1.Id = emptyBlob;
            e2.Id = emptyBlob;
            e3.Id = emptyBlob;
            e4.Id = emptyBlob;

            t.Accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
            Assert.AreEqual(ObjectId.FromString("b47a8f0a4190f7572e11212769090523e23eb1ea"), t.Id);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:19,代码来源:T0003_Basic_Write.cs

示例6: test009_CreateCommitOldFormat

        public void test009_CreateCommitOldFormat()
        {
            writeTrashFile(".git/config", "[core]\n" + "legacyHeaders=1\n");
            db.Config.load();
            Assert.AreEqual(true, db.Config.getBoolean("core", "legacyHeaders", false));

            var t = new Tree(db);
            FileTreeEntry f = t.AddFile("i-am-a-file");
            writeTrashFile(f.Name, "and this is the data in me\n");
            t.Accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);

            Assert.AreEqual(ObjectId.FromString("00b1f73724f493096d1ffa0b0f1f1482dbb8c936"), t.TreeId);

            var c = new Commit(db)
                        {
                            Author = (new PersonIdent(jauthor, 1154236443000L, -4*60)),
                            Committer = (new PersonIdent(jcommitter, 1154236443000L, -4*60)),
                            Message = ("A Commit\n"),
                            TreeEntry = t
                        };
            Assert.AreEqual(t.TreeId, c.TreeId);
            c.Save();

            ObjectId cmtid = ObjectId.FromString("803aec4aba175e8ab1d666873c984c0308179099");
            Assert.AreEqual(cmtid, c.CommitId);

            // Verify the commit we just wrote is in the correct format.
            var xis = new XInputStream(new FileStream(db.ToFile(cmtid).FullName, System.IO.FileMode.Open, FileAccess.Read));
            try
            {
                Assert.AreEqual(0x78, xis.ReadUInt8());
                Assert.AreEqual(0x9c, xis.ReadUInt8());
                Assert.IsTrue(0x789c % 31 == 0);
            }
            finally
            {
                xis.Close();
            }

            // Verify we can Read it.
            Commit c2 = db.MapCommit(cmtid);
            Assert.IsNotNull(c2);
            Assert.AreEqual(c.Message, c2.Message);
            Assert.AreEqual(c.TreeId, c2.TreeId);
            Assert.AreEqual(c.Author, c2.Author);
            Assert.AreEqual(c.Committer, c2.Committer);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:47,代码来源:T0003_Basic_Write.cs

示例7: test003_WriteShouldBeEmptyTree

        public void test003_WriteShouldBeEmptyTree()
        {
            Tree t = new Tree(db);
            ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
            t.AddFile("should-be-empty").Id = emptyId;
            t.Accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
            Assert.AreEqual("7bb943559a305bdd6bdee2cef6e5df2413c3d30a", t.Id.Name);

            var o = new FileInfo(trash_git + "/objects/7b/b943559a305bdd6bdee2cef6e5df2413c3d30a");
            Assert.IsTrue(o.IsFile(), "Exists " + o);
            Assert.IsTrue(o.IsReadOnly, "Read-only " + o);

            o = new FileInfo(trash_git + "/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391");
            Assert.IsTrue(o.IsFile(), "Exists " + o);
            Assert.IsTrue(o.IsReadOnly, "Read-only " + o);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:16,代码来源:T0003_Basic_Write.cs

示例8: test002_WriteEmptyTree2

 public void test002_WriteEmptyTree2()
 {
     // File shouldn't exist as it is in a test pack.
     //
     var t = new Tree(db);
     t.Accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
     Assert.AreEqual("4b825dc642cb6eb9a060e54bf8d69288fbee4904", t.Id.Name);
     var o = new FileInfo(trash_git + "/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904");
     Assert.IsFalse(o.IsFile(), "Exists " + o);
 }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:10,代码来源:T0003_Basic_Write.cs


注:本文中的GitSharp.Core.Tree.Accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。