/// <summary>
        /// Called when a file in a project is renamed
        /// </summary>
        /// <param name="project">The SCC project.</param>
        /// <param name="oldName">The old name.</param>
        /// <param name="newName">The new name.</param>
        /// <param name="flags">The flags.</param>
        internal void OnProjectRenamedFile(IVsSccProject2 project, string oldName, string newName, VSRENAMEFILEFLAGS flags)
        {
            SccProjectData data;
            if (!_projectMap.TryGetValue(project, out data))
                return; // Not managed by us
            else
                data.CheckProjectRename(project, oldName, newName); // Just to be sure (should be handled by other event)

            data.RemovePath(oldName);
            data.AddPath(newName);

            if (!IsActive)
                return;

            using (GitSccContext git = new GitSccContext(Context))
            {
                if (!git.IsUnversioned(oldName))
                {
                    if (!Directory.Exists(newName)) // Fails if the new name is a directory!
                        git.SafeWcMoveFixup(oldName, newName);
                }

                MarkDirty(new string[] { oldName, newName }, true);
            }
        }
        internal void OnSolutionRenamedFile(string oldName, string newName, VSRENAMEFILEFLAGS flags)
        {
            if (!IsActive)
                return;

            _solutionDirectory = _solutionFile = null; // Get new data after this rename

            using (GitSccContext git = new GitSccContext(Context))
            {
                if (!git.IsUnversioned(oldName))
                {
                    try
                    {
                        git.SafeWcMoveFixup(oldName, newName);
                    }
                    catch (IOException)
                    {
                        if (_delayedMove == null)
                            _delayedMove = new List<FixUp>();
                        _delayedMove.Add(new FixUp(oldName, newName));

                        RegisterForSccCleanup();
                    }

                    MarkDirty(new string[] { oldName, newName }, true);
                }
            }

            Monitor.ScheduleGlyphUpdate(SolutionFilename);
        }
        internal void OnSccCleanup(CommandEventArgs e)
        {
            _registeredSccCleanup = false;

            if ((_ensureIcons || _syncMap) && IsActive)
            {
                // Enable our custom glyphs when we are set active
                IVisualGitSolutionExplorerWindow solutionExplorer = GetService<IVisualGitSolutionExplorerWindow>();

                if (solutionExplorer != null)
                    solutionExplorer.EnableVisualGitIcons(true);
            }

            if (_syncMap)
            {
                _syncMap = false;

                foreach (SccProjectData pd in _projectMap.Values)
                    pd.Load();
            }

            if (_delayedDelete != null)
            {
                List<string> files = _delayedDelete;
                _delayedDelete = null;

                using (GitSccContext git = new GitSccContext(Context))
                {
                    foreach (string file in files)
                    {
                        if (!File.Exists(file))
                        {
                            git.SafeDeleteFile(file);
                            MarkDirty(file);
                        }
                    }
                }
            }

            if (_delayedMove != null)
            {
                List<FixUp> files = _delayedMove;
                _delayedMove = null;

                using (GitSccContext git = new GitSccContext(Context))
                {
                    foreach (FixUp fu in files)
                    {
                        if (!git.IsUnversioned(fu.From) && git.IsUnversioned(fu.To))
                        {
                            git.SafeWcMoveFixup(fu.From, fu.To);
                        }
                    }
                }
            }
            if (_backupMap.Count > 0)
            {
                using (GitSccContext git = new GitSccContext(Context))
                {
                    foreach (KeyValuePair<string, string> dir in _backupMap)
                    {
                        string originalDir = dir.Key;
                        string backupDir = dir.Value;

                        if (!Directory.Exists(backupDir))
                            continue; // No backupdir, we can't delete or move it

                        if (Directory.Exists(originalDir))
                        {
                            // The original has not been deleted by visual studio, must be an exclude.
                            git.DeleteDirectory(backupDir);
                        }
                        else
                        {
                            // Original is gone, must be a delete, put back backup so we can git-delete it
                            GitSccContext.RetriedRename(backupDir, originalDir); // Use retried rename, to prevent virus-scanner locks
                            git.WcDelete(originalDir);
                        }
                    }
                }
                _backupMap.Clear();
            }
        }