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


C# TreeWalk.addTree方法代码示例

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


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

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

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

示例3: testTwoLevelSubtree_Recursive

        public void testTwoLevelSubtree_Recursive()
        {
            DirCache dc = DirCache.read(db);

            FileMode mode = FileMode.RegularFile;
            string[] paths = { "a.", "a/b", "a/c/e", "a/c/f", "a/d", "a0b" };
            var ents = new DirCacheEntry[paths.Length];
            for (int i = 0; i < paths.Length; i++)
            {
                ents[i] = new DirCacheEntry(paths[i]);
                ents[i].setFileMode(mode);
            }

            DirCacheBuilder b = dc.builder();
            for (int i = 0; i < ents.Length; i++)
            {
                b.add(ents[i]);
            }
            b.finish();

            var tw = new TreeWalk(db);
            tw.reset();
            tw.addTree(new DirCacheIterator(dc));
            tw.Recursive = true;
            int pathIdx = 0;
            while (tw.next())
            {
                var c = tw.getTree<DirCacheIterator>(0, typeof(DirCacheIterator));
                Assert.IsNotNull(c);
                Assert.AreEqual(pathIdx, c.Pointer);
                Assert.AreSame(ents[pathIdx], c.getDirCacheEntry());
                Assert.AreEqual(paths[pathIdx], tw.getPathString());
                Assert.AreEqual(mode.Bits, tw.getRawMode(0));
                Assert.AreSame(mode, tw.getFileMode(0));
                pathIdx++;
            }

            Assert.AreEqual(paths.Length, pathIdx);
        }
开发者ID:spraints,项目名称:GitSharp,代码行数:39,代码来源:DirCacheIteratorTest.cs

示例4: testTwoLevelSubtree_FilterPath

        public void testTwoLevelSubtree_FilterPath()
        {
            DirCache dc = DirCache.read(db);

            FileMode mode = FileMode.RegularFile;
            string[] paths = { "a.", "a/b", "a/c/e", "a/c/f", "a/d", "a0b" };
            var ents = new DirCacheEntry[paths.Length];
            for (int i = 0; i < paths.Length; i++)
            {
                ents[i] = new DirCacheEntry(paths[i]);
                ents[i].setFileMode(mode);
            }

            DirCacheBuilder b = dc.builder();
            for (int i = 0; i < ents.Length; i++)
            {
                b.add(ents[i]);
            }
            b.finish();

            var tw = new TreeWalk(db);
            for (int victimIdx = 0; victimIdx < paths.Length; victimIdx++)
            {
                tw.reset();
                tw.addTree(new DirCacheIterator(dc));
                tw.setFilter(PathFilterGroup.createFromStrings(new[] { paths[victimIdx] }));
                tw.Recursive = tw.getFilter().shouldBeRecursive();
                Assert.IsTrue(tw.next());
                var c = tw.getTree<DirCacheIterator>(0, typeof(DirCacheIterator));
                Assert.IsNotNull(c);
                Assert.AreEqual(victimIdx, c.Pointer);
                Assert.AreSame(ents[victimIdx], c.getDirCacheEntry());
                Assert.AreEqual(paths[victimIdx], tw.getPathString());
                Assert.AreEqual(mode.Bits, tw.getRawMode(0));
                Assert.AreSame(mode, tw.getFileMode(0));
                Assert.IsFalse(tw.next());
            }
        }
开发者ID:spraints,项目名称:GitSharp,代码行数:38,代码来源:DirCacheIteratorTest.cs

示例5: testSingleSubtree_NoRecursion

        public void testSingleSubtree_NoRecursion()
        {
            DirCache dc = DirCache.read(db);

            string[] paths = { "a.", "a/b", "a/c", "a/d", "a0b" };
            var ents = new DirCacheEntry[paths.Length];
            for (int i = 0; i < paths.Length; i++)
            {
                ents[i] = new DirCacheEntry(paths[i]);
                ents[i].setFileMode(FileMode.RegularFile);
            }

            DirCacheBuilder b = dc.builder();
            for (int i = 0; i < ents.Length; i++)
            {
                b.add(ents[i]);
            }
            b.finish();

            string[] expPaths = { "a.", "a", "a0b" };
            FileMode[] expModes = { FileMode.RegularFile, FileMode.Tree, FileMode.RegularFile };
            var expPos = new[] { 0, -1, 4 };

            var iter = new DirCacheIterator(dc);
            var tw = new TreeWalk(db);
            tw.reset();
            tw.addTree(iter);
            tw.Recursive = false;
            int pathIdx = 0;
            while (tw.next())
            {
                Assert.AreSame(iter, tw.getTree<DirCacheIterator>(0, typeof(DirCacheIterator)));
                Assert.AreEqual(expModes[pathIdx].Bits, tw.getRawMode(0));
                Assert.AreSame(expModes[pathIdx], tw.getFileMode(0));
                Assert.AreEqual(expPaths[pathIdx], tw.getPathString());

                if (expPos[pathIdx] >= 0)
                {
                    Assert.AreEqual(expPos[pathIdx], iter.Pointer);
                    Assert.AreSame(ents[expPos[pathIdx]], iter.getDirCacheEntry());
                }
                else
                {
                    Assert.AreSame(FileMode.Tree, tw.getFileMode(0));
                }

                pathIdx++;
            }
            Assert.AreEqual(expPaths.Length, pathIdx);
        }
开发者ID:spraints,项目名称:GitSharp,代码行数:50,代码来源:DirCacheIteratorTest.cs

示例6: testNoSubtree_WithTreeWalk

        public void testNoSubtree_WithTreeWalk()
        {
            DirCache dc = DirCache.read(db);

            string[] paths = { "a.", "a0b" };
            FileMode[] modes = { FileMode.ExecutableFile, FileMode.GitLink };
            var ents = new DirCacheEntry[paths.Length];
            for (int i = 0; i < paths.Length; i++)
            {
                ents[i] = new DirCacheEntry(paths[i]);
                ents[i].setFileMode(modes[i]);
            }

            DirCacheBuilder b = dc.builder();
            for (int i = 0; i < ents.Length; i++)
            {
                b.add(ents[i]);
            }
            b.finish();

            var iter = new DirCacheIterator(dc);
            var tw = new TreeWalk(db);
            tw.reset();
            tw.addTree(iter);
            int pathIdx = 0;
            while (tw.next())
            {
                Assert.AreSame(iter, tw.getTree<DirCacheIterator>(0, typeof(DirCacheIterator)));
                Assert.AreEqual(pathIdx, iter.Pointer);
                Assert.AreSame(ents[pathIdx], iter.getDirCacheEntry());
                Assert.AreEqual(paths[pathIdx], tw.getPathString());
                Assert.AreEqual(modes[pathIdx].Bits, tw.getRawMode(0));
                Assert.AreSame(modes[pathIdx], tw.getFileMode(0));
                pathIdx++;
            }
            Assert.AreEqual(paths.Length, pathIdx);
        }
开发者ID:spraints,项目名称:GitSharp,代码行数:37,代码来源:DirCacheIteratorTest.cs


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