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


C# Core.Tree类代码示例

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


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

示例1: StartVisitTree

 public void StartVisitTree(Tree t)
 {
     stack.Push(currentDirectory);
     if (!t.IsRoot)
     {
         currentDirectory = new DirectoryInfo(Path.Combine(currentDirectory.FullName, t.Name));
     }
 }
开发者ID:stschake,项目名称:GitSharp,代码行数:8,代码来源:TreeVisitorWithCurrentDirectory.cs

示例2: testSimpleF1

 public void testSimpleF1()
 {
     Tree tree = new Tree(db);
     tree.AddFile("x");
     TreeIterator i = MakeIterator(tree);
     Assert.IsTrue(i.hasNext());
     Assert.AreEqual("x", i.next().Name);
 }
开发者ID:georgeck,项目名称:GitSharp,代码行数:8,代码来源:TreeIteratorLeafOnlyTest.cs

示例3: handler

 void IndexTreeVisitor.FinishVisitTree(Tree tree, Tree auxTree, string curDir)
 {
     FinishVisitTreeDelegate handler = FinishVisitTree;
     if (handler != null)
     {
         handler(tree, auxTree, curDir);
     }
 }
开发者ID:dev218,项目名称:GitSharp,代码行数:8,代码来源:AbstractIndexTreeVisitor.cs

示例4: WorkDirCheckout

 internal WorkDirCheckout(Repository repo, DirectoryInfo workDir, GitIndex oldIndex, GitIndex newIndex)
     : this()
 {
     _repo = repo;
     _root = workDir;
     _index = oldIndex;
     _merge = repo.MapTree(newIndex.writeTree());
 }
开发者ID:dev218,项目名称:GitSharp,代码行数:8,代码来源:WorkDirCheckout.cs

示例5: testEmpty

 public void testEmpty()
 {
     Tree tree = new Tree(db);
     TreeIterator i = makeIterator(tree);
     Assert.IsTrue(i.hasNext());
     Assert.AreEqual("", i.next().FullName);
     Assert.IsFalse(i.hasNext());
 }
开发者ID:georgeck,项目名称:GitSharp,代码行数:8,代码来源:TreeIteratorPostOrderTest.cs

示例6: IndexTreeWalker

 public IndexTreeWalker(GitIndex index, Tree mainTree, Tree newTree, FileSystemInfo root,
                        IndexTreeVisitor visitor)
 {
     _mainTree = mainTree;
     _newTree = newTree;
     _root = root;
     _visitor = visitor;
     _threeTrees = newTree != null;
     _indexMembers = index.Members;
 }
开发者ID:stschake,项目名称:GitSharp,代码行数:10,代码来源:IndexTreeWalker.cs

示例7: IndexDiff

        public IndexDiff(Tree tree, GitIndex index)
        {
            _anyChanges = false;
            _tree = tree;
            _index = index;

            Added = new HashSet<string>();
            Changed = new HashSet<string>();
            Removed = new HashSet<string>();
            Missing = new HashSet<string>();
            Modified = new HashSet<string>();
        }
开发者ID:georgeck,项目名称:GitSharp,代码行数:12,代码来源:IndexDiff.cs

示例8: testAdded2

        public void testAdded2()
        {
            var index = new GitIndex(db);
            writeTrashFile("test/für henon.txt", "Weißebier");
            var tree = new Tree(db);

            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "test/für henon.txt")));
            var diff = new IndexDiff(tree, index);
            diff.Diff();

            Assert.AreEqual(1, diff.Added.Count);
            Assert.IsTrue(diff.Added.Contains("test/für henon.txt"));
            Assert.AreEqual(0, diff.Changed.Count);
            Assert.AreEqual(0, diff.Modified.Count);
            Assert.AreEqual(0, diff.Removed.Count);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:16,代码来源:IndexDiffTest.cs

示例9: testAdded

        public void testAdded()
        {
            var index = new GitIndex(db);
            writeTrashFile("file1", "file1");
            writeTrashFile("dir/subfile", "dir/subfile");
            var tree = new Tree(db);

            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "file1")));
            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "dir/subfile")));
            var diff = new IndexDiff(tree, index);
            diff.Diff();

            Assert.AreEqual(2, diff.Added.Count);
            Assert.IsTrue(diff.Added.Contains("file1"));
            Assert.IsTrue(diff.Added.Contains("dir/subfile"));
            Assert.AreEqual(0, diff.Changed.Count);
            Assert.AreEqual(0, diff.Modified.Count);
            Assert.AreEqual(0, diff.Removed.Count);
        }
开发者ID:georgeck,项目名称:GitSharp,代码行数:19,代码来源:IndexDiffTest.cs

示例10: CanAddAFileToAMSysGitIndexWhereAFileIsAlreadyWaitingToBeCommitted

        public void CanAddAFileToAMSysGitIndexWhereAFileIsAlreadyWaitingToBeCommitted()
        {
            //setup of .git directory
            var resource =
                new DirectoryInfo(Path.Combine(Path.Combine(Environment.CurrentDirectory, "Resources"),
                                               "CorruptIndex"));
            var tempRepository =
                new DirectoryInfo(Path.Combine(trash.FullName, "CorruptIndex" + Path.GetRandomFileName()));
            CopyDirectory(resource.FullName, tempRepository.FullName);

            var repositoryPath = new DirectoryInfo(Path.Combine(tempRepository.FullName, ".git"));
            Directory.Move(repositoryPath.FullName + "ted", repositoryPath.FullName);

            var repository = new Repository(repositoryPath);
            GitIndex index = repository.Index;

            Assert.IsNotNull(index);

            writeTrashFile(Path.Combine(repository.WorkingDirectory.FullName, "c.txt"), "c");

            var tree = new Tree(repository);

            index.add(repository.WorkingDirectory, new FileInfo(Path.Combine(repository.WorkingDirectory.FullName, "c.txt")));

            var diff = new IndexDiff(tree, index);
            diff.Diff();

            index.write();

            Assert.AreEqual(3, diff.Added.Count);
            Assert.IsTrue(diff.Added.Contains("a.txt"));
            Assert.IsTrue(diff.Added.Contains("b.txt"));
            Assert.IsTrue(diff.Added.Contains("c.txt"));
            Assert.AreEqual(0, diff.Changed.Count);
            Assert.AreEqual(0, diff.Modified.Count);
            Assert.AreEqual(0, diff.Removed.Count);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:37,代码来源:CanReadMsysgitIndexFixture.cs

示例11: testTwoSuccessiveCommitsLinkedToHead

        public void testTwoSuccessiveCommitsLinkedToHead()
        {
            var repo = createNewEmptyRepo();
            var workingDirectory = repo.WorkingDirectory;
            repo.Create();

            var objectWriter = new ObjectWriter(repo);

            FileInfo project1_a_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/A.txt"), "A.txt - first version\n");
            FileInfo project1_b_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/B.txt"), "B.txt - first version\n");

            var tree = new Tree(repo);
            Tree projectTree = tree.AddTree("Project-1");
            addFile(projectTree, project1_a_txt, objectWriter);
            projectTree.Id = (objectWriter.WriteTree(projectTree));
            addFile(projectTree, project1_b_txt, objectWriter);
            projectTree.Id = (objectWriter.WriteTree(projectTree));
            tree.Id = (objectWriter.WriteTree(tree));

            var commit = new Commit(repo)
            {
                Author = new PersonIdent(jauthor, (0L), 60),
                Committer = new PersonIdent(jcommitter, (0L), 60),
                Message = "Foo\n\nMessage",
                TreeEntry = tree
            };
            commit.Save();
            var commitId = commit.CommitId;

            FileInfo project1_b_v2_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/B.txt"), "B.txt - second version\n");

            tree = new Tree(repo);
            projectTree = tree.AddTree("Project-1");
            addFile(projectTree, project1_a_txt, objectWriter);
            projectTree.Id = (objectWriter.WriteTree(projectTree));
            addFile(projectTree, project1_b_v2_txt, objectWriter);
            projectTree.Id = (objectWriter.WriteTree(projectTree));
            tree.Id = (objectWriter.WriteTree(tree));

            commit = new Commit(repo)
            {
                Author = new PersonIdent(jauthor, (0L), 60),
                Committer = new PersonIdent(jcommitter, (0L), 60),
                Message = "Modified",
                ParentIds = new[] { commitId },
                TreeEntry = tree
            };
            commit.Save();
            commitId = commit.CommitId;

            RefUpdate lck = repo.UpdateRef("refs/heads/master");
            Assert.IsNotNull(lck, "obtained lock");
            lck.NewObjectId = commitId;
            Assert.AreEqual(RefUpdate.RefUpdateResult.New, lck.ForceUpdate());
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:55,代码来源:T0003_Basic_Write.cs

示例12: HasParentBlob

        private static bool HasParentBlob(Tree t, string name)
        {
            if (name.IndexOf('/') == -1)
            {
                return false;
            }

            string parent = name.Slice(0, name.LastIndexOf('/'));
            return t.FindBlobMember(parent) != null || HasParentBlob(t, parent);
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:10,代码来源:WorkDirCheckout.cs

示例13: Refresh

        public void Refresh()
        {
            cache.Clear();
            if (!string.IsNullOrEmpty(initFolder))
            {
                try
                {
                    this.repository = Repository.Open(initFolder);

                    if (this.repository != null)
                    {
                        var id = repository.Resolve("HEAD");
                        var commit = repository.MapCommit(id);
                        this.commitTree = (commit != null ? commit.TreeEntry : new Tree(repository));
                        this.index = repository.Index;
                        this.index.RereadIfNecessary();
                        //this.ignoreHandler = new IgnoreHandler(repository);
                        //this.watcher = new FileSystemWatcher(this.repository.WorkingDirectory.FullName);
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
开发者ID:cocytus,项目名称:Git-Source-Control-Provider,代码行数:25,代码来源:GitFileStatusTracker.cs

示例14: SymlinkTreeEntry

 public SymlinkTreeEntry(Tree parent, ObjectId id, byte[] nameUTF8)
     : base(parent, id, nameUTF8)
 {
 }
开发者ID:dev218,项目名称:GitSharp,代码行数:4,代码来源:SymlinkTreeEntry.cs

示例15: ReadTree

		private void ReadTree(byte[] raw)
		{
			int rawSize = raw.Length;
			int rawPtr = 0;
			int nextIndex = 0;

			while (rawPtr < rawSize)
			{
				while (rawPtr < rawSize && raw[rawPtr] != 0)
				{
					rawPtr++;
				}

				rawPtr++;
				rawPtr += Constants.OBJECT_ID_LENGTH;
				nextIndex++;
			}

			var temp = new TreeEntry[nextIndex];
			rawPtr = 0;
			nextIndex = 0;

			while (rawPtr < rawSize)
			{
				int c = raw[rawPtr++];
				if (c < '0' || c > '7')
				{
					throw new CorruptObjectException(Id, "invalid entry mode");
				}

				int mode = c - '0';

				while (true)
				{
					c = raw[rawPtr++];
					if (' ' == c) break;

					if (c < '0' || c > '7')
					{
						throw new CorruptObjectException(Id, "invalid mode");
					}

					mode <<= 3;
					mode += c - '0';
				}

				int nameLen = 0;
				while (raw[rawPtr + nameLen] != 0)
				{
					nameLen++;
				}

				var name = new byte[nameLen];
				Array.Copy(raw, rawPtr, name, 0, nameLen);
				rawPtr += nameLen + 1;

				ObjectId id = ObjectId.FromRaw(raw, rawPtr);
				rawPtr += Constants.OBJECT_ID_LENGTH;

				TreeEntry ent;
				if (FileMode.RegularFile.Equals(mode))
				{
					ent = new FileTreeEntry(this, id, name, false);
				}
				else if (FileMode.ExecutableFile.Equals(mode))
				{
					ent = new FileTreeEntry(this, id, name, true);
				}
				else if (FileMode.Tree.Equals(mode))
				{
					ent = new Tree(this, id, name);
				}
                else if (FileMode.Symlink.Equals(mode))
                {
                    ent = new SymlinkTreeEntry(this, id, name);
                }
                else if (FileMode.GitLink.Equals(mode))
                {
                    ent = new GitLinkTreeEntry(this, id, name);
                }
				else
				{
					throw new CorruptObjectException(Id, "Invalid mode: " + Convert.ToString(mode, 8));
				}

				temp[nextIndex++] = ent;
			}

			_contents = temp;
		}
开发者ID:dev218,项目名称:GitSharp,代码行数:90,代码来源:Tree.cs


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