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


C# DirCacheEntry.setFileMode方法代码示例

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


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

示例1: testNonRecursiveFiltering

        public void testNonRecursiveFiltering()
        {
            var ow = new ObjectWriter(db);
            ObjectId aSth = ow.WriteBlob("a.sth".getBytes());
            ObjectId aTxt = ow.WriteBlob("a.txt".getBytes());
            DirCache dc = DirCache.read(db);
            DirCacheBuilder builder = dc.builder();
            var aSthEntry = new DirCacheEntry("a.sth");
            aSthEntry.setFileMode(FileMode.RegularFile);
            aSthEntry.setObjectId(aSth);
            var aTxtEntry = new DirCacheEntry("a.txt");
            aTxtEntry.setFileMode(FileMode.RegularFile);
            aTxtEntry.setObjectId(aTxt);
            builder.add(aSthEntry);
            builder.add(aTxtEntry);
            builder.finish();
            ObjectId treeId = dc.writeTree(ow);


            var tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
            tw.setFilter(PathSuffixFilter.create(".txt"));
            tw.addTree(treeId);

            var paths = new LinkedList<string>();
            while (tw.next())
            {
                paths.AddLast(tw.getPathString());
            }

            var expected = new LinkedList<string>();
            expected.AddLast("a.txt");

            Assert.AreEqual(expected, paths);
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:34,代码来源:PathSuffixFilterTestCase.cs

示例2: testBuildOneFile_FinishWriteCommit

        public void testBuildOneFile_FinishWriteCommit()
        {
            string path = "a-File-path";
            var mode = GitSharp.Core.FileMode.RegularFile;
            long lastModified = 1218123387057L;
            int Length = 1342;
            DirCacheEntry entOrig;

            DirCache dc = DirCache.Lock(db);
            DirCacheBuilder b = dc.builder();
            Assert.IsNotNull(b);

            entOrig = new DirCacheEntry(path);
            entOrig.setFileMode(mode);
            entOrig.setLastModified(lastModified);
            entOrig.setLength(Length);

            Assert.AreNotSame(path, entOrig.getPathString());
            Assert.AreEqual(path, entOrig.getPathString());
            Assert.AreEqual(ObjectId.ZeroId, entOrig.getObjectId());
            Assert.AreEqual(mode.Bits, entOrig.getRawMode());
            Assert.AreEqual(0, entOrig.getStage());
            Assert.AreEqual(lastModified, entOrig.getLastModified());
            Assert.AreEqual(Length, entOrig.getLength());
            Assert.IsFalse(entOrig.isAssumeValid());
            b.add(entOrig);

            b.finish();
            Assert.AreEqual(1, dc.getEntryCount());
            Assert.AreSame(entOrig, dc.getEntry(0));

            dc.write();
            Assert.IsTrue(dc.commit());

            dc = DirCache.read(db);
            Assert.AreEqual(1, dc.getEntryCount());

            DirCacheEntry entRead = dc.getEntry(0);
            Assert.AreNotSame(entOrig, entRead);
            Assert.AreEqual(path, entRead.getPathString());
            Assert.AreEqual(ObjectId.ZeroId, entOrig.getObjectId());
            Assert.AreEqual(mode.Bits, entOrig.getRawMode());
            Assert.AreEqual(0, entOrig.getStage());
            Assert.AreEqual(lastModified, entOrig.getLastModified());
            Assert.AreEqual(Length, entOrig.getLength());
            Assert.IsFalse(entOrig.isAssumeValid());
        }
开发者ID:jagregory,项目名称:GitSharp,代码行数:47,代码来源:DirCacheBuilderTest.cs

示例3: MakeEntry

 private DirCacheEntry MakeEntry(string path, FileMode mode, String content)
 {
     var ent = new DirCacheEntry(path);
     ent.setFileMode(mode);
     byte[] contentBytes = Constants.encode(content);
     ent.setObjectId(new ObjectWriter(db).ComputeBlobSha1(contentBytes.Length, new MemoryStream(contentBytes)));
     return ent;
 }
开发者ID:georgeck,项目名称:GitSharp,代码行数:8,代码来源:SimpleMergeTest.cs

示例4: testSetFileMode

        public void testSetFileMode()
        {
            DirCacheEntry e = new DirCacheEntry("a");

            Assert.AreEqual(0, e.getRawMode());

            e.setFileMode(FileMode.RegularFile);
            Assert.AreSame(FileMode.RegularFile, e.getFileMode());
            Assert.AreEqual(FileMode.RegularFile.Bits, e.getRawMode());

            e.setFileMode(FileMode.ExecutableFile);
            Assert.AreSame(FileMode.ExecutableFile, e.getFileMode());
            Assert.AreEqual(FileMode.ExecutableFile.Bits, e.getRawMode());

            e.setFileMode(FileMode.Symlink);
            Assert.AreSame(FileMode.Symlink, e.getFileMode());
            Assert.AreEqual(FileMode.Symlink.Bits, e.getRawMode());

            e.setFileMode(FileMode.GitLink);
            Assert.AreSame(FileMode.GitLink, e.getFileMode());
            Assert.AreEqual(FileMode.GitLink.Bits, e.getRawMode());

            try
            {
                e.setFileMode(FileMode.Missing);
                Assert.Fail("incorrectly accepted FileMode.MISSING");
            }
            catch (ArgumentException err)
            {
                Assert.AreEqual("Invalid mode 0 for path a", err.Message);
            }

            try
            {
                e.setFileMode(FileMode.Tree);
                Assert.Fail("incorrectly accepted FileMode.TREE");
            }
            catch (ArgumentException err)
            {
                Assert.AreEqual("Invalid mode " + FileMode.TYPE_TREE + " for path a", err.Message);
            }
        }
开发者ID:spraints,项目名称:GitSharp,代码行数:42,代码来源:DirCacheEntryTest.cs

示例5: ToEntry

 private static DirCacheEntry ToEntry(int stage, TreeWalk.TreeWalk tw)
 {
     var e = new DirCacheEntry(tw.getRawPath(), stage);
     var iterator = tw.getTree<AbstractTreeIterator>(0, typeof(AbstractTreeIterator));
     e.setFileMode(tw.getFileMode(0));
     e.setObjectIdFromRaw(iterator.idBuffer(), iterator.idOffset());
     return e;
 }
开发者ID:spraints,项目名称:GitSharp,代码行数:8,代码来源:DirCacheBuilder.cs

示例6: makeFile

 private DirCacheEntry makeFile(string path)
 {
     byte[] pathBytes = Constants.encode(path);
     var ent = new DirCacheEntry(path);
     ent.setFileMode(FileMode.RegularFile);
     ent.setObjectId(new ObjectWriter(db).ComputeBlobSha1(pathBytes.Length, new MemoryStream(pathBytes)));
     return ent;
 }
开发者ID:jagregory,项目名称:GitSharp,代码行数:8,代码来源:PostOrderTreeWalkTest.cs

示例7: Add

            private void Add(int tree, int stage)
            {
                AbstractTreeIterator i = GetTree(tree);
                if (i == null) return;

                if (FileMode.Tree.Equals(_tw.getRawMode(tree)))
                {
                    _builder.addTree(_tw.getRawPath(), stage, Repository, _tw.getObjectId(tree));
                }
                else
                {
                    var e = new DirCacheEntry(_tw.getRawPath(), stage);
                    e.setObjectIdFromRaw(i.idBuffer(), i.idOffset());
                    e.setFileMode(_tw.getFileMode(tree));
                    _builder.add(e);
                }
            }
开发者ID:stschake,项目名称:GitSharp,代码行数:17,代码来源:StrategySimpleTwoWayInCore.cs

示例8: testFindSingleFile

        public void testFindSingleFile()
        {
            string path = "a-File-path";
            DirCache dc = DirCache.read(db);
            DirCacheBuilder b = dc.builder();
            Assert.IsNotNull(b);

            DirCacheEntry entOrig = new DirCacheEntry(path);
            entOrig.setFileMode(FileMode.RegularFile);
            Assert.AreNotSame(path, entOrig.getPathString());
            Assert.AreEqual(path, entOrig.getPathString());
            b.add(entOrig);
            b.finish();

            Assert.AreEqual(1, dc.getEntryCount());
            Assert.AreSame(entOrig, dc.getEntry(0));
            Assert.AreEqual(0, dc.findEntry(path));

            Assert.AreEqual(-1, dc.findEntry("@@-before"));
            Assert.AreEqual(0, real(dc.findEntry("@@-before")));

            Assert.AreEqual(-2, dc.findEntry("a-zoo"));
            Assert.AreEqual(1, real(dc.findEntry("a-zoo")));

            Assert.AreSame(entOrig, dc.getEntry(path));
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:26,代码来源:DirCacheBuilderTest.cs

示例9: testLongPath

        private void testLongPath(int len)
        {
            string longPath = makeLongPath(len);
            string shortPath = "~~~ shorter-path";

            DirCacheEntry longEnt = new DirCacheEntry(longPath);
            DirCacheEntry shortEnt = new DirCacheEntry(shortPath);

            longEnt.setFileMode(FileMode.RegularFile);
            shortEnt.setFileMode(FileMode.RegularFile);

            Assert.AreEqual(longPath, longEnt.getPathString());
            Assert.AreEqual(shortPath, shortEnt.getPathString());

            DirCache dc1 = DirCache.Lock(db);
            DirCacheBuilder b = dc1.builder();
            b.add(longEnt);
            b.add(shortEnt);
            Assert.IsTrue(b.commit());
            Assert.AreEqual(2, dc1.getEntryCount());
            Assert.AreSame(longEnt, dc1.getEntry(0));
            Assert.AreSame(shortEnt, dc1.getEntry(1));

            DirCache dc2 = DirCache.read(db);
            Assert.AreEqual(2, dc2.getEntryCount());
            Assert.AreNotSame(longEnt, dc2.getEntry(0));
            Assert.AreEqual(longPath, dc2.getEntry(0).getPathString());
            Assert.AreNotSame(shortEnt, dc2.getEntry(1));
            Assert.AreEqual(shortPath, dc2.getEntry(1).getPathString());
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:30,代码来源:DirCacheLargePathTest.cs


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