本文整理汇总了C#中GitSharp.Core.Tree类的典型用法代码示例。如果您正苦于以下问题:C# Tree类的具体用法?C# Tree怎么用?C# Tree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tree类属于GitSharp.Core命名空间,在下文中一共展示了Tree类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: StartVisitTree
public void StartVisitTree(Tree t)
{
stack.Push(currentDirectory);
if (!t.IsRoot)
{
currentDirectory = new DirectoryInfo(Path.Combine(currentDirectory.FullName, t.Name));
}
}
开发者ID:stschake,项目名称:GitSharp,代码行数:8,代码来源:TreeVisitorWithCurrentDirectory.cs
示例2: 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:georgeck,项目名称:GitSharp,代码行数:8,代码来源:TreeIteratorLeafOnlyTest.cs
示例3: handler
void IndexTreeVisitor.FinishVisitTree(Tree tree, Tree auxTree, string curDir)
{
FinishVisitTreeDelegate handler = FinishVisitTree;
if (handler != null)
{
handler(tree, auxTree, curDir);
}
}
开发者ID:dev218,项目名称:GitSharp,代码行数:8,代码来源:AbstractIndexTreeVisitor.cs
示例4: WorkDirCheckout
internal WorkDirCheckout(Repository repo, DirectoryInfo workDir, GitIndex oldIndex, GitIndex newIndex)
: this()
{
_repo = repo;
_root = workDir;
_index = oldIndex;
_merge = repo.MapTree(newIndex.writeTree());
}
开发者ID:dev218,项目名称:GitSharp,代码行数:8,代码来源:WorkDirCheckout.cs
示例5: testEmpty
public void testEmpty()
{
Tree tree = new Tree(db);
TreeIterator i = makeIterator(tree);
Assert.IsTrue(i.hasNext());
Assert.AreEqual("", i.next().FullName);
Assert.IsFalse(i.hasNext());
}
开发者ID:georgeck,项目名称:GitSharp,代码行数:8,代码来源:TreeIteratorPostOrderTest.cs
示例6: IndexTreeWalker
public IndexTreeWalker(GitIndex index, Tree mainTree, Tree newTree, FileSystemInfo root,
IndexTreeVisitor visitor)
{
_mainTree = mainTree;
_newTree = newTree;
_root = root;
_visitor = visitor;
_threeTrees = newTree != null;
_indexMembers = index.Members;
}
开发者ID:stschake,项目名称:GitSharp,代码行数:10,代码来源:IndexTreeWalker.cs
示例7: IndexDiff
public IndexDiff(Tree tree, GitIndex index)
{
_anyChanges = false;
_tree = tree;
_index = index;
Added = new HashSet<string>();
Changed = new HashSet<string>();
Removed = new HashSet<string>();
Missing = new HashSet<string>();
Modified = new HashSet<string>();
}
开发者ID:georgeck,项目名称:GitSharp,代码行数:12,代码来源:IndexDiff.cs
示例8: testAdded2
public void testAdded2()
{
var index = new GitIndex(db);
writeTrashFile("test/für henon.txt", "Weißebier");
var tree = new Tree(db);
index.add(trash, new FileInfo(Path.Combine(trash.FullName, "test/für henon.txt")));
var diff = new IndexDiff(tree, index);
diff.Diff();
Assert.AreEqual(1, diff.Added.Count);
Assert.IsTrue(diff.Added.Contains("test/für henon.txt"));
Assert.AreEqual(0, diff.Changed.Count);
Assert.AreEqual(0, diff.Modified.Count);
Assert.AreEqual(0, diff.Removed.Count);
}
开发者ID:mdekrey,项目名称:GitSharp,代码行数:16,代码来源:IndexDiffTest.cs
示例9: testAdded
public void testAdded()
{
var index = new GitIndex(db);
writeTrashFile("file1", "file1");
writeTrashFile("dir/subfile", "dir/subfile");
var tree = new Tree(db);
index.add(trash, new FileInfo(Path.Combine(trash.FullName, "file1")));
index.add(trash, new FileInfo(Path.Combine(trash.FullName, "dir/subfile")));
var diff = new IndexDiff(tree, index);
diff.Diff();
Assert.AreEqual(2, diff.Added.Count);
Assert.IsTrue(diff.Added.Contains("file1"));
Assert.IsTrue(diff.Added.Contains("dir/subfile"));
Assert.AreEqual(0, diff.Changed.Count);
Assert.AreEqual(0, diff.Modified.Count);
Assert.AreEqual(0, diff.Removed.Count);
}
开发者ID:georgeck,项目名称:GitSharp,代码行数:19,代码来源:IndexDiffTest.cs
示例10: CanAddAFileToAMSysGitIndexWhereAFileIsAlreadyWaitingToBeCommitted
public void CanAddAFileToAMSysGitIndexWhereAFileIsAlreadyWaitingToBeCommitted()
{
//setup of .git directory
var resource =
new DirectoryInfo(Path.Combine(Path.Combine(Environment.CurrentDirectory, "Resources"),
"CorruptIndex"));
var tempRepository =
new DirectoryInfo(Path.Combine(trash.FullName, "CorruptIndex" + Path.GetRandomFileName()));
CopyDirectory(resource.FullName, tempRepository.FullName);
var repositoryPath = new DirectoryInfo(Path.Combine(tempRepository.FullName, ".git"));
Directory.Move(repositoryPath.FullName + "ted", repositoryPath.FullName);
var repository = new Repository(repositoryPath);
GitIndex index = repository.Index;
Assert.IsNotNull(index);
writeTrashFile(Path.Combine(repository.WorkingDirectory.FullName, "c.txt"), "c");
var tree = new Tree(repository);
index.add(repository.WorkingDirectory, new FileInfo(Path.Combine(repository.WorkingDirectory.FullName, "c.txt")));
var diff = new IndexDiff(tree, index);
diff.Diff();
index.write();
Assert.AreEqual(3, diff.Added.Count);
Assert.IsTrue(diff.Added.Contains("a.txt"));
Assert.IsTrue(diff.Added.Contains("b.txt"));
Assert.IsTrue(diff.Added.Contains("c.txt"));
Assert.AreEqual(0, diff.Changed.Count);
Assert.AreEqual(0, diff.Modified.Count);
Assert.AreEqual(0, diff.Removed.Count);
}
开发者ID:mdekrey,项目名称:GitSharp,代码行数:37,代码来源:CanReadMsysgitIndexFixture.cs
示例11: testTwoSuccessiveCommitsLinkedToHead
public void testTwoSuccessiveCommitsLinkedToHead()
{
var repo = createNewEmptyRepo();
var workingDirectory = repo.WorkingDirectory;
repo.Create();
var objectWriter = new ObjectWriter(repo);
FileInfo project1_a_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/A.txt"), "A.txt - first version\n");
FileInfo project1_b_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/B.txt"), "B.txt - first version\n");
var tree = new Tree(repo);
Tree projectTree = tree.AddTree("Project-1");
addFile(projectTree, project1_a_txt, objectWriter);
projectTree.Id = (objectWriter.WriteTree(projectTree));
addFile(projectTree, project1_b_txt, objectWriter);
projectTree.Id = (objectWriter.WriteTree(projectTree));
tree.Id = (objectWriter.WriteTree(tree));
var commit = new Commit(repo)
{
Author = new PersonIdent(jauthor, (0L), 60),
Committer = new PersonIdent(jcommitter, (0L), 60),
Message = "Foo\n\nMessage",
TreeEntry = tree
};
commit.Save();
var commitId = commit.CommitId;
FileInfo project1_b_v2_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/B.txt"), "B.txt - second version\n");
tree = new Tree(repo);
projectTree = tree.AddTree("Project-1");
addFile(projectTree, project1_a_txt, objectWriter);
projectTree.Id = (objectWriter.WriteTree(projectTree));
addFile(projectTree, project1_b_v2_txt, objectWriter);
projectTree.Id = (objectWriter.WriteTree(projectTree));
tree.Id = (objectWriter.WriteTree(tree));
commit = new Commit(repo)
{
Author = new PersonIdent(jauthor, (0L), 60),
Committer = new PersonIdent(jcommitter, (0L), 60),
Message = "Modified",
ParentIds = new[] { commitId },
TreeEntry = tree
};
commit.Save();
commitId = commit.CommitId;
RefUpdate lck = repo.UpdateRef("refs/heads/master");
Assert.IsNotNull(lck, "obtained lock");
lck.NewObjectId = commitId;
Assert.AreEqual(RefUpdate.RefUpdateResult.New, lck.ForceUpdate());
}
开发者ID:mdekrey,项目名称:GitSharp,代码行数:55,代码来源:T0003_Basic_Write.cs
示例12: HasParentBlob
private static bool HasParentBlob(Tree t, string name)
{
if (name.IndexOf('/') == -1)
{
return false;
}
string parent = name.Slice(0, name.LastIndexOf('/'));
return t.FindBlobMember(parent) != null || HasParentBlob(t, parent);
}
开发者ID:dev218,项目名称:GitSharp,代码行数:10,代码来源:WorkDirCheckout.cs
示例13: Refresh
public void Refresh()
{
cache.Clear();
if (!string.IsNullOrEmpty(initFolder))
{
try
{
this.repository = Repository.Open(initFolder);
if (this.repository != null)
{
var id = repository.Resolve("HEAD");
var commit = repository.MapCommit(id);
this.commitTree = (commit != null ? commit.TreeEntry : new Tree(repository));
this.index = repository.Index;
this.index.RereadIfNecessary();
//this.ignoreHandler = new IgnoreHandler(repository);
//this.watcher = new FileSystemWatcher(this.repository.WorkingDirectory.FullName);
}
}
catch (Exception ex)
{
}
}
}
开发者ID:cocytus,项目名称:Git-Source-Control-Provider,代码行数:25,代码来源:GitFileStatusTracker.cs
示例14: SymlinkTreeEntry
public SymlinkTreeEntry(Tree parent, ObjectId id, byte[] nameUTF8)
: base(parent, id, nameUTF8)
{
}
开发者ID:dev218,项目名称:GitSharp,代码行数:4,代码来源:SymlinkTreeEntry.cs
示例15: ReadTree
private void ReadTree(byte[] raw)
{
int rawSize = raw.Length;
int rawPtr = 0;
int nextIndex = 0;
while (rawPtr < rawSize)
{
while (rawPtr < rawSize && raw[rawPtr] != 0)
{
rawPtr++;
}
rawPtr++;
rawPtr += Constants.OBJECT_ID_LENGTH;
nextIndex++;
}
var temp = new TreeEntry[nextIndex];
rawPtr = 0;
nextIndex = 0;
while (rawPtr < rawSize)
{
int c = raw[rawPtr++];
if (c < '0' || c > '7')
{
throw new CorruptObjectException(Id, "invalid entry mode");
}
int mode = c - '0';
while (true)
{
c = raw[rawPtr++];
if (' ' == c) break;
if (c < '0' || c > '7')
{
throw new CorruptObjectException(Id, "invalid mode");
}
mode <<= 3;
mode += c - '0';
}
int nameLen = 0;
while (raw[rawPtr + nameLen] != 0)
{
nameLen++;
}
var name = new byte[nameLen];
Array.Copy(raw, rawPtr, name, 0, nameLen);
rawPtr += nameLen + 1;
ObjectId id = ObjectId.FromRaw(raw, rawPtr);
rawPtr += Constants.OBJECT_ID_LENGTH;
TreeEntry ent;
if (FileMode.RegularFile.Equals(mode))
{
ent = new FileTreeEntry(this, id, name, false);
}
else if (FileMode.ExecutableFile.Equals(mode))
{
ent = new FileTreeEntry(this, id, name, true);
}
else if (FileMode.Tree.Equals(mode))
{
ent = new Tree(this, id, name);
}
else if (FileMode.Symlink.Equals(mode))
{
ent = new SymlinkTreeEntry(this, id, name);
}
else if (FileMode.GitLink.Equals(mode))
{
ent = new GitLinkTreeEntry(this, id, name);
}
else
{
throw new CorruptObjectException(Id, "Invalid mode: " + Convert.ToString(mode, 8));
}
temp[nextIndex++] = ent;
}
_contents = temp;
}
开发者ID:dev218,项目名称:GitSharp,代码行数:90,代码来源:Tree.cs
示例16: test023_createCommitNonAnullii
public void test023_createCommitNonAnullii()
{
ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
var almostEmptyTree = new Tree(db);
almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
ObjectId almostEmptyTreeId = new ObjectWriter(db).WriteTree(almostEmptyTree);
var commit = new Commit(db)
{
TreeId = almostEmptyTreeId,
Author = new PersonIdent("Joe H\u00e4cker", "[email protected]", 4294967295000L, 60),
Committer = new PersonIdent("Joe Hacker", "[email protected]", 4294967295000L, 60),
Encoding = Constants.CHARSET,
Message = "\u00dcbergeeks"
};
ObjectId cid = new ObjectWriter(db).WriteCommit(commit);
Assert.AreEqual("4680908112778718f37e686cbebcc912730b3154", cid.Name);
}
开发者ID:mdekrey,项目名称:GitSharp,代码行数:19,代码来源:T0003_Basic_Write.cs
示例17: AddFile
/// <summary>
/// Adds a new or existing file with the specified name to this tree.
/// Trees are added if necessary as the name may contain '/':s.
/// </summary>
/// <param name="s"> an array containing the name </param>
/// <param name="offset"> when the name starts in the tree.
/// </param>
/// <returns>A <seealso cref="FileTreeEntry"/> for the added file.</returns>
/// <exception cref="IOException"></exception>
public FileTreeEntry AddFile(byte[] s, int offset)
{
int slash;
for (slash = offset; slash < s.Length && s[slash] != '/'; slash++)
{
// search for path component terminator
// [henon] body is empty by intention!
}
EnsureLoaded();
byte xlast = slash < s.Length ? (byte)'/' : (byte)0;
int p = BinarySearch(_contents, s, xlast, offset, slash);
if (p >= 0 && slash < s.Length && _contents[p] is Tree)
{
return ((Tree)_contents[p]).AddFile(s, slash + 1);
}
byte[] newName = SubString(s, offset, slash);
if (p >= 0)
{
throw new EntryExistsException(RawParseUtils.decode(newName));
}
if (slash < s.Length)
{
Tree t = new Tree(this, newName);
InsertEntry(p, t);
return t.AddFile(s, slash + 1);
}
FileTreeEntry f = new FileTreeEntry(this, null, newName, false);
InsertEntry(p, f);
return f;
}
开发者ID:dev218,项目名称:GitSharp,代码行数:44,代码来源:Tree.cs
示例18: Tree
/// <summary>
/// Construct a new Tree under another Tree
/// </summary>
/// <param name="parent"></param>
/// <param name="nameUTF8"></param>
public Tree(Tree parent, byte[] nameUTF8)
: base(parent, null, nameUTF8)
{
_db = parent.Repository;
_contents = EmptyTree;
}
开发者ID:dev218,项目名称:GitSharp,代码行数:11,代码来源:Tree.cs
示例19: 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
示例20: test024_createCommitNonAscii
public void test024_createCommitNonAscii()
{
ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
var almostEmptyTree = new Tree(db);
almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
ObjectId almostEmptyTreeId = new ObjectWriter(db).WriteTree(almostEmptyTree);
var commit = new Commit(db)
{
TreeId = almostEmptyTreeId,
Author = new PersonIdent("Joe H\u00e4cker", "[email protected]", 4294967295000L, 60),
Committer = new PersonIdent("Joe Hacker", "[email protected]", 4294967295000L, 60),
Encoding = Encoding.GetEncoding("ISO-8859-1"),
Message = "\u00dcbergeeks"
};
ObjectId cid = new ObjectWriter(db).WriteCommit(commit);
var s = new Inspector(db).Inspect(cid);
Assert.AreEqual("2979b39d385014b33287054b87f77bcb3ecb5ebf", cid.ToString());
}
开发者ID:mdekrey,项目名称:GitSharp,代码行数:18,代码来源:T0003_Basic_Write.cs
注:本文中的GitSharp.Core.Tree类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论