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


C# Tree.AddFile方法代码示例

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


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

示例1: testSimpleF1

 public void testSimpleF1()
 {
     Tree tree = new Tree(db);
     tree.AddFile("x");
     TreeIterator i = MakeIterator(tree);
     Assert.IsTrue(i.hasNext());
     Assert.AreEqual("x", i.next().Name);
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:8,代码来源:TreeIteratorLeafOnlyTest.cs

示例2: testTricky

        public void testTricky()
        {
            Tree tree = new Tree(db);
            tree.AddFile("a.b");
            tree.AddFile("a.c");
            tree.AddFile("a/b.b/b");
            tree.AddFile("a/b");
            tree.AddFile("a/c");
            tree.AddFile("a=c");
            tree.AddFile("a=d");

            TreeIterator i = MakeIterator(tree);
            Assert.IsTrue(i.hasNext());
            Assert.AreEqual("", i.next().FullName);
            Assert.IsTrue(i.hasNext());
            Assert.AreEqual("a.b", i.next().FullName);
            Assert.IsTrue(i.hasNext());
            Assert.AreEqual("a.c", i.next().FullName);
            Assert.IsTrue(i.hasNext());
            Assert.AreEqual("a", i.next().FullName);
            Assert.IsTrue(i.hasNext());
            Assert.AreEqual("a/b", i.next().FullName);
            Assert.IsTrue(i.hasNext());
            Assert.AreEqual("a/b.b", i.next().FullName);
            Assert.IsTrue(i.hasNext());
            Assert.AreEqual("a/b.b/b", i.next().FullName);
            Assert.IsTrue(i.hasNext());
            Assert.AreEqual("a/c", i.next().FullName);
            Assert.IsTrue(i.hasNext());
            Assert.AreEqual("a=c", i.next().FullName);
            Assert.IsTrue(i.hasNext());
            Assert.AreEqual("a=d", i.next().FullName);
            Assert.IsFalse(i.hasNext());
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:34,代码来源:TreeIteratorPreOrderTest.cs

示例3: 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.ToString());

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

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

示例4: testTreeOnlyOneLevel

 public void testTreeOnlyOneLevel()
 {
     var index = new GitIndex(db);
     var mainTree = new Tree(db);
     mainTree.AddFile("foo");
     mainTree.AddFile("bar");
     new IndexTreeWalker(index, mainTree, trash, TestIndexTreeVisitor).Walk();
     Assert.IsTrue(TreeOnlyEntriesVisited[0].Equals("bar"));
     Assert.IsTrue(TreeOnlyEntriesVisited[1].Equals("foo"));
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:10,代码来源:IndexTreeWalkerTest.cs

示例5: testBoth

        public void testBoth()
        {
            var index = new GitIndex(db);
            var mainTree = new Tree(db);

            index.add(trash, writeTrashFile("a", "a"));
            mainTree.AddFile("b/b");
            index.add(trash, writeTrashFile("c", "c"));
            mainTree.AddFile("c");

            new IndexTreeWalker(index, mainTree, trash, TestIndexTreeVisitor).Walk();
            Assert.IsTrue(IndexOnlyEntriesVisited.Contains("a"));
            Assert.IsTrue(TreeOnlyEntriesVisited.Contains("b/b"));
            Assert.IsTrue(BothVisited.Contains("c"));
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:15,代码来源:IndexTreeWalkerTest.cs

示例6: test002_addFile

        public void test002_addFile()
        {
            var t = new Tree(db) { Id = SomeFakeId };
            Assert.IsTrue(t.Id != null);
            Assert.IsFalse(t.IsModified);

            const string n = "bob";
            FileTreeEntry f = t.AddFile(n);
            Assert.IsNotNull(f);
            Assert.AreEqual(n, f.Name);
            Assert.AreEqual(f.Name, Constants.CHARSET.GetString(f.NameUTF8));
            Assert.AreEqual(n, f.FullName);
            Assert.IsTrue(f.Id == null);
            Assert.IsTrue(t.IsModified);
            Assert.IsTrue(t.Id == null);
            Assert.IsTrue(t.FindBlobMember(f.Name) == f);

            TreeEntry[] i = t.Members;
            Assert.IsNotNull(i);
            Assert.IsTrue(i != null && i.Length > 0);
            Assert.IsTrue(i != null && i[0] == f);
            Assert.IsTrue(i != null && i.Length == 1);
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:23,代码来源:TreeTests.cs

示例7: 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]", 1245946742, 2*60)),
                            Committer = (new PersonIdent("henon", "[email protected]", 1245946742, 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:HackerBaloo,项目名称:GitSharp,代码行数:47,代码来源:WriteTests.cs

示例8: 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:HackerBaloo,项目名称:GitSharp,代码行数:19,代码来源:WriteTests.cs

示例9: testRemoved

        public void testRemoved()
        {
            var index = new GitIndex(db);
            writeTrashFile("file2", "file2");
            writeTrashFile("dir/file3", "dir/file3");

            var t = new Tree(db);
            t.AddFile("file2");
            t.AddFile("dir/file3");
            Assert.AreEqual(2, t.MemberCount);
            t.FindBlobMember("file2").Id = ObjectId.FromString("30d67d4672d5c05833b7192cc77a79eaafb5c7ad");
            var tree2 = (Tree) t.findTreeMember("dir");
            tree2.FindBlobMember("file3").Id = ObjectId.FromString("873fb8d667d05436d728c52b1d7a09528e6eb59b");
            tree2.Id = new ObjectWriter(db).WriteTree(tree2);
            t.Id = new ObjectWriter(db).WriteTree(t);

            var diff = new IndexDiff(t, index);
            diff.Diff();
            Assert.AreEqual(2, diff.Removed.Count);
            Assert.IsTrue(diff.Removed.Contains("file2"));
            Assert.IsTrue(diff.Removed.Contains("dir/file3"));
            Assert.AreEqual(0, diff.Changed.Count);
            Assert.AreEqual(0, diff.Modified.Count);
            Assert.AreEqual(0, diff.Added.Count);
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:25,代码来源:IndexDiffTest.cs

示例10: BuildTree

 private Tree BuildTree(Dictionary<string, string> headEntries)
 {
     var tree = new Tree(db);
     if (headEntries != null)
     {
         foreach (var pair in headEntries)
         {
             tree.AddFile(pair.Key).Id = GenSha1(pair.Value);
         }
     }
     return tree;
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:12,代码来源:ReadTreeTest.cs

示例11: testRules1thru3_NoIndexEntry

 public void testRules1thru3_NoIndexEntry()
 {
     var index = new GitIndex(db);
     var head = new Tree(db);
     FileTreeEntry entry = head.AddFile("foo");
     ObjectId expected = ObjectId.FromString("ba78e065e2c261d4f7b8f42107588051e87e18e9");
     entry.Id = expected;
     var merge = new Tree(db);
     var checkout = new WorkDirCheckout(db, trash, head, index, merge);
     checkout.PrescanTwoTrees();
     Assert.IsTrue(checkout.Removed.Contains("foo"));
     checkout = new WorkDirCheckout(db, trash, merge, index, head);
     checkout.PrescanTwoTrees();
     Assert.AreEqual(expected, checkout.Updated["foo"]);
     ObjectId id2 = ObjectId.FromString("ba78e065e2c261d4f7b8f42107588051e87e18ee");
     merge.AddFile("foo").Id = id2;
     checkout = new WorkDirCheckout(db, trash, head, index, merge);
     checkout.PrescanTwoTrees();
     Assert.AreEqual(id2, checkout.Updated["foo"]);
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:20,代码来源:ReadTreeTest.cs

示例12: test008_SubtreeInternalSorting

        public void test008_SubtreeInternalSorting()
        {
            var t = new Tree(db);
            FileTreeEntry e0 = t.AddFile("a-b");
            FileTreeEntry e1 = t.AddFile("a-");
            FileTreeEntry e2 = t.AddFile("a=b");
            Tree e3 = t.AddTree("a");
            FileTreeEntry e4 = t.AddFile("a=");

            TreeEntry[] ents = t.Members;
            Assert.AreSame(e1, ents[0]);
            Assert.AreSame(e0, ents[1]);
            Assert.AreSame(e3, ents[2]);
            Assert.AreSame(e4, ents[3]);
            Assert.AreSame(e2, ents[4]);
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:16,代码来源:TreeTests.cs

示例13: test007_manyFileLookup

 public void test007_manyFileLookup()
 {
     var t = new Tree(db);
     var files = new List<FileTreeEntry>(26 * 26);
     for (char level1 = 'a'; level1 <= 'z'; level1++)
     {
         for (char level2 = 'a'; level2 <= 'z'; level2++)
         {
             String n = "." + level1 + level2 + "9";
             FileTreeEntry f = t.AddFile(n);
             Assert.IsNotNull(f, "File " + n + " added.");
             Assert.AreEqual(n, f.Name);
             files.Add(f);
         }
     }
     Assert.AreEqual(files.Count, t.MemberCount);
     TreeEntry[] ents = t.Members;
     Assert.IsNotNull(ents);
     Assert.AreEqual(files.Count, ents.Length);
     for (int k = 0; k < ents.Length; k++)
     {
         Assert.IsTrue(files[k] == ents[k], "File " + files[k].Name + " is at " + k + ".");
     }
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:24,代码来源:TreeTests.cs

示例14: test005_addRecursiveFile

 public void test005_addRecursiveFile()
 {
     var t = new Tree(db);
     FileTreeEntry f = t.AddFile("a/b/c");
     Assert.IsNotNull(f);
     Assert.AreEqual(f.Name, "c");
     Assert.AreEqual(f.Parent.Name, "b");
     Assert.AreEqual(f.Parent.Parent.Name, "a");
     Assert.IsTrue(t == f.Parent.Parent.Parent, "t is great-grandparent");
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:10,代码来源:TreeTests.cs

示例15: test009_CreateCommitOldFormat

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

            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);

            var s = new Inspector(db).Inspect(t.Id);

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

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

            var sc = new Inspector(db).Inspect(c.CommitId);

            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.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:HackerBaloo,项目名称:GitSharp,代码行数:51,代码来源:WriteTests.cs


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