// creates a new copy of NodeAtTime in this tree an links them  // has to be directory
        private NodeAtTime AddCopy(
            string path, NodeAtTime previousNode, NodeAtTime parent,
            long currentRevision, long previousRevision,
            ref ISet <string> filesCopiedThisRevision)
        {
            NodeAtTime currentNode;

            currentNode = new NodeAtTime(path, currentRevision, new AncestorRelation(previousNode, previousRevision));

            if (previousNode.IsFolder)
            {
                currentNode.SetIsFolder(false);

                foreach (var c in previousNode.Children)
                {
                    if (c.ExistsAtRevision(previousRevision))
                    {
                        string relpath;

                        if (previousNode.Path == "")
                        {
                            relpath = "/" + c.Path;
                        }
                        else
                        {
                            relpath = c.Path.Substring(previousNode.Path.Length);
                        }

                        string newPath = path + relpath;

                        AddCopy(newPath, c, currentNode, currentRevision, previousRevision, ref filesCopiedThisRevision);
                    }
                }
            }
            else
            {
                if (previousNode.IsFile)
                {
                    currentNode.SetIsFile(false);
                }

                // gets put into this list so it can be deleted from the equalAdds list if it's modified in the same revision it's copied
                filesCopiedThisRevision.Add(currentNode.Path);

                if (previousNode.Actions.Count == 1 || previousNode.Actions[1].Revision > previousRevision)
                {
                    // if our first content is the same as our parents

                    ISet <NodeAtTime> eqli;
                    if (!equalAdds.TryGetValue(previousNode, out eqli))
                    {
                        equalAdds[previousNode] = eqli = new HashSet <NodeAtTime>();
                        eqli.Add(previousNode);
                    }
                    equalAdds[currentNode] = eqli;
                    eqli.Add(currentNode);
                }
            }

            if (parent != null)
            {
                parent.AddChild(currentNode);
            }

            IList <NodeAtTime> nodesWithSamePath;

            if (!nodes.TryGetValue(currentNode.Path, out nodesWithSamePath))
            {
                nodes[currentNode.Path] = nodesWithSamePath = new List <NodeAtTime>();
            }
            nodesWithSamePath.Add(currentNode);

            return(currentNode);
        }
        private void AddAddition(string nodePath, SimplifiedSvnChangeItem changeItem, long revision, ref ISet <string> filesCopiedThisRevision)
        {
            NodeAtTime parent = null;
            // get parent
            int t = 0;

            for (int k = nodePath.Length - 1; k >= 0; k--)
            {
                if (nodePath[k] == '/')
                {
                    t = k;
                    break;
                }
            }
            string             parentPath = nodePath.Substring(0, t);
            IList <NodeAtTime> parli;

            if (nodes.TryGetValue(parentPath, out parli))
            {
                if (parli.Count > 0)
                {
                    parent = parli[parli.Count - 1];
                }
            }
            else if (!String.IsNullOrEmpty(parentPath))
            {
                Progress.DebugLog("Could not find Parent \"{0}\"", parentPath);
            }
            //-------

            if (changeItem.CopyFromPath != null)
            {
                string cpFromPath = changeItem.CopyFromPath.Length > 1 ? changeItem.CopyFromPath.Substring(1) : "";

                var previousNode = GetNodeAtTime(cpFromPath, changeItem.CopyFromRevision);
                if (previousNode != null)
                {
                    AddCopy(nodePath, previousNode, parent, revision, changeItem.CopyFromRevision, ref filesCopiedThisRevision);
                }
                else
                {
                    Progress.DebugLog("Ancestor of {0}@{1} not found: {2}@{3}", nodePath, revision, cpFromPath, changeItem.CopyFromRevision);
                    return;
                }
            }
            else
            {
                NodeAtTime newlyAdded;

                IList <NodeAtTime> nodesWithSamePath;
                if (!nodes.TryGetValue(nodePath, out nodesWithSamePath))
                {
                    nodes[nodePath] = nodesWithSamePath = new List <NodeAtTime>();
                }

                newlyAdded = new NodeAtTime(nodePath, revision);

                if (parent != null)
                {
                    parent.AddChild(newlyAdded);
                }

                if (changeItem.NodeKind == SvnNodeKind.Directory)
                {
                    newlyAdded.SetIsFolder();
                }
                else if (changeItem.NodeKind == SvnNodeKind.File)
                {
                    newlyAdded.SetIsFile();
                }

                nodesWithSamePath.Add(newlyAdded);
            }
        }