本文整理汇总了C#中TreeWalk类的典型用法代码示例。如果您正苦于以下问题:C# TreeWalk类的具体用法?C# TreeWalk怎么用?C# TreeWalk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeWalk类属于命名空间,在下文中一共展示了TreeWalk类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:kenji-tan,项目名称:ngit,代码行数:10,代码来源:SubmoduleWalk.cs
示例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);
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:32,代码来源:PathSuffixFilterTestCase.cs
示例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);
}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:25,代码来源:RevCommitExtensions.cs
示例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());
}
开发者ID:red-gate,项目名称:ngit,代码行数:25,代码来源:FileTreeIteratorTest.cs
示例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);
}
开发者ID:shoff,项目名称:ngit,代码行数:26,代码来源:NameConflictTreeWalkTest.cs
示例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());
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:8,代码来源:DirCacheIteratorTest.cs
示例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);
}
开发者ID:shoff,项目名称:ngit,代码行数:9,代码来源:PostOrderTreeWalkTest.cs
示例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));
}
开发者ID:shoff,项目名称:ngit,代码行数:9,代码来源:NotTreeFilterTest.cs
示例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());
}
开发者ID:spraints,项目名称:GitSharp,代码行数:10,代码来源:DirCacheIteratorTest.cs
示例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;
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:10,代码来源:SkipWorkTreeFilter.cs
示例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 ());
}
开发者ID:joaonunesk,项目名称:monodevelop,代码行数:13,代码来源:GitUtil.cs
示例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);
}
开发者ID:shoff,项目名称:ngit,代码行数:12,代码来源:PostOrderTreeWalkTest.cs
示例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;
}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:16,代码来源:GitUtil.cs
示例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 });
}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:20,代码来源:GitUtil.cs
示例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));
}
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:43,代码来源:DirCacheBuilderIteratorTest.cs
示例16: ShouldListAddedFileInInitialCommit
public virtual void ShouldListAddedFileInInitialCommit()
{
// given
WriteTrashFile("a.txt", "content");
Git git = new Git(db);
git.Add().AddFilepattern("a.txt").Call();
RevCommit c = git.Commit().SetMessage("initial commit").Call();
// when
TreeWalk walk = new TreeWalk(db);
walk.AddTree(new EmptyTreeIterator());
walk.AddTree(c.Tree);
IList<DiffEntry> result = DiffEntry.Scan(walk);
// then
Assert.IsNotNull (result);
Assert.AreEqual(1, result.Count);
DiffEntry entry = result[0];
Assert.AreEqual(entry.GetChangeType(), DiffEntry.ChangeType.ADD);
Assert.AreEqual(entry.GetNewPath(), "a.txt");
Assert.AreEqual(entry.GetOldPath(), DiffEntry.DEV_NULL);
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:20,代码来源:DiffEntryTest.cs
示例17: GetFileDiffs
public IEnumerable<FileDiff> GetFileDiffs(string newHash, string oldHash)
{
NGit.Repository repo = this.git.GetRepository();
ObjectId newCommit = repo.Resolve(newHash + "^{tree}");
ObjectId oldCommit = repo.Resolve(oldHash + "^{tree}");
var walk = new TreeWalk(repo) { Recursive = true };
walk.AddTree(oldCommit);
walk.AddTree(newCommit);
IEnumerable<DiffEntry> entries = DiffEntry.Scan(walk);
var diffs = entries.Where(diff => diff.GetNewId().Name != diff.GetOldId().Name);
return from diffEntry in diffs
let diffType = ToDiffType(diffEntry.GetChangeType())
let path = diffType == DiffType.Delete ? diffEntry.GetOldPath() : diffEntry.GetNewPath()
select new FileDiff(path, diffType);
}
开发者ID:dineshkummarc,项目名称:Ometh,代码行数:20,代码来源:Repository.cs
示例18: GetFileContent
public static string GetFileContent(this RevCommit commit, string path, Repository repository)
{
var treeWalk = new TreeWalk(repository) {Recursive = true, Filter = PathFilter.Create(path)};
treeWalk.AddTree(commit.Tree);
if (!treeWalk.Next())
{
return string.Empty;
}
var objectId = treeWalk.GetObjectId(0);
var loader = repository.Open(objectId);
using (var stream = loader.OpenStream())
{
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
}
开发者ID:FarReachJason,项目名称:Target-Process-Plugins,代码行数:21,代码来源:RevCommitExtensions.cs
示例19: testTreeWalk_LsFiles
public void testTreeWalk_LsFiles()
{
global::GitSharp.Core.Repository db = createBareRepository();
List<CGitIndexRecord> ls = ReadLsFiles();
var dc = new DirCache(_index);
Assert.AreEqual(0, dc.getEntryCount());
dc.read();
Assert.AreEqual(ls.Count, dc.getEntryCount());
var rItr = ls.GetEnumerator();
var tw = new TreeWalk(db);
tw.reset();
tw.Recursive = true;
tw.addTree(new DirCacheIterator(dc));
while (rItr.MoveNext())
{
Assert.IsTrue(tw.next());
var dcItr = tw.getTree<DirCacheIterator>(0, typeof(DirCacheIterator));
Assert.IsNotNull(dcItr);
AssertAreEqual(rItr.Current, dcItr.getDirCacheEntry());
}
}
开发者ID:dev218,项目名称:GitSharp,代码行数:22,代码来源:DirCacheCGitCompatabilityTest.cs
示例20: AssertWorkDir
/// <exception cref="NGit.Errors.CorruptObjectException"></exception>
/// <exception cref="System.IO.IOException"></exception>
public virtual void AssertWorkDir(Dictionary<string, string> i)
{
TreeWalk walk = new TreeWalk(db);
walk.Recursive = true;
walk.AddTree(new FileTreeIterator(db));
string expectedValue;
string path;
int nrFiles = 0;
FileTreeIterator ft;
while (walk.Next())
{
ft = walk.GetTree<FileTreeIterator>(0);
path = ft.EntryPathString;
expectedValue = i.Get(path);
NUnit.Framework.Assert.IsNotNull(expectedValue, "found unexpected file for path "
+ path + " in workdir");
FilePath file = new FilePath(db.WorkTree, path);
NUnit.Framework.Assert.IsTrue(file.Exists());
if (file.IsFile())
{
FileInputStream @is = new FileInputStream(file);
byte[] buffer = new byte[(int)file.Length()];
int offset = 0;
int numRead = 0;
while (offset < buffer.Length && (numRead = @is.Read(buffer, offset, buffer.Length
- offset)) >= 0)
{
offset += numRead;
}
@is.Close();
CollectionAssert.AreEqual (buffer, Sharpen.Runtime.GetBytesForString(i.Get(path)),
"unexpected content for path " + path + " in workDir. ");
nrFiles++;
}
}
NUnit.Framework.Assert.AreEqual(i.Count, nrFiles, "WorkDir has not the right size."
);
}
开发者ID:JamesChan,项目名称:ngit,代码行数:41,代码来源:DirCacheCheckoutTest.cs
注:本文中的TreeWalk类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论