当前位置: 首页>>代码示例>>C#>>正文


C# Treewalk.FileTreeIterator类代码示例

本文整理汇总了C#中NGit.Treewalk.FileTreeIterator的典型用法代码示例。如果您正苦于以下问题:C# FileTreeIterator类的具体用法?C# FileTreeIterator怎么用?C# FileTreeIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileTreeIterator类属于NGit.Treewalk命名空间,在下文中一共展示了FileTreeIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CommitDiffs

        public void CommitDiffs()
        {
            Assert.IsNull(nGit.head());
            nGit.file_Create("testFile.txt", "some Text");
            "head 1 :{0}".info(nGit.head().info());
            nGit.add_and_Commit_using_Status();
            "head 2 :{0}".info(nGit.head().info());
            nGit.file_Write("testFile.txt", "some Text changed");
            nGit.add_and_Commit_using_Status();
            var head3 = nGit.head();
            "head 3 :{0}".info(head3.info());

            var workingTreeIt = new FileTreeIterator(nGit.Repository);

            var indexDiff = new IndexDiff(nGit.Repository, Constants.HEAD, workingTreeIt);
            indexDiff.Diff();
            var result = new Status(indexDiff);
            "RESULT: {0}".info(result);

            /*OutputStream outputStream = "Sharpen.dll".assembly().type("ByteArrayOutputStream").ctor(new object[0]).cast<OutputStream>();

            var diffFormater = new DiffFormatter(outputStream);
            diffFormater.SetRepository(nGit.Repository);
            //diffFormater.Format(refLog.GetNewId(), refLog.GetOldId());
            diffFormater.Format(refLog.GetOldId(), refLog.GetNewId());*/
        }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:26,代码来源:Test_Diff.cs

示例2: 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);
 }
开发者ID:ashmind,项目名称:ngit,代码行数:20,代码来源:IndexDiffTest.cs

示例3: TestDiff

		public virtual void TestDiff()
		{
			Write(new FilePath(db.Directory.GetParent(), "test.txt"), "test");
			FilePath folder = new FilePath(db.Directory.GetParent(), "folder");
			folder.Mkdir();
			Write(new FilePath(folder, "folder.txt"), "folder");
			Git git = new Git(db);
			git.Add().AddFilepattern(".").Call();
			git.Commit().SetMessage("Initial commit").Call();
			Write(new FilePath(folder, "folder.txt"), "folder change");
			PatchIdDiffFormatter df = new PatchIdDiffFormatter();
			df.SetRepository(db);
			df.SetPathFilter(PathFilter.Create("folder"));
			DirCacheIterator oldTree = new DirCacheIterator(db.ReadDirCache());
			FileTreeIterator newTree = new FileTreeIterator(db);
			df.Format(oldTree, newTree);
			df.Flush();
			NUnit.Framework.Assert.AreEqual("1ff64e0f9333e9b81967c3e8d7a81362b14d5441", df.GetCalulatedPatchId
				().Name);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:20,代码来源:PatchIdDiffFormatterTest.cs

示例4: 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()
         );
 }
开发者ID:sharwell,项目名称:ngit,代码行数:23,代码来源:IndexDiffTest.cs

示例5: SubmoduleNestedWithHeadMatchingIndex

		public virtual void SubmoduleNestedWithHeadMatchingIndex()
		{
			Git git = new Git(db);
			WriteTrashFile("file.txt", "content");
			git.Add().AddFilepattern("file.txt").Call();
			RevCommit id = git.Commit().SetMessage("create file").Call();
			string path = "sub/dir1/dir2";
			DirCache cache = db.LockDirCache();
			DirCacheEditor editor = cache.Editor();
			editor.Add(new _PathEdit_412(id, path));
			editor.Commit();
			Git.CloneRepository().SetURI(db.Directory.ToURI().ToString()).SetDirectory(new FilePath
				(db.WorkTree, path)).Call().GetRepository().Close();
			TreeWalk walk = new TreeWalk(db);
			DirCacheIterator indexIter = new DirCacheIterator(db.ReadDirCache());
			FileTreeIterator workTreeIter = new FileTreeIterator(db);
			walk.AddTree(indexIter);
			walk.AddTree(workTreeIter);
			walk.Filter = PathFilter.Create(path);
			NUnit.Framework.Assert.IsTrue(walk.Next());
			NUnit.Framework.Assert.IsTrue(indexIter.IdEqual(workTreeIter));
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:22,代码来源:FileTreeIteratorTest.cs

示例6: TestIsModifiedFileSmudged

		public virtual void TestIsModifiedFileSmudged()
		{
			FilePath f = WriteTrashFile("file", "content");
			Git git = new Git(db);
			// The idea of this test is to check the smudged handling
			// Hopefully fsTick will make sure our entry gets smudged
			FsTick(f);
			WriteTrashFile("file", "content");
			git.Add().AddFilepattern("file").Call();
			WriteTrashFile("file", "conten2");
			DirCacheEntry dce = db.ReadDirCache().GetEntry("file");
			FileTreeIterator fti = new FileTreeIterator(trash, db.FileSystem, ((FileBasedConfig
				)db.GetConfig()).Get(WorkingTreeOptions.KEY));
			while (!fti.EntryPathString.Equals("file"))
			{
				fti.Next(1);
			}
			// If the fsTick trick does not work we could skip the compareMetaData
			// test and hope that we are usually testing the intended code path.
			NUnit.Framework.Assert.AreEqual(WorkingTreeIterator.MetadataDiff.SMUDGED, fti.CompareMetadata
				(dce));
			NUnit.Framework.Assert.IsTrue(fti.IsModified(dce, false));
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:23,代码来源:FileTreeIteratorTest.cs

示例7: SubmoduleWithNoHead

		public virtual void SubmoduleWithNoHead()
		{
			Git git = new Git(db);
			WriteTrashFile("file.txt", "content");
			git.Add().AddFilepattern("file.txt").Call();
			RevCommit id = git.Commit().SetMessage("create file").Call();
			string path = "sub";
			DirCache cache = db.LockDirCache();
			DirCacheEditor editor = cache.Editor();
			editor.Add(new _PathEdit_345(id, path));
			editor.Commit();
			NUnit.Framework.Assert.IsNotNull(Git.Init().SetDirectory(new FilePath(db.WorkTree
				, path)).Call().GetRepository());
			TreeWalk walk = new TreeWalk(db);
			DirCacheIterator indexIter = new DirCacheIterator(db.ReadDirCache());
			FileTreeIterator workTreeIter = new FileTreeIterator(db);
			walk.AddTree(indexIter);
			walk.AddTree(workTreeIter);
			walk.Filter = PathFilter.Create(path);
			NUnit.Framework.Assert.IsTrue(walk.Next());
			NUnit.Framework.Assert.IsFalse(indexIter.IdEqual(workTreeIter));
			NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, workTreeIter.EntryObjectId);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:23,代码来源:FileTreeIteratorTest.cs

示例8: TestConflictingDeletedAndModified

		public virtual void TestConflictingDeletedAndModified()
		{
			Git git = new Git(db);
			WriteTrashFile("a", "1\na\n3\n");
			WriteTrashFile("b", "1\nb\n3\n");
			git.Add().AddFilepattern("a").AddFilepattern("b").Call();
			RevCommit initialCommit = git.Commit().SetMessage("initial").Call();
			// create side branch and delete "a"
			CreateBranch(initialCommit, "refs/heads/side");
			CheckoutBranch("refs/heads/side");
			git.Rm().AddFilepattern("a").Call();
			RevCommit secondCommit = git.Commit().SetMessage("side").Call();
			// update a on master to generate conflict
			CheckoutBranch("refs/heads/master");
			WriteTrashFile("a", "1\na(main)\n3\n");
			git.Add().AddFilepattern("a").Call();
			git.Commit().SetMessage("main").Call();
			// merge side with master
			MergeCommandResult result = git.Merge().Include(secondCommit.Id).SetStrategy(MergeStrategy
				.RESOLVE).Call();
			NUnit.Framework.Assert.AreEqual(MergeStatus.CONFLICTING, result.GetMergeStatus());
			FileTreeIterator iterator = new FileTreeIterator(db);
			IndexDiff diff = new IndexDiff(db, Constants.HEAD, iterator);
			diff.Diff();
			NUnit.Framework.Assert.AreEqual("[]", new TreeSet<string>(diff.GetChanged()).ToString
				());
			NUnit.Framework.Assert.AreEqual("[]", diff.GetAdded().ToString());
			NUnit.Framework.Assert.AreEqual("[]", diff.GetRemoved().ToString());
			NUnit.Framework.Assert.AreEqual("[]", diff.GetMissing().ToString());
			NUnit.Framework.Assert.AreEqual("[]", diff.GetModified().ToString());
			NUnit.Framework.Assert.AreEqual("[a]", diff.GetConflicting().ToString());
		}
开发者ID:shoff,项目名称:ngit,代码行数:32,代码来源:IndexDiffTest.cs

示例9: TestIsModifiedSymlink

		public virtual void TestIsModifiedSymlink()
		{
			FilePath f = WriteTrashFile("symlink", "content");
			Git git = new Git(db);
			git.Add().AddFilepattern("symlink").Call();
			git.Commit().SetMessage("commit").Call();
			// Modify previously committed DirCacheEntry and write it back to disk
			DirCacheEntry dce = db.ReadDirCache().GetEntry("symlink");
			dce.FileMode = FileMode.SYMLINK;
			DirCacheCheckout.CheckoutEntry(db, f, dce);
			FileTreeIterator fti = new FileTreeIterator(trash, db.FileSystem, ((FileBasedConfig
				)db.GetConfig()).Get(WorkingTreeOptions.KEY));
			while (!fti.EntryPathString.Equals("symlink"))
			{
				fti.Next(1);
			}
			NUnit.Framework.Assert.IsFalse(fti.IsModified(dce, false));
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:18,代码来源:FileTreeIteratorTest.cs

示例10: TestConflictingFromMultipleCreations

 public virtual void TestConflictingFromMultipleCreations()
 {
     Git git = new Git(db);
     WriteTrashFile("a", "1\na\n3\n");
     git.Add().AddFilepattern("a").Call();
     RevCommit initialCommit = git.Commit().SetMessage("initial").Call();
     CreateBranch(initialCommit, "refs/heads/side");
     CheckoutBranch("refs/heads/side");
     WriteTrashFile("b", "1\nb(side)\n3\n");
     git.Add().AddFilepattern("b").Call();
     RevCommit secondCommit = git.Commit().SetMessage("side").Call();
     CheckoutBranch("refs/heads/master");
     WriteTrashFile("b", "1\nb(main)\n3\n");
     git.Add().AddFilepattern("b").Call();
     git.Commit().SetMessage("main").Call();
     MergeCommandResult result = git.Merge().Include(secondCommit.Id).SetStrategy(MergeStrategy
         .RESOLVE).Call();
     NUnit.Framework.Assert.AreEqual(MergeStatus.CONFLICTING, result.GetMergeStatus());
     FileTreeIterator iterator = new FileTreeIterator(db);
     IndexDiff diff = new IndexDiff(db, Constants.HEAD, iterator);
     diff.Diff();
     NUnit.Framework.Assert.AreEqual("[]", new TreeSet<string>(diff.GetChanged()).ToString
         ());
     NUnit.Framework.CollectionAssert.IsEmpty(diff.GetAdded());
     NUnit.Framework.CollectionAssert.IsEmpty(diff.GetRemoved());
     NUnit.Framework.CollectionAssert.IsEmpty(diff.GetMissing());
     NUnit.Framework.CollectionAssert.IsEmpty(diff.GetModified());
     NUnit.Framework.Assert.AreEqual(1, diff.GetConflicting().Count());
     NUnit.Framework.Assert.AreEqual("b", diff.GetConflicting().First());
     NUnit.Framework.CollectionAssert.IsEmpty(diff.GetUntrackedFolders()
         );
 }
开发者ID:sharwell,项目名称:ngit,代码行数:32,代码来源:IndexDiffTest.cs

示例11: GetDirectoryFiles

		IEnumerable<string> GetDirectoryFiles (DirectoryInfo dir)
		{
			FileTreeIterator iter = new FileTreeIterator (dir.FullName, RootRepository.FileSystem, WorkingTreeOptions.KEY.Parse(RootRepository.GetConfig()));
			while (!iter.Eof) {
				var file = iter.GetEntryFile ();
				if (file != null && !iter.IsEntryIgnored ())
					yield return file.GetPath ();
				iter.Next (1);
			}
		}
开发者ID:kthguru,项目名称:monodevelop,代码行数:10,代码来源:GitRepository.cs

示例12: TestEmptyIfRootDoesNotExist

		public virtual void TestEmptyIfRootDoesNotExist()
		{
			FilePath r = new FilePath(trash, "not-existing-file");
			NUnit.Framework.Assert.IsFalse(r.Exists());
			FileTreeIterator fti = new FileTreeIterator(r, db.FileSystem, ((FileBasedConfig)db
				.GetConfig()).Get(WorkingTreeOptions.KEY));
			NUnit.Framework.Assert.IsTrue(fti.First);
			NUnit.Framework.Assert.IsTrue(fti.Eof);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:9,代码来源:FileTreeIteratorTest.cs

示例13: RaiseNotifyFromDiff

        protected void RaiseNotifyFromDiff(Repository repository)
        {
            if (repository == null)
                throw new ArgumentNullException("repository");
            var workingTreeIt = new FileTreeIterator(repository);
            var diff = new IndexDiff(repository, Constants.HEAD, workingTreeIt);

            diff.Diff();

            RaiseNotifyFromDiff(repository, diff.GetAdded(), GitNotifyAction.UpdateAdd);
            RaiseNotifyFromDiff(repository, diff.GetAssumeUnchanged(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetChanged(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetConflicting(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetMissing(), GitNotifyAction.UpdateDeleted);
            RaiseNotifyFromDiff(repository, diff.GetModified(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetRemoved(), GitNotifyAction.UpdateDeleted);
            RaiseNotifyFromDiff(repository, diff.GetUntracked(), GitNotifyAction.UpdateUpdate);
        }
开发者ID:pvginkel,项目名称:VisualGit,代码行数:18,代码来源:GitCommand.cs

示例14: TestUnchangedComplex

 public virtual void TestUnchangedComplex()
 {
     Git git = new Git(db);
     WriteTrashFile("a.b", "a.b");
     WriteTrashFile("a.c", "a.c");
     WriteTrashFile("a/b.b/b", "a/b.b/b");
     WriteTrashFile("a/b", "a/b");
     WriteTrashFile("a/c", "a/c");
     WriteTrashFile("a=c", "a=c");
     WriteTrashFile("a=d", "a=d");
     git.Add().AddFilepattern("a.b").AddFilepattern("a.c").AddFilepattern("a/b.b/b").AddFilepattern
         ("a/b").AddFilepattern("a/c").AddFilepattern("a=c").AddFilepattern("a=d").Call();
     Tree tree = new Tree(db);
     // got the hash id'd from the data using echo -n a.b|git hash-object -t blob --stdin
     tree.AddFile("a.b").SetId(ObjectId.FromString("f6f28df96c2b40c951164286e08be7c38ec74851"
         ));
     tree.AddFile("a.c").SetId(ObjectId.FromString("6bc0e647512d2a0bef4f26111e484dc87df7f5ca"
         ));
     tree.AddFile("a/b.b/b").SetId(ObjectId.FromString("8d840bd4e2f3a48ff417c8e927d94996849933fd"
         ));
     tree.AddFile("a/b").SetId(ObjectId.FromString("db89c972fc57862eae378f45b74aca228037d415"
         ));
     tree.AddFile("a/c").SetId(ObjectId.FromString("52ad142a008aeb39694bafff8e8f1be75ed7f007"
         ));
     tree.AddFile("a=c").SetId(ObjectId.FromString("06022365ddbd7fb126761319633bf73517770714"
         ));
     tree.AddFile("a=d").SetId(ObjectId.FromString("fa6414df3da87840700e9eeb7fc261dd77ccd5c2"
         ));
     Tree tree3 = (Tree)tree.FindTreeMember("a/b.b");
     tree3.SetId(InsertTree(tree3));
     Tree tree2 = (Tree)tree.FindTreeMember("a");
     tree2.SetId(InsertTree(tree2));
     tree.SetId(InsertTree(tree));
     FileTreeIterator iterator = new FileTreeIterator(db);
     IndexDiff diff = new IndexDiff(db, tree.GetId(), iterator);
     diff.Diff();
     NUnit.Framework.Assert.AreEqual(0, diff.GetChanged().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetAdded().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetRemoved().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetMissing().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetModified().Count);
     NUnit.Framework.CollectionAssert.AreEquivalent(Collections<string>.EMPTY_SET, diff.GetUntrackedFolders()
         );
 }
开发者ID:sharwell,项目名称:ngit,代码行数:44,代码来源:IndexDiffTest.cs

示例15: TestUnchangedSimple

 public virtual void TestUnchangedSimple()
 {
     WriteTrashFile("a.b", "a.b");
     WriteTrashFile("a.c", "a.c");
     WriteTrashFile("a=c", "a=c");
     WriteTrashFile("a=d", "a=d");
     Git git = new Git(db);
     git.Add().AddFilepattern("a.b").Call();
     git.Add().AddFilepattern("a.c").Call();
     git.Add().AddFilepattern("a=c").Call();
     git.Add().AddFilepattern("a=d").Call();
     Tree tree = new Tree(db);
     // got the hash id'd from the data using echo -n a.b|git hash-object -t blob --stdin
     tree.AddFile("a.b").SetId(ObjectId.FromString("f6f28df96c2b40c951164286e08be7c38ec74851"
         ));
     tree.AddFile("a.c").SetId(ObjectId.FromString("6bc0e647512d2a0bef4f26111e484dc87df7f5ca"
         ));
     tree.AddFile("a=c").SetId(ObjectId.FromString("06022365ddbd7fb126761319633bf73517770714"
         ));
     tree.AddFile("a=d").SetId(ObjectId.FromString("fa6414df3da87840700e9eeb7fc261dd77ccd5c2"
         ));
     tree.SetId(InsertTree(tree));
     FileTreeIterator iterator = new FileTreeIterator(db);
     IndexDiff diff = new IndexDiff(db, tree.GetId(), iterator);
     diff.Diff();
     NUnit.Framework.Assert.AreEqual(0, diff.GetChanged().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetAdded().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetRemoved().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetMissing().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetModified().Count);
     NUnit.Framework.CollectionAssert.AreEquivalent(Collections<string>.EMPTY_SET, diff.GetUntrackedFolders()
         );
 }
开发者ID:sharwell,项目名称:ngit,代码行数:33,代码来源:IndexDiffTest.cs


注:本文中的NGit.Treewalk.FileTreeIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。