Пример #1
0
        internal void OnSccCleanup(CommandEventArgs e)
        {
            _registeredSccCleanup = false;

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

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

            if (_syncMap)
            {
                _syncMap = false;

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

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

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

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

                using (SvnSccContext svn = new SvnSccContext(Context))
                {
                    foreach (FixUp fu in files)
                    {
                        if (!svn.IsUnversioned(fu.From) && svn.IsUnversioned(fu.To))
                        {
                            svn.SafeWcMoveFixup(fu.From, fu.To);
                        }
                    }
                }
            }
            if (_backupMap.Count > 0)
            {
                using (SvnSccContext svn = new SvnSccContext(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.
                            svn.DeleteDirectory(backupDir);
                        }
                        else
                        {
                            // Original is gone, must be a delete, put back backup so we can svn-delete it
                            SvnSccContext.RetriedRename(backupDir, originalDir); // Use retried rename, to prevent virus-scanner locks
                            svn.WcDelete(originalDir);
                        }
                    }
                }
                _backupMap.Clear();
            }
        }
Пример #2
0
        /// <summary>
        /// Called when a file is removed from a project
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="filename">The filename.</param>
        /// <param name="flags">The flags.</param>
        internal void OnProjectFileRemoved(IVsSccProject2 project, string filename, VSREMOVEFILEFLAGS flags)
        {
            SccProjectData data;
            if (!_projectMap.TryGetValue(project, out data))
                return; // Not managed by us

            data.RemovePath(filename);

            if (!IsActive)
                return; // Let the other SCC package manage it

            MarkDirty(filename);

            if (SvnUpdatesDisabled || !StatusCache[filename].IsVersioned)
                return; // Don't bother

            using (SvnSccContext svn = new SvnSccContext(Context))
            {
                if (File.Exists(filename))
                {
                    // The file was only removed from the project. We should not touch it

                    // Some projects delete the file before (C#) and some after (C++) calling OnProjectFileRemoved
                    if (_delayedDelete == null)
                        _delayedDelete = new List<string>();

                    if (!_delayedDelete.Contains(filename))
                        _delayedDelete.Add(filename);

                    RegisterForSccCleanup();
                    return;
                }

                if (svn.IsUnversioned(filename))
                    return;

                svn.SafeDeleteFile(filename);
            }
        }