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


C# TreeWalk.IdEqual方法代码示例

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


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

示例1: CalculateCommitDiff

		static IEnumerable<Change> CalculateCommitDiff (NGit.Repository repo, TreeWalk walk, RevCommit[] commits)
		{
			while (walk.Next ()) {
				int m0 = walk.GetRawMode (0);
				if (walk.TreeCount == 2) {
					int m1 = walk.GetRawMode (1);
					var change = new Change { ReferenceCommit = commits[0], ComparedCommit = commits[1], ReferencePermissions = walk.GetFileMode (0).GetBits (), ComparedPermissions = walk.GetFileMode (1).GetBits (), Name = walk.NameString, Path = walk.PathString };
					if (m0 != 0 && m1 == 0) {
						change.ChangeType = ChangeType.Added;
						change.ComparedObject = walk.GetObjectId (0);
					} else if (m0 == 0 && m1 != 0) {
						change.ChangeType = ChangeType.Deleted;
						change.ReferenceObject = walk.GetObjectId (0);
					} else if (m0 != m1 && walk.IdEqual (0, 1)) {
						change.ChangeType = ChangeType.TypeChanged;
						change.ReferenceObject = walk.GetObjectId (0);
						change.ComparedObject = walk.GetObjectId (1);
					} else {
						change.ChangeType = ChangeType.Modified;
						change.ReferenceObject = walk.GetObjectId (0);
						change.ComparedObject = walk.GetObjectId (1);
					}
					yield return change;
				} else {
					var raw_modes = new int[walk.TreeCount - 1];
					for (int i = 0; i < walk.TreeCount - 1; i++)
						raw_modes[i] = walk.GetRawMode (i + 1);
					//ComparedCommit = compared,
					var change = new Change { ReferenceCommit = commits[0], Name = walk.NameString, Path = walk.PathString };
					if (m0 != 0 && raw_modes.All (m1 => m1 == 0)) {
						change.ChangeType = ChangeType.Added;
						change.ComparedObject = walk.GetObjectId (0);
						yield return change;
					} else if (m0 == 0 && raw_modes.Any (m1 => m1 != 0)) {
						change.ChangeType = ChangeType.Deleted;
						yield return change;
					// TODO: not sure if this condition suffices in some special cases.
					} else if (raw_modes.Select ((m1, i) => new { Mode = m1, Index = i + 1 }).All (x => !walk.IdEqual (0, x.Index))) {
						change.ChangeType = ChangeType.Modified;
						change.ReferenceObject = walk.GetObjectId (0);
						yield return change;
					} else if (raw_modes.Select ((m1, i) => new { Mode = m1, Index = i + 1 }).Any (x => m0 != x.Mode && walk.IdEqual (0, x.Index))) {
						change.ChangeType = ChangeType.TypeChanged;
						change.ReferenceObject = walk.GetObjectId (0);
						yield return change;
					}
				}
			}
		}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:49,代码来源:GitUtil.cs

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

示例3: GetChanges

 // Modified version of GitSharp's Commit class
 private Change[] GetChanges(Repository repository, ObjectId id1, ObjectId id2)
 {
     var list = new List<Change>();
     TreeWalk walk = new TreeWalk(repository);
     walk.Reset(id1, id2);
     walk.Recursive = true;
     walk.Filter = TreeFilter.ANY_DIFF;
     while (walk.Next())
     {
         int m0 = walk.GetRawMode(0);
         if (walk.TreeCount == 2)
         {
             int m1 = walk.GetRawMode(1);
             var change = new Change
             {
                 Name = walk.PathString,
             };
             if (m0 != 0 && m1 == 0)
             {
                 change.ChangeType = ChangeType.Added;
             }
             else if (m0 == 0 && m1 != 0)
             {
                 change.ChangeType = ChangeType.Deleted;
             }
             else if (m0 != m1 && walk.IdEqual(0, 1))
             {
                 change.ChangeType = ChangeType.TypeChanged;
             }
             else
             {
                 change.ChangeType = ChangeType.Modified;
             }
             list.Add(change);
         }
         else
         {
             var raw_modes = new int[walk.TreeCount - 1];
             for (int i = 0; i < walk.TreeCount - 1; i++)
                 raw_modes[i] = walk.GetRawMode(i + 1);
             var change = new Change
             {
                 Name = walk.PathString,
             };
             if (m0 != 0 && raw_modes.All(m1 => m1 == 0))
             {
                 change.ChangeType = ChangeType.Added;
                 list.Add(change);
             }
             else if (m0 == 0 && raw_modes.Any(m1 => m1 != 0))
             {
                 change.ChangeType = ChangeType.Deleted;
                 list.Add(change);
             }
             else if (raw_modes.Select((m1, i) => new { Mode = m1, Index = i + 1 }).All(x => !walk.IdEqual(0, x.Index))) // TODO: not sure if this condition suffices in some special cases.
             {
                 change.ChangeType = ChangeType.Modified;
                 list.Add(change);
             }
             else if (raw_modes.Select((m1, i) => new { Mode = m1, Index = i + 1 }).Any(x => m0 != x.Mode && walk.IdEqual(0, x.Index)))
             {
                 change.ChangeType = ChangeType.TypeChanged;
                 list.Add(change);
             }
         }
     }
     return list.ToArray();
 }
开发者ID:Frrank1,项目名称:Git-Source-Control-Provider,代码行数:69,代码来源:RepositoryGraph.cs

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

示例5: Include

 public override bool Include(TreeWalk walker)
 {
     int n = walker.TreeCount;
     if (n == 1)
     {
         // Assume they meant difference to empty tree.
         return true;
     }
     int m = walker.GetRawMode(0);
     for (int i = 1; i < n; i++)
     {
         if (walker.GetRawMode(i) != m || !walker.IdEqual(i, 0))
         {
             return true;
         }
     }
     return false;
 }
开发者ID:sharwell,项目名称:ngit,代码行数:18,代码来源:TreeFilter.cs


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