本文整理汇总了C#中Tree.AddTree方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.AddTree方法的具体用法?C# Tree.AddTree怎么用?C# Tree.AddTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree.AddTree方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testMissingSubtree_DetectFileAdded_FileModified
public void testMissingSubtree_DetectFileAdded_FileModified()
{
var ow = new ObjectWriter(db);
ObjectId aFileId = ow.WriteBlob(Constants.CHARSET.GetBytes("a"));
ObjectId bFileId = ow.WriteBlob(Constants.CHARSET.GetBytes("b"));
ObjectId cFileId1 = ow.WriteBlob(Constants.CHARSET.GetBytes("c-1"));
ObjectId cFileId2 = ow.WriteBlob(Constants.CHARSET.GetBytes("c-2"));
// Create sub-a/empty, sub-c/empty = hello.
Func<ObjectId> oldTree = () =>
{
var root = new Tree(db);
Tree subA = root.AddTree("sub-a");
subA.AddFile("empty").Id = aFileId;
subA.Id = ow.WriteTree(subA);
Tree subC = root.AddTree("sub-c");
subC.AddFile("empty").Id = cFileId1;
subC.Id = ow.WriteTree(subC);
return ow.WriteTree(root);
};
// Create sub-a/empty, sub-b/empty, sub-c/empty.
Func<ObjectId> newTree = () =>
{
var root = new Tree(db);
Tree subA = root.AddTree("sub-a");
subA.AddFile("empty").Id = aFileId;
subA.Id = ow.WriteTree(subA);
Tree subB = root.AddTree("sub-b");
subB.AddFile("empty").Id = bFileId;
subB.Id = ow.WriteTree(subB);
Tree subC = root.AddTree("sub-c");
subC.AddFile("empty").Id = cFileId2;
subC.Id = ow.WriteTree(subC);
return ow.WriteTree(root);
};
var tw = new GitSharp.TreeWalk.TreeWalk(db);
tw.reset(new[] { oldTree.Invoke(), newTree.Invoke() });
tw.Recursive = true;
tw.setFilter(TreeFilter.ANY_DIFF);
Assert.IsTrue(tw.next());
Assert.AreEqual("sub-b/empty", tw.getPathString());
Assert.AreEqual(FileMode.Missing, tw.getFileMode(0));
Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(1));
Assert.AreEqual(ObjectId.ZeroId, tw.getObjectId(0));
Assert.AreEqual(bFileId, tw.getObjectId(1));
Assert.IsTrue(tw.next());
Assert.AreEqual("sub-c/empty", tw.getPathString());
Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(0));
Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(1));
Assert.AreEqual(cFileId1, tw.getObjectId(0));
Assert.AreEqual(cFileId2, tw.getObjectId(1));
Assert.IsFalse(tw.next());
}
示例2: testSimpleT
public void testSimpleT()
{
Tree tree = new Tree(db);
tree.AddTree("a");
TreeIterator i = MakeIterator(tree);
Assert.IsTrue(i.hasNext());
Assert.AreEqual("", i.next().FullName);
Assert.IsTrue(i.hasNext());
Assert.AreEqual("a", i.next().FullName);
Assert.IsFalse(i.hasNext());
}
示例3: 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]);
}
示例4: test006_addDeepTree
public void test006_addDeepTree()
{
var t = new Tree(db);
Tree e = t.AddTree("e");
Assert.IsNotNull(e);
Assert.IsTrue(e.Parent == t);
Tree f = t.AddTree("f");
Assert.IsNotNull(f);
Assert.IsTrue(f.Parent == t);
Tree g = f.AddTree("g");
Assert.IsNotNull(g);
Assert.IsTrue(g.Parent == f);
Tree h = g.AddTree("h");
Assert.IsNotNull(h);
Assert.IsTrue(h.Parent == g);
h.Id = SomeFakeId;
Assert.IsTrue(!h.IsModified);
g.Id = SomeFakeId;
Assert.IsTrue(!g.IsModified);
f.Id = SomeFakeId;
Assert.IsTrue(!f.IsModified);
e.Id = SomeFakeId;
Assert.IsTrue(!e.IsModified);
t.Id = SomeFakeId;
Assert.IsTrue(!t.IsModified);
Assert.AreEqual("f/g/h", h.FullName);
Assert.IsTrue(t.findTreeMember(h.FullName) == h);
Assert.IsTrue(t.FindBlobMember("f/z") == null);
Assert.IsTrue(t.FindBlobMember("y/z") == null);
FileTreeEntry i = h.AddFile("i");
Assert.IsNotNull(i);
Assert.AreEqual("f/g/h/i", i.FullName);
Assert.IsTrue(t.FindBlobMember(i.FullName) == i);
Assert.IsTrue(h.IsModified);
Assert.IsTrue(g.IsModified);
Assert.IsTrue(f.IsModified);
Assert.IsTrue(!e.IsModified);
Assert.IsTrue(t.IsModified);
Assert.IsTrue(h.Id == null);
Assert.IsTrue(g.Id == null);
Assert.IsTrue(f.Id == null);
Assert.IsTrue(e.Id != null);
Assert.IsTrue(t.Id == null);
}
示例5: test005_addRecursiveTree
public void test005_addRecursiveTree()
{
var t = new Tree(db);
Tree f = t.AddTree("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");
}
示例6: test004_addTree
public void test004_addTree()
{
var t = new Tree(db) {Id = SomeFakeId};
Assert.IsTrue(t.Id != null);
Assert.IsFalse(t.IsModified);
const string n = "bob";
Tree f = t.AddTree(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(f.Parent == t);
Assert.IsTrue(f.Repository == db);
Assert.IsTrue(f.IsLoaded);
Assert.IsFalse(f.Members.Length > 0);
Assert.IsFalse(f.IsRoot);
Assert.IsTrue(f.TreeEntry == f);
Assert.IsTrue(t.IsModified);
Assert.IsTrue(t.Id == null);
Assert.IsTrue(t.findTreeMember(f.Name) == f);
TreeEntry[] i = t.Members;
Assert.IsTrue(i.Length > 0);
Assert.IsTrue(i[0] == f);
Assert.IsTrue(i.Length == 1);
}
示例7: testSimpleT
public void testSimpleT()
{
Tree tree = new Tree(db);
tree.AddTree("a");
TreeIterator i = MakeIterator(tree);
Assert.IsFalse(i.hasNext());
}