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


C# TreeWalk.GetTree方法代码示例

本文整理汇总了C#中TreeWalk.GetTree方法的典型用法代码示例。如果您正苦于以下问题:C# TreeWalk.GetTree方法的具体用法?C# TreeWalk.GetTree怎么用?C# TreeWalk.GetTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TreeWalk的用法示例。


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

示例1: 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

示例2: 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

示例3: 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

示例4: TestSingleSubtree_NoRecursion

		public virtual void TestSingleSubtree_NoRecursion()
		{
			DirCache dc = DirCache.NewInCore();
			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 = FileMode.REGULAR_FILE;
			}
			DirCacheBuilder b = dc.Builder();
			for (int i_1 = 0; i_1 < ents.Length; i_1++)
			{
				b.Add(ents[i_1]);
			}
			b.Finish();
			string[] expPaths = new string[] { "a.", "a", "a0b" };
			FileMode[] expModes = new FileMode[] { FileMode.REGULAR_FILE, FileMode.TREE, FileMode
				.REGULAR_FILE };
			int[] expPos = new int[] { 0, -1, 4 };
			DirCacheIterator i_2 = new DirCacheIterator(dc);
			TreeWalk tw = new TreeWalk(db);
			tw.AddTree(i_2);
			tw.Recursive = false;
			int pathIdx = 0;
			while (tw.Next())
			{
				NUnit.Framework.Assert.AreSame(i_2, tw.GetTree<DirCacheIterator>(0));
				NUnit.Framework.Assert.AreEqual(expModes[pathIdx].GetBits(), tw.GetRawMode(0));
				NUnit.Framework.Assert.AreSame(expModes[pathIdx], tw.GetFileMode(0));
				NUnit.Framework.Assert.AreEqual(expPaths[pathIdx], tw.PathString);
				if (expPos[pathIdx] >= 0)
				{
					NUnit.Framework.Assert.AreEqual(expPos[pathIdx], i_2.ptr);
					NUnit.Framework.Assert.AreSame(ents[expPos[pathIdx]], i_2.GetDirCacheEntry());
				}
				else
				{
					NUnit.Framework.Assert.AreSame(FileMode.TREE, tw.GetFileMode(0));
				}
				pathIdx++;
			}
			NUnit.Framework.Assert.AreEqual(expPaths.Length, pathIdx);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:44,代码来源:DirCacheIteratorTest.cs

示例5: TestNoSubtree_WithTreeWalk

		public virtual void TestNoSubtree_WithTreeWalk()
		{
			DirCache dc = DirCache.NewInCore();
			string[] paths = new string[] { "a.", "a0b" };
			FileMode[] modes = new FileMode[] { FileMode.EXECUTABLE_FILE, FileMode.GITLINK };
			DirCacheEntry[] ents = new DirCacheEntry[paths.Length];
			for (int i = 0; i < paths.Length; i++)
			{
				ents[i] = new DirCacheEntry(paths[i]);
				ents[i].FileMode = modes[i];
			}
			DirCacheBuilder b = dc.Builder();
			for (int i_1 = 0; i_1 < ents.Length; i_1++)
			{
				b.Add(ents[i_1]);
			}
			b.Finish();
			DirCacheIterator i_2 = new DirCacheIterator(dc);
			TreeWalk tw = new TreeWalk(db);
			tw.AddTree(i_2);
			int pathIdx = 0;
			while (tw.Next())
			{
				NUnit.Framework.Assert.AreSame(i_2, tw.GetTree<DirCacheIterator>(0));
				NUnit.Framework.Assert.AreEqual(pathIdx, i_2.ptr);
				NUnit.Framework.Assert.AreSame(ents[pathIdx], i_2.GetDirCacheEntry());
				NUnit.Framework.Assert.AreEqual(paths[pathIdx], tw.PathString);
				NUnit.Framework.Assert.AreEqual(modes[pathIdx].GetBits(), tw.GetRawMode(0));
				NUnit.Framework.Assert.AreSame(modes[pathIdx], tw.GetFileMode(0));
				pathIdx++;
			}
			NUnit.Framework.Assert.AreEqual(paths.Length, pathIdx);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:33,代码来源:DirCacheIteratorTest.cs

示例6: 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

示例7: UpdateDirectory

		/// <summary>
		/// Run the diff operation. Until this is called, all lists will be empty
		/// </summary>
		/// <returns>true if anything is different between index, tree, and workdir</returns>
		private void UpdateDirectory (IEnumerable<string> paths, bool recursive)
		{
			RevWalk rw = new RevWalk (Repository);
			ObjectId id = Repository.Resolve (Constants.HEAD);
			var commit = id != null ? rw.ParseCommit (id) : null;
			
			TreeWalk treeWalk = new TreeWalk (Repository);
			treeWalk.Reset ();
			treeWalk.Recursive = false;

			if (commit != null)
				treeWalk.AddTree (commit.Tree);
			else
				treeWalk.AddTree (new EmptyTreeIterator());
			
			DirCache dc = Repository.ReadDirCache ();
			treeWalk.AddTree (new DirCacheIterator (dc));
			
			FileTreeIterator workTree = new FileTreeIterator (Repository.WorkTree, Repository.FileSystem, WorkingTreeOptions.KEY.Parse(Repository.GetConfig()));
			treeWalk.AddTree (workTree);

			List<TreeFilter> filters = new List<TreeFilter> ();
			filters.Add (new SkipWorkTreeFilter(1));
			
			var pathFilters = paths.Where (p => p != ".").Select (p => PathFilter.Create (p)).ToArray ();
			if (pathFilters.Length > 1) {
				filters.Add (OrTreeFilter.Create (pathFilters)); // Use an OR to join all path filters
			} else if (pathFilters.Length == 1)
				filters.Add (pathFilters[0]);

			if (filters.Count > 1)
				treeWalk.Filter = AndTreeFilter.Create(filters);
			else
				treeWalk.Filter = filters[0];
			
			while (treeWalk.Next())
			{
				AbstractTreeIterator treeIterator = treeWalk.GetTree<AbstractTreeIterator>(0);
				DirCacheIterator dirCacheIterator = treeWalk.GetTree<DirCacheIterator>(1);
				WorkingTreeIterator workingTreeIterator = treeWalk.GetTree<WorkingTreeIterator>(2);
				NGit.FileMode fileModeTree = treeWalk.GetFileMode(0);
				
				if (treeWalk.IsSubtree) {
					treeWalk.EnterSubtree ();
					continue;
				}
				
				int stage = dirCacheIterator != null ? dirCacheIterator.GetDirCacheEntry ().Stage : 0;
				if (stage > 1)
					continue;
				else if (stage == 1) {
					MergeConflict.Add(dirCacheIterator.EntryPathString);
					changesExist = true;
					continue;
				}
				
				if (treeIterator != null)
				{
					if (dirCacheIterator != null)
					{
						if (!treeIterator.EntryObjectId.Equals(dirCacheIterator.EntryObjectId))
						{
							// in repo, in index, content diff => changed
							Modified.Add(dirCacheIterator.EntryPathString);
							changesExist = true;
						}
					}
					else
					{
						// in repo, not in index => removed
						if (!fileModeTree.Equals(NGit.FileMode.TYPE_TREE))
						{
							Removed.Add(treeIterator.EntryPathString);
							changesExist = true;
						}
					}
				}
				else
				{
					if (dirCacheIterator != null)
					{
						// not in repo, in index => added
						Added.Add(dirCacheIterator.EntryPathString);
						changesExist = true;
					}
					else
					{
						// not in repo, not in index => untracked
						if (workingTreeIterator != null && !workingTreeIterator.IsEntryIgnored())
						{
							Untracked.Add(workingTreeIterator.EntryPathString);
							changesExist = true;
						}
					}
				}
				if (dirCacheIterator != null)
//.........这里部分代码省略.........
开发者ID:yayanyang,项目名称:monodevelop,代码行数:101,代码来源:RepositoryStatus.cs

示例8: GetFileStatus

        private GitFileStatus GetFileStatus(TreeWalk treeWalk)
        {
            AbstractTreeIterator treeIterator = treeWalk.GetTree<AbstractTreeIterator>(TREE);
            DirCacheIterator dirCacheIterator = treeWalk.GetTree<DirCacheIterator>(INDEX);
            WorkingTreeIterator workingTreeIterator = treeWalk.GetTree<WorkingTreeIterator>(WORKDIR);
            if (dirCacheIterator != null)
            {
                DirCacheEntry dirCacheEntry = dirCacheIterator.GetDirCacheEntry();
                if (dirCacheEntry != null && dirCacheEntry.Stage > 0)
                {
                    return GitFileStatus.Conflict;
                }

                if (workingTreeIterator == null)
                {
                    // in index, not in workdir => missing
                    return GitFileStatus.Deleted;
                }
                else
                {
                    if (workingTreeIterator.IsModified(dirCacheIterator.GetDirCacheEntry(), true))
                    {
                        // in index, in workdir, content differs => modified
                        return GitFileStatus.Modified;
                    }
                }
            }
            if (treeIterator != null)
            {
                if (dirCacheIterator != null)
                {
                    if (!treeIterator.IdEqual(dirCacheIterator) || treeIterator.EntryRawMode != dirCacheIterator.EntryRawMode)
                    {
                        // in repo, in index, content diff => changed
                        return GitFileStatus.Staged;
                    }
                }
                else
                {
                    return GitFileStatus.Removed;
                }
            }
            else
            {
                if (dirCacheIterator != null)
                {
                    // not in repo, in index => added
                    return GitFileStatus.Added;
                }
                else
                {
                    // not in repo, not in index => untracked
                    if (workingTreeIterator != null)
                    {
                        return !workingTreeIterator.IsEntryIgnored() ? GitFileStatus.New : GitFileStatus.Ignored;
                    }
                }
            }

            return GitFileStatus.NotControlled;
        }
开发者ID:b4shailen,项目名称:Git-Source-Control-Provider,代码行数:61,代码来源:GitFileStatusTracker.cs

示例9: GetFileStatusNoCache

        private GitFileStatus GetFileStatusNoCache(string fileName)
        {
            if (Directory.Exists(fileName)) return GitFileStatus.Ignored;

            var fileNameRel = GetRelativeFileNameForGit(fileName);
            var dirCache = repository.ReadDirCache();
            TreeWalk treeWalk = new TreeWalk(this.repository) { Recursive = true };
            var head = repository.Resolve(Constants.HEAD);
            RevTree revTree = head == null ? null : new RevWalk(repository).ParseTree(head);

            if (revTree != null)
            {
                treeWalk.AddTree(revTree);
            }
            else
            {
                treeWalk.AddTree(new EmptyTreeIterator());
            }
            treeWalk.AddTree(new DirCacheIterator(dirCache));
            treeWalk.AddTree(new FileTreeIterator(this.repository));

            var filters = new TreeFilter[] {
                PathFilter.Create(fileNameRel),
                new SkipWorkTreeFilter(INDEX),
                new IndexDiffFilter(INDEX, WORKDIR)
            };
            treeWalk.Filter = AndTreeFilter.Create(filters);
            if (treeWalk.Next())
            {
                AbstractTreeIterator treeIterator = treeWalk.GetTree<AbstractTreeIterator>(TREE);
                DirCacheIterator dirCacheIterator = treeWalk.GetTree<DirCacheIterator>(INDEX);
                WorkingTreeIterator workingTreeIterator = treeWalk.GetTree<WorkingTreeIterator>(WORKDIR);
                if (dirCacheIterator != null)
                {
                    DirCacheEntry dirCacheEntry = dirCacheIterator.GetDirCacheEntry();
                    if (dirCacheEntry != null && dirCacheEntry.Stage > 0)
                    {
                        return GitFileStatus.MergeConflict;
                    }

                    if (workingTreeIterator == null)
                    {
                        // in index, not in workdir => missing
                        return GitFileStatus.Deleted;
                    }
                    else
                    {
                        if (workingTreeIterator.IsModified(dirCacheIterator.GetDirCacheEntry(), true))
                        {
                            // in index, in workdir, content differs => modified
                            return GitFileStatus.Modified;
                        }
                    }
                }
                if (treeIterator != null)
                {
                    if (dirCacheIterator != null)
                    {
                        if (!treeIterator.IdEqual(dirCacheIterator) || treeIterator.EntryRawMode != dirCacheIterator.EntryRawMode)
                        {
                            // in repo, in index, content diff => changed
                            return GitFileStatus.Staged;
                        }
                    }
                    else
                    {
                        return GitFileStatus.Removed;
                    }
                }
                else
                {
                    if (dirCacheIterator != null)
                    {
                        // not in repo, in index => added
                        return GitFileStatus.Added;
                    }
                    else
                    {
                        // not in repo, not in index => untracked
                        if (workingTreeIterator != null)
                        {
                            return !workingTreeIterator.IsEntryIgnored() ? GitFileStatus.New : GitFileStatus.Ignored;
                        }
                    }
                }
            }

            var dirCacheEntry2 = dirCache.GetEntry(fileNameRel);
            if (dirCacheEntry2 != null)
            {
                var treeEntry2 = TreeWalk.ForPath(repository, fileNameRel, revTree);
                if (treeEntry2 != null && treeEntry2.GetObjectId(0).Equals(dirCacheEntry2.GetObjectId()))
                    return GitFileStatus.Tracked;
            }

            return GitFileStatus.NotControlled;
        }
开发者ID:Miraculix,项目名称:Git-Source-Control-Provider,代码行数:97,代码来源:GitFileStatusTracker.cs

示例10: WorkingTree

		private WorkingTreeIterator WorkingTree(TreeWalk tw)
		{
			return tw.GetTree<WorkingTreeIterator>(workingTree);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:4,代码来源:IndexDiffFilter.cs

示例11: Include

		/// <exception cref="NGit.Errors.MissingObjectException"></exception>
		/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public override bool Include(TreeWalk tw)
		{
			// If the working tree file doesn't exist, it does exist for at least
			// one other so include this difference.
			int wm = tw.GetRawMode(workingTree);
			if (wm == 0)
			{
				return true;
			}
			// If the path does not appear in the DirCache and its ignored
			// we can avoid returning a result here, but only if its not in any
			// other tree.
			int cnt = tw.TreeCount;
			int dm = tw.GetRawMode(dirCache);
			if (dm == 0)
			{
				if (honorIgnores && WorkingTree(tw).IsEntryIgnored())
				{
					int i = 0;
					for (; i < cnt; i++)
					{
						if (i == dirCache || i == workingTree)
						{
							continue;
						}
						if (tw.GetRawMode(i) != 0)
						{
							break;
						}
					}
					// If i is cnt then the path does not appear in any other tree,
					// and this working tree entry can be safely ignored.
					return i == cnt ? false : true;
				}
				else
				{
					// In working tree and not ignored, and not in DirCache.
					return true;
				}
			}
			// Always include subtrees as WorkingTreeIterator cannot provide
			// efficient elimination of unmodified subtrees.
			if (tw.IsSubtree)
			{
				return true;
			}
			// Try the inexpensive comparisons between index and all real trees
			// first. Only if we don't find a diff here we have to bother with
			// the working tree
			for (int i_1 = 0; i_1 < cnt; i_1++)
			{
				if (i_1 == dirCache || i_1 == workingTree)
				{
					continue;
				}
				if (tw.GetRawMode(i_1) != dm || !tw.IdEqual(i_1, dirCache))
				{
					return true;
				}
			}
			// Only one chance left to detect a diff: between index and working
			// tree. Make use of the WorkingTreeIterator#isModified() method to
			// avoid computing SHA1 on filesystem content if not really needed.
			WorkingTreeIterator wi = WorkingTree(tw);
			DirCacheIterator di = tw.GetTree<DirCacheIterator>(dirCache);
			return wi.IsModified(di.GetDirCacheEntry(), true);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:70,代码来源:IndexDiffFilter.cs

示例12: Include

		/// <exception cref="NGit.Errors.MissingObjectException"></exception>
		/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public override bool Include(TreeWalk tw)
		{
			WorkingTreeIterator i = tw.GetTree<WorkingTreeIterator>(index);
			return i == null || !i.IsEntryIgnored();
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:8,代码来源:NotIgnoredFilter.cs

示例13: TestTreeWalk_LsFiles

		public virtual void TestTreeWalk_LsFiles()
		{
			Repository db = CreateBareRepository();
			IDictionary<string, DirCacheCGitCompatabilityTest.CGitIndexRecord> ls = ReadLsFiles
				();
			DirCache dc = new DirCache(index, db.FileSystem);
			NUnit.Framework.Assert.AreEqual(0, dc.GetEntryCount());
			dc.Read();
			NUnit.Framework.Assert.AreEqual(ls.Count, dc.GetEntryCount());
			{
				Iterator<DirCacheCGitCompatabilityTest.CGitIndexRecord> rItr = ls.Values.Iterator
					();
				TreeWalk tw = new TreeWalk(db);
				tw.Recursive = true;
				tw.AddTree(new DirCacheIterator(dc));
				while (rItr.HasNext())
				{
					DirCacheIterator dcItr;
					NUnit.Framework.Assert.IsTrue(tw.Next());
					dcItr = tw.GetTree<DirCacheIterator>(0);
					NUnit.Framework.Assert.IsNotNull(dcItr);
					AssertEqual(rItr.Next(), dcItr.GetDirCacheEntry());
				}
			}
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:25,代码来源:DirCacheCGitCompatabilityTest.cs

示例14: Include

		/// <exception cref="NGit.Errors.MissingObjectException"></exception>
		/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public override bool Include(TreeWalk tw)
		{
			int cnt = tw.TreeCount;
			int wm = tw.GetRawMode(workingTree);
			string path = tw.PathString;
			if (!tw.PostOrderTraversal)
			{
				// detect untracked Folders
				// Whenever we enter a folder in the workingtree assume it will
				// contain only untracked files and add it to
				// untrackedParentFolders. If we later find tracked files we will
				// remove it from this list
				if (FileMode.TREE.Equals(wm))
				{
					// Clean untrackedParentFolders. This potentially moves entries
					// from untrackedParentFolders to untrackedFolders
					CopyUntrackedFolders(path);
					// add the folder we just entered to untrackedParentFolders
					untrackedParentFolders.AddFirst(path);
				}
				// detect untracked Folders
				// Whenever we see a tracked file we know that all of its parent
				// folders do not belong into untrackedParentFolders anymore. Clean
				// it.
				for (int i = 0; i < cnt; i++)
				{
					int rmode = tw.GetRawMode(i);
					if (i != workingTree && rmode != 0 && FileMode.TREE.Equals(rmode))
					{
						untrackedParentFolders.Clear();
						break;
					}
				}
			}
			// If the working tree file doesn't exist, it does exist for at least
			// one other so include this difference.
			if (wm == 0)
			{
				return true;
			}
			// If the path does not appear in the DirCache and its ignored
			// we can avoid returning a result here, but only if its not in any
			// other tree.
			int dm = tw.GetRawMode(dirCache);
			WorkingTreeIterator wi = WorkingTree(tw);
			if (dm == 0)
			{
				if (honorIgnores && wi.IsEntryIgnored())
				{
					ignoredPaths.AddItem(wi.EntryPathString);
					int i = 0;
					for (; i < cnt; i++)
					{
						if (i == dirCache || i == workingTree)
						{
							continue;
						}
						if (tw.GetRawMode(i) != 0)
						{
							break;
						}
					}
					// If i is cnt then the path does not appear in any other tree,
					// and this working tree entry can be safely ignored.
					return i == cnt ? false : true;
				}
				else
				{
					// In working tree and not ignored, and not in DirCache.
					return true;
				}
			}
			// Always include subtrees as WorkingTreeIterator cannot provide
			// efficient elimination of unmodified subtrees.
			if (tw.IsSubtree)
			{
				return true;
			}
			// Try the inexpensive comparisons between index and all real trees
			// first. Only if we don't find a diff here we have to bother with
			// the working tree
			for (int i_1 = 0; i_1 < cnt; i_1++)
			{
				if (i_1 == dirCache || i_1 == workingTree)
				{
					continue;
				}
				if (tw.GetRawMode(i_1) != dm || !tw.IdEqual(i_1, dirCache))
				{
					return true;
				}
			}
			// Only one chance left to detect a diff: between index and working
			// tree. Make use of the WorkingTreeIterator#isModified() method to
			// avoid computing SHA1 on filesystem content if not really needed.
			DirCacheIterator di = tw.GetTree<DirCacheIterator>(dirCache);
			return wi.IsModified(di.GetDirCacheEntry(), true);
//.........这里部分代码省略.........
开发者ID:LunarLanding,项目名称:ngit,代码行数:101,代码来源:IndexDiffFilter.cs

示例15: TestTwoLevelSubtree_Recursive

		public virtual void TestTwoLevelSubtree_Recursive()
		{
			DirCache dc = DirCache.NewInCore();
			FileMode mode = FileMode.REGULAR_FILE;
			string[] paths = new string[] { "a.", "a/b", "a/c/e", "a/c/f", "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();
			TreeWalk tw = new TreeWalk(db);
			tw.AddTree(new DirCacheIterator(dc));
			tw.Recursive = true;
			int pathIdx = 0;
			while (tw.Next())
			{
				DirCacheIterator c = tw.GetTree<DirCacheIterator>(0);
				NUnit.Framework.Assert.IsNotNull(c);
				NUnit.Framework.Assert.AreEqual(pathIdx, c.ptr);
				NUnit.Framework.Assert.AreSame(ents[pathIdx], c.GetDirCacheEntry());
				NUnit.Framework.Assert.AreEqual(paths[pathIdx], tw.PathString);
				NUnit.Framework.Assert.AreEqual(mode.GetBits(), tw.GetRawMode(0));
				NUnit.Framework.Assert.AreSame(mode, tw.GetFileMode(0));
				pathIdx++;
			}
			NUnit.Framework.Assert.AreEqual(paths.Length, pathIdx);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:34,代码来源:DirCacheIteratorTest.cs


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