本文整理汇总了C#中NGit.Tree类的典型用法代码示例。如果您正苦于以下问题:C# Tree类的具体用法?C# Tree怎么用?C# Tree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tree类属于NGit命名空间,在下文中一共展示了Tree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupCase
/// <exception cref="System.IO.IOException"></exception>
internal virtual void SetupCase(Dictionary<string, string> headEntries, Dictionary
<string, string> mergeEntries, Dictionary<string, string> indexEntries)
{
theHead = BuildTree(headEntries);
theMerge = BuildTree(mergeEntries);
BuildIndex(indexEntries);
}
示例2: TestSimpleF1
public virtual void TestSimpleF1()
{
Tree tree = new Tree(db);
tree.AddFile("x");
TreeIterator i = MakeIterator(tree);
NUnit.Framework.Assert.IsTrue(i.HasNext());
NUnit.Framework.Assert.AreEqual("x", i.Next().GetName());
}
示例3: StartVisitTree
/// <exception cref="System.IO.IOException"></exception>
public virtual void StartVisitTree(Tree t)
{
stack.AddItem(currentDirectory);
if (!t.IsRoot())
{
currentDirectory = new FilePath(currentDirectory, t.GetName());
}
}
示例4: TestEmpty
public virtual void TestEmpty()
{
Tree tree = new Tree(db);
TreeIterator i = MakeIterator(tree);
NUnit.Framework.Assert.IsTrue(i.HasNext());
NUnit.Framework.Assert.AreEqual(string.Empty, i.Next().GetFullName());
NUnit.Framework.Assert.IsFalse(i.HasNext());
}
示例5: IndexTreeWalker
/// <summary>Construct a walker for the index and one tree.</summary>
/// <remarks>Construct a walker for the index and one tree.</remarks>
/// <param name="index"></param>
/// <param name="tree"></param>
/// <param name="root"></param>
/// <param name="visitor"></param>
public IndexTreeWalker(GitIndex index, Tree tree, FilePath root, IndexTreeVisitor
visitor)
{
//import org.eclipse.jgit.JGitText;
this.mainTree = tree;
this.root = root;
this.visitor = visitor;
this.newTree = null;
threeTrees = false;
indexMembers = index.GetMembers();
}
示例6: PrescanTwoTrees
/// <exception cref="System.InvalidOperationException"></exception>
/// <exception cref="System.IO.IOException"></exception>
public override void PrescanTwoTrees(Tree head, Tree merge)
{
DirCache dc = db.LockDirCache();
try
{
dco = new DirCacheCheckout(db, head.GetId(), dc, merge.GetId());
dco.PreScanTwoTrees();
}
finally
{
dc.Unlock();
}
}
示例7: TestBoth
public virtual void TestBoth()
{
GitIndex index = new GitIndex(db);
Tree tree = new Tree(db);
index.Add(trash, WriteTrashFile("a", "a"));
tree.AddFile("b/b");
index.Add(trash, WriteTrashFile("c", "c"));
tree.AddFile("c");
new IndexTreeWalker(index, tree, trash, new IndexTreeWalkerTest.TestIndexTreeVisitor
(this)).Walk();
NUnit.Framework.Assert.IsTrue(indexOnlyEntriesVisited.Contains("a"));
NUnit.Framework.Assert.IsTrue(treeOnlyEntriesVisited.Contains("b/b"));
NUnit.Framework.Assert.IsTrue(bothVisited.Contains("c"));
}
示例8: TestRules1thru3_NoIndexEntry
public virtual void TestRules1thru3_NoIndexEntry()
{
Tree head = new Tree(db);
head = BuildTree(Mk("foo"));
ObjectId objectId = head.FindBlobMember("foo").GetId();
Tree merge = new Tree(db);
PrescanTwoTrees(head, merge);
NUnit.Framework.Assert.IsTrue(GetRemoved().Contains("foo"));
PrescanTwoTrees(merge, head);
NUnit.Framework.Assert.AreEqual(objectId, GetUpdated().Get("foo"));
merge = BuildTree(Mkmap("foo", "a"));
ObjectId anotherId = merge.FindBlobMember("foo").GetId();
PrescanTwoTrees(head, merge);
NUnit.Framework.Assert.AreEqual(anotherId, GetUpdated().Get("foo"));
}
示例9: TestAdded
public virtual void TestAdded()
{
GitIndex index = new GitIndex(db);
WriteTrashFile("file1", "file1");
WriteTrashFile("dir/subfile", "dir/subfile");
Tree tree = new Tree(db);
tree.SetId(InsertTree(tree));
index.Add(trash, new FilePath(trash, "file1"));
index.Add(trash, new FilePath(trash, "dir/subfile"));
index.Write();
FileTreeIterator iterator = new FileTreeIterator(db);
IndexDiff diff = new IndexDiff(db, tree.GetId(), iterator);
diff.Diff();
NUnit.Framework.Assert.AreEqual(2, diff.GetAdded().Count);
NUnit.Framework.Assert.IsTrue(diff.GetAdded().Contains("file1"));
NUnit.Framework.Assert.IsTrue(diff.GetAdded().Contains("dir/subfile"));
NUnit.Framework.Assert.AreEqual(0, diff.GetChanged().Count);
NUnit.Framework.Assert.AreEqual(0, diff.GetModified().Count);
NUnit.Framework.Assert.AreEqual(0, diff.GetRemoved().Count);
}
示例10: TestAdded
public virtual void TestAdded()
{
WriteTrashFile("file1", "file1");
WriteTrashFile("dir/subfile", "dir/subfile");
Tree tree = new Tree(db);
tree.SetId(InsertTree(tree));
DirCache index = db.LockDirCache();
DirCacheEditor editor = index.Editor();
editor.Add(Add(db, trash, "file1"));
editor.Add(Add(db, trash, "dir/subfile"));
editor.Commit();
FileTreeIterator iterator = new FileTreeIterator(db);
IndexDiff diff = new IndexDiff(db, tree.GetId(), iterator);
diff.Diff();
NUnit.Framework.Assert.AreEqual(2, diff.GetAdded().Count);
NUnit.Framework.Assert.IsTrue(diff.GetAdded().Contains("file1"));
NUnit.Framework.Assert.IsTrue(diff.GetAdded().Contains("dir/subfile"));
NUnit.Framework.Assert.AreEqual(0, diff.GetChanged().Count);
NUnit.Framework.Assert.AreEqual(0, diff.GetModified().Count);
NUnit.Framework.Assert.AreEqual(0, diff.GetRemoved().Count);
NUnit.Framework.CollectionAssert.AreEquivalent(Collections<string>.EMPTY_SET, diff.GetUntrackedFolders()
);
}
示例11: TestIndexOnlySubDirs
public virtual void TestIndexOnlySubDirs()
{
GitIndex index = new GitIndex(db);
Tree tree = new Tree(db);
index.Add(trash, WriteTrashFile("foo/bar/baz", "foobar"));
index.Add(trash, WriteTrashFile("asdf", "asdf"));
new IndexTreeWalker(index, tree, trash, new IndexTreeWalkerTest.TestIndexTreeVisitor
(this)).Walk();
NUnit.Framework.Assert.AreEqual("asdf", indexOnlyEntriesVisited[0]);
NUnit.Framework.Assert.AreEqual("foo/bar/baz", indexOnlyEntriesVisited[1]);
}
示例12: Test024_createCommitNonAscii
public virtual void Test024_createCommitNonAscii()
{
ObjectId emptyId = InsertEmptyBlob();
Tree almostEmptyTree = new Tree(db);
almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, Sharpen.Runtime.GetBytesForString
("empty"), false));
ObjectId almostEmptyTreeId = InsertTree(almostEmptyTree);
NGit.CommitBuilder commit = new NGit.CommitBuilder();
commit.TreeId = almostEmptyTreeId;
commit.Author = new PersonIdent("Joe H\u00e4cker", "[email protected]", 4294967295000L
, 60);
commit.Committer = new PersonIdent("Joe Hacker", "[email protected]", 4294967295000L
, 60);
commit.SetEncoding("ISO-8859-1");
commit.Message = "\u00dcbergeeks";
ObjectId cid = InsertCommit(commit);
NUnit.Framework.Assert.AreEqual("2979b39d385014b33287054b87f77bcb3ecb5ebf", cid.Name
);
}
示例13: Test022_createCommitTag
public virtual void Test022_createCommitTag()
{
ObjectId emptyId = InsertEmptyBlob();
Tree almostEmptyTree = new Tree(db);
almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, Sharpen.Runtime.GetBytesForString
("empty"), false));
ObjectId almostEmptyTreeId = InsertTree(almostEmptyTree);
NGit.CommitBuilder almostEmptyCommit = new NGit.CommitBuilder();
almostEmptyCommit.Author = new PersonIdent(author, 1154236443000L, -2 * 60);
// not exactly the same
almostEmptyCommit.Committer = new PersonIdent(author, 1154236443000L, -2 * 60);
almostEmptyCommit.Message = "test022\n";
almostEmptyCommit.TreeId = almostEmptyTreeId;
ObjectId almostEmptyCommitId = InsertCommit(almostEmptyCommit);
TagBuilder t = new TagBuilder();
t.SetObjectId(almostEmptyCommitId, Constants.OBJ_COMMIT);
t.SetTag("test022");
t.SetTagger(new PersonIdent(author, 1154236443000L, -4 * 60));
t.SetMessage("test022 tagged\n");
ObjectId actid = InsertTag(t);
NUnit.Framework.Assert.AreEqual("0ce2ebdb36076ef0b38adbe077a07d43b43e3807", actid
.Name);
RevTag mapTag = ParseTag(actid);
NUnit.Framework.Assert.AreEqual(Constants.OBJ_COMMIT, mapTag.GetObject().Type);
NUnit.Framework.Assert.AreEqual("test022 tagged\n", mapTag.GetFullMessage());
NUnit.Framework.Assert.AreEqual(new PersonIdent(author, 1154236443000L, -4 * 60),
mapTag.GetTaggerIdent());
NUnit.Framework.Assert.AreEqual("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag
.GetObject().Id.Name);
}
示例14: Test012_SubtreeExternalSorting
public virtual void Test012_SubtreeExternalSorting()
{
ObjectId emptyBlob = InsertEmptyBlob();
Tree 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.SetId(emptyBlob);
e1.SetId(emptyBlob);
e2.SetId(emptyBlob);
e3.SetId(emptyBlob);
e4.SetId(emptyBlob);
Tree a = (Tree)t.FindTreeMember("a");
a.SetId(InsertTree(a));
NUnit.Framework.Assert.AreEqual(ObjectId.FromString("b47a8f0a4190f7572e11212769090523e23eb1ea"
), InsertTree(t));
}
示例15: WorkDirCheckout
/// <summary>Create a checkout class for merging and checking our two trees and the index.
/// </summary>
/// <remarks>Create a checkout class for merging and checking our two trees and the index.
/// </remarks>
/// <param name="repo"></param>
/// <param name="root">workdir</param>
/// <param name="head"></param>
/// <param name="index"></param>
/// <param name="merge"></param>
public WorkDirCheckout(Repository repo, FilePath root, Tree head, GitIndex index,
Tree merge) : this(repo, root, index, merge)
{
this.head = head;
}