GitSharp.Core.WorkDirCheckout.PrescanTwoTrees C# (CSharp) Метод

PrescanTwoTrees() приватный Метод

private PrescanTwoTrees ( ) : void
Результат void
        internal void PrescanTwoTrees()
        {
            var visitor = new AbstractIndexTreeVisitor
                              {
                                  VisitEntryAux = (treeEntry, auxEntry, indexEntry, file) =>
                                                   {
                                                       if (treeEntry is Tree || auxEntry is Tree)
                                                       {
                                                           throw new ArgumentException("Can't pass me a tree!");
                                                       }

                                                       ProcessEntry(treeEntry, auxEntry, indexEntry);
                                                   },

                                  FinishVisitTree = (tree, auxTree, currentDirectory) =>
                                                        {
                                                            if (currentDirectory.Length == 0) return;
                                                            if (auxTree == null) return;

                                                            if (_index.GetEntry(currentDirectory) != null)
                                                            {
                                                                Removed.Add(currentDirectory);
                                                            }
                                                        }
                              };

            new IndexTreeWalker(_index, _head, _merge, _root, visitor).Walk();

            // if there's a conflict, don't list it under
            // to-be-removed, since that messed up our next
            // section
            Removed.RemoveAll(removed => Conflicts.Contains(removed));

            foreach (string path in _updated.Keys)
            {
                if (_index.GetEntry(path) == null)
                {
                    FileSystemInfo file = new FileInfo(Path.Combine(_root.DirectoryName(), path));
                    if (file.IsFile())
                    {
                        Conflicts.Add(path);
                    }
                    else if (file.IsDirectory())
                    {
                        CheckConflictsWithFile(file);
                    }
                }
            }

            Conflicts.RemoveAll(conflict => Removed.Contains(conflict));
        }

Usage Example

Пример #1
0
 public void testRules1thru3_NoIndexEntry()
 {
     var index = new GitIndex(db);
     var head = new Core.Tree(db);
     FileTreeEntry entry = head.AddFile("foo");
     ObjectId expected = ObjectId.FromString("ba78e065e2c261d4f7b8f42107588051e87e18e9");
     entry.Id = expected;
     var merge = new Core.Tree(db);
     var checkout = new WorkDirCheckout(db, trash, head, index, merge);
     checkout.PrescanTwoTrees();
     Assert.IsTrue(checkout.Removed.Contains("foo"));
     checkout = new WorkDirCheckout(db, trash, merge, index, head);
     checkout.PrescanTwoTrees();
     Assert.AreEqual(expected, checkout.Updated["foo"]);
     ObjectId id2 = ObjectId.FromString("ba78e065e2c261d4f7b8f42107588051e87e18ee");
     merge.AddFile("foo").Id = id2;
     checkout = new WorkDirCheckout(db, trash, head, index, merge);
     checkout.PrescanTwoTrees();
     Assert.AreEqual(id2, checkout.Updated["foo"]);
 }
All Usage Examples Of GitSharp.Core.WorkDirCheckout::PrescanTwoTrees