本文整理汇总了C#中TreeWalk类的典型用法代码示例。如果您正苦于以下问题:C# TreeWalk类的具体用法?C# TreeWalk怎么用?C# TreeWalk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeWalk类属于命名空间,在下文中一共展示了TreeWalk类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubmoduleWalk
/// <summary>Create submodule generator</summary>
/// <param name="repository"></param>
/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
public SubmoduleWalk(Repository repository)
{
this.repository = repository;
repoConfig = repository.GetConfig();
walk = new TreeWalk(repository);
walk.Recursive = true;
}
示例2: TestNonRecursiveFiltering
public virtual void TestNonRecursiveFiltering()
{
ObjectInserter odi = db.NewObjectInserter();
ObjectId aSth = odi.Insert(Constants.OBJ_BLOB, Sharpen.Runtime.GetBytesForString(
"a.sth"));
ObjectId aTxt = odi.Insert(Constants.OBJ_BLOB, Sharpen.Runtime.GetBytesForString(
"a.txt"));
DirCache dc = db.ReadDirCache();
DirCacheBuilder builder = dc.Builder();
DirCacheEntry aSthEntry = new DirCacheEntry("a.sth");
aSthEntry.FileMode = FileMode.REGULAR_FILE;
aSthEntry.SetObjectId(aSth);
DirCacheEntry aTxtEntry = new DirCacheEntry("a.txt");
aTxtEntry.FileMode = FileMode.REGULAR_FILE;
aTxtEntry.SetObjectId(aTxt);
builder.Add(aSthEntry);
builder.Add(aTxtEntry);
builder.Finish();
ObjectId treeId = dc.WriteTree(odi);
odi.Flush();
TreeWalk tw = new TreeWalk(db);
tw.Filter = PathSuffixFilter.Create(".txt");
tw.AddTree(treeId);
IList<string> paths = new List<string>();
while (tw.Next())
{
paths.AddItem(tw.PathString);
}
IList<string> expected = new List<string>();
expected.AddItem("a.txt");
NUnit.Framework.Assert.AreEqual(expected, paths);
}
示例3: GetDiffEntries
private static IEnumerable<DiffEntry> GetDiffEntries(this RevCommit commit, Repository repository)
{
var tw = new TreeWalk(repository) { Recursive = true };
if (commit.ParentCount > 0)
{
if (commit.Parents.First().Tree != null)
{
tw.AddTree(commit.Parents.First().Tree);
}
else
{
tw.AddTree(new EmptyTreeIterator());
}
}
else
{
tw.AddTree(new EmptyTreeIterator());
}
tw.Filter = TreeFilter.ANY_DIFF;
tw.AddTree(commit.Tree);
return DiffEntry.Scan(tw);
}
示例4: IdOffset
public virtual void IdOffset()
{
Git git = new Git(db);
WriteTrashFile("fileAinfsonly", "A");
FilePath fileBinindex = WriteTrashFile("fileBinindex", "B");
FsTick(fileBinindex);
git.Add().AddFilepattern("fileBinindex").Call();
WriteTrashFile("fileCinfsonly", "C");
TreeWalk tw = new TreeWalk(db);
DirCacheIterator indexIter = new DirCacheIterator(db.ReadDirCache());
FileTreeIterator workTreeIter = new FileTreeIterator(db);
tw.AddTree(indexIter);
tw.AddTree(workTreeIter);
workTreeIter.SetDirCacheIterator(tw, 0);
AssertEntry("d46c305e85b630558ee19cc47e73d2e5c8c64cdc", "a,", tw);
AssertEntry("58ee403f98538ec02409538b3f80adf610accdec", "a,b", tw);
AssertEntry("0000000000000000000000000000000000000000", "a", tw);
AssertEntry("b8d30ff397626f0f1d3538d66067edf865e201d6", "a0b", tw);
// The reason for adding this test. Check that the id is correct for
// mixed
AssertEntry("8c7e5a667f1b771847fe88c01c3de34413a1b220", "fileAinfsonly", tw);
AssertEntry("7371f47a6f8bd23a8fa1a8b2a9479cdd76380e54", "fileBinindex", tw);
AssertEntry("96d80cd6c4e7158dbebd0849f4fb7ce513e5828c", "fileCinfsonly", tw);
NUnit.Framework.Assert.IsFalse(tw.Next());
}
示例5: TestNoDF_NoGap
public virtual void TestNoDF_NoGap()
{
DirCache tree0 = db.ReadDirCache();
DirCache tree1 = db.ReadDirCache();
{
DirCacheBuilder b0 = tree0.Builder();
DirCacheBuilder b1 = tree1.Builder();
b0.Add(MakeEntry("a", REGULAR_FILE));
b0.Add(MakeEntry("a.b", EXECUTABLE_FILE));
b1.Add(MakeEntry("a/b", REGULAR_FILE));
b0.Add(MakeEntry("a0b", SYMLINK));
b0.Finish();
b1.Finish();
NUnit.Framework.Assert.AreEqual(3, tree0.GetEntryCount());
NUnit.Framework.Assert.AreEqual(1, tree1.GetEntryCount());
}
TreeWalk tw = new TreeWalk(db);
tw.AddTree(new DirCacheIterator(tree0));
tw.AddTree(new DirCacheIterator(tree1));
AssertModes("a", REGULAR_FILE, MISSING, tw);
AssertModes("a.b", EXECUTABLE_FILE, MISSING, tw);
AssertModes("a", MISSING, TREE, tw);
tw.EnterSubtree();
AssertModes("a/b", MISSING, REGULAR_FILE, tw);
AssertModes("a0b", SYMLINK, MISSING, tw);
}
示例6: TestEmptyTree_WithTreeWalk
public virtual void TestEmptyTree_WithTreeWalk()
{
DirCache dc = DirCache.NewInCore();
NUnit.Framework.Assert.AreEqual(0, dc.GetEntryCount());
TreeWalk tw = new TreeWalk(db);
tw.AddTree(new DirCacheIterator(dc));
NUnit.Framework.Assert.IsFalse(tw.Next());
}
示例7: TestInitialize_TogglePostOrder
public virtual void TestInitialize_TogglePostOrder()
{
TreeWalk tw = new TreeWalk(db);
NUnit.Framework.Assert.IsFalse(tw.PostOrderTraversal);
tw.PostOrderTraversal = true;
NUnit.Framework.Assert.IsTrue(tw.PostOrderTraversal);
tw.PostOrderTraversal = false;
NUnit.Framework.Assert.IsFalse(tw.PostOrderTraversal);
}
示例8: TestWrap
public virtual void TestWrap()
{
TreeWalk tw = new TreeWalk(db);
TreeFilter a = TreeFilter.ALL;
TreeFilter n = NotTreeFilter.Create(a);
NUnit.Framework.Assert.IsNotNull(n);
NUnit.Framework.Assert.IsTrue(a.Include(tw));
NUnit.Framework.Assert.IsFalse(n.Include(tw));
}
示例9: testEmptyTree_WithTreeWalk
public void testEmptyTree_WithTreeWalk()
{
DirCache dc = DirCache.read(db);
Assert.AreEqual(0, dc.getEntryCount());
var tw = new TreeWalk(db);
tw.reset();
tw.addTree(new DirCacheIterator(dc));
Assert.IsFalse(tw.next());
}
示例10: Include
public override bool Include(TreeWalk walker)
{
DirCacheIterator i = walker.GetTree<DirCacheIterator>(treeIdx);
if (i == null)
{
return true;
}
DirCacheEntry e = i.GetDirCacheEntry();
return e == null || !e.IsSkipWorkTree;
}
示例11: GetCommitChanges
/// <summary>
/// Returns a list of files that have changed in a commit
/// </summary>
public static IEnumerable<Change> GetCommitChanges (NGit.Repository repo, RevCommit commit)
{
var treeIds = new[] { commit.Tree.Id }.Concat (commit.Parents.Select (c => c.Tree.Id)).ToArray ();
var walk = new TreeWalk (repo);
walk.Reset (treeIds);
walk.Recursive = true;
walk.Filter = AndTreeFilter.Create (AndTreeFilter.ANY_DIFF, AndTreeFilter.ALL);
return CalculateCommitDiff (repo, walk, new[] { commit }.Concat (commit.Parents).ToArray ());
}
示例12: TestResetDoesNotAffectPostOrder
public virtual void TestResetDoesNotAffectPostOrder()
{
TreeWalk tw = new TreeWalk(db);
tw.PostOrderTraversal = true;
NUnit.Framework.Assert.IsTrue(tw.PostOrderTraversal);
tw.Reset();
NUnit.Framework.Assert.IsTrue(tw.PostOrderTraversal);
tw.PostOrderTraversal = false;
NUnit.Framework.Assert.IsFalse(tw.PostOrderTraversal);
tw.Reset();
NUnit.Framework.Assert.IsFalse(tw.PostOrderTraversal);
}
示例13: GetConflictedFiles
public static List<string> GetConflictedFiles (NGit.Repository repo)
{
List<string> list = new List<string> ();
TreeWalk treeWalk = new TreeWalk (repo);
treeWalk.Reset ();
treeWalk.Recursive = true;
DirCache dc = repo.ReadDirCache ();
treeWalk.AddTree (new DirCacheIterator (dc));
while (treeWalk.Next()) {
DirCacheIterator dirCacheIterator = treeWalk.GetTree<DirCacheIterator>(0);
var ce = dirCacheIterator.GetDirCacheEntry ();
if (ce != null && ce.Stage == 1)
list.Add (ce.PathString);
}
return list;
}
示例14: CompareCommits
/// <summary>
/// Compares two commits and returns a list of files that have changed
/// </summary>
public static IEnumerable<Change> CompareCommits (NGit.Repository repo, RevCommit reference, RevCommit compared)
{
var changes = new List<Change>();
if (reference == null && compared == null)
return changes;
ObjectId refTree = (reference != null ? reference.Tree.Id : ObjectId.ZeroId);
ObjectId comparedTree = (compared != null ? compared.Tree.Id : ObjectId.ZeroId);
var walk = new TreeWalk (repo);
if (reference == null || compared == null)
walk.Reset ((reference ?? compared).Tree.Id);
else
walk.Reset (new AnyObjectId[] {refTree, comparedTree});
walk.Recursive = true;
walk.Filter = AndTreeFilter.Create(TreeFilter.ANY_DIFF, TreeFilter.ALL);
return CalculateCommitDiff (repo, walk, new[] { reference, compared });
}
示例15: TestPathFilterGroup_DoesNotSkipTail
public virtual void TestPathFilterGroup_DoesNotSkipTail()
{
DirCache dc = db.ReadDirCache();
FileMode mode = FileMode.REGULAR_FILE;
string[] paths = new string[] { "a.", "a/b", "a/c", "a/d", "a0b" };
DirCacheEntry[] ents = new DirCacheEntry[paths.Length];
for (int i = 0; i < paths.Length; i++)
{
ents[i] = new DirCacheEntry(paths[i]);
ents[i].FileMode = mode;
}
{
DirCacheBuilder b = dc.Builder();
for (int i_1 = 0; i_1 < ents.Length; i_1++)
{
b.Add(ents[i_1]);
}
b.Finish();
}
int expIdx = 2;
DirCacheBuilder b_1 = dc.Builder();
TreeWalk tw = new TreeWalk(db);
tw.AddTree(new DirCacheBuildIterator(b_1));
tw.Recursive = true;
tw.Filter = PathFilterGroup.CreateFromStrings(Collections.Singleton(paths[expIdx]
));
NUnit.Framework.Assert.IsTrue(tw.Next(), "found " + paths[expIdx]);
DirCacheIterator c = tw.GetTree<DirCacheIterator>(0);
NUnit.Framework.Assert.IsNotNull(c);
NUnit.Framework.Assert.AreEqual(expIdx, c.ptr);
NUnit.Framework.Assert.AreSame(ents[expIdx], c.GetDirCacheEntry());
NUnit.Framework.Assert.AreEqual(paths[expIdx], tw.PathString);
NUnit.Framework.Assert.AreEqual(mode.GetBits(), tw.GetRawMode(0));
NUnit.Framework.Assert.AreSame(mode, tw.GetFileMode(0));
b_1.Add(c.GetDirCacheEntry());
NUnit.Framework.Assert.IsFalse(tw.Next(), "no more entries");
b_1.Finish();
NUnit.Framework.Assert.AreEqual(ents.Length, dc.GetEntryCount());
for (int i_2 = 0; i_2 < ents.Length; i_2++)
{
NUnit.Framework.Assert.AreSame(ents[i_2], dc.GetEntry(i_2));
}
}