public int OnBeforeCloseSolution(object pUnkReserved)
        {
            _solutionLoaded = false;
            if (SccProvider.IsActive)
            {
                SccEvents.OnStartedSolutionClose();
            }

            return(VSErr.S_OK);
        }
Esempio n. 2
0
        public int OnAfterRenameDirectories(int cProjects, int cDirs, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgszMkOldNames, string[] rgszMkNewNames, VSRENAMEDIRECTORYFLAGS[] rgFlags)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (rgszMkNewNames == null || rgpProjects == null || rgszMkOldNames == null)
            {
                return(VSErr.E_POINTER);
            }

            int iDirectory = 0;

            for (int i = 0; i < cDirs; i++)
            {
                string s = rgszMkOldNames[i];
                if (!string.IsNullOrEmpty(s))
                {
                    SvnCache.MarkDirty(s);
                }

                s = rgszMkNewNames[i];
                if (!string.IsNullOrEmpty(s))
                {
                    SvnCache.MarkDirty(s);
                }
            }

            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }

            ProcessRenames(rgszMkOldNames, rgszMkNewNames);

            for (int iProject = 0; (iProject < cProjects) && (iDirectory < cDirs); iProject++)
            {
                int iLastDirectoryThisProject = (iProject < cProjects - 1) ? rgFirstIndices[iProject + 1] : cDirs;

                IVsSccProject2 sccProject = rgpProjects[iProject] as IVsSccProject2;

                bool track = SccEvents.TrackProjectChanges(sccProject);

                for (; iDirectory < iLastDirectoryThisProject; iDirectory++)
                {
                    if (sccProject == null || !track)
                    {
                        continue; // Not handled by our provider
                    }
                    SccEvents.OnProjectDirectoryRenamed(sccProject,
                                                        SvnTools.GetNormalizedFullPath(rgszMkOldNames[iDirectory]),
                                                        SvnTools.GetNormalizedFullPath(rgszMkNewNames[iDirectory]), rgFlags[iDirectory]);
                }
            }

            return(VSErr.S_OK);
        }
        public int OnAfterCloseSolution(object pUnkReserved)
        {
            if (SccProvider.IsActive)
            {
                SccEvents.OnSolutionClosed();
            }

            GetService <IAnkhServiceEvents>().OnSolutionClosed(EventArgs.Empty);

            return(VSErr.S_OK);
        }
Esempio n. 4
0
        private void LoadInitial()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            IVsSolution solution = GetService <IVsSolution>(typeof(SVsSolution));

            if (solution == null)
            {
                return;
            }

            string dir, file, user;

            if (!VSErr.Succeeded(solution.GetSolutionInfo(out dir, out file, out user)) ||
                string.IsNullOrEmpty(file))
            {
                return; // No solution loaded, nothing to load
            }

            Guid             none = Guid.Empty;
            IEnumHierarchies hierEnum;

            if (!VSErr.Succeeded(solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref none, out hierEnum)))
            {
                return;
            }

            IVsHierarchy[] hiers = new IVsHierarchy[32];
            uint           nFetched;

            while (VSErr.Succeeded(hierEnum.Next((uint)hiers.Length, hiers, out nFetched)))
            {
                if (nFetched == 0)
                {
                    break;
                }
                for (int i = 0; i < nFetched; i++)
                {
                    IVsSccProject2 p2 = hiers[i] as IVsSccProject2;

                    if (p2 != null)
                    {
                        SccEvents.OnProjectOpened(p2, false);
                    }
                }
            }

            _solutionLoaded = true;
            SccEvents.OnSolutionOpened(false);
        }
Esempio n. 5
0
        public int OnAfterAsynchOpenProject(IVsHierarchy pHierarchy, int fAdded)
        {
            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }

            IVsSccProject2 project = pHierarchy as IVsSccProject2;

            if (project != null)
            {
                SccEvents.OnProjectOpened(project, fAdded != 0);
            }

            return(VSErr.S_OK);
        }
Esempio n. 6
0
        public int OnBeforeUnloadProject(IVsHierarchy pRealHierarchy, IVsHierarchy pStubHierarchy)
        {
            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }

            IVsSccProject2 project = pRealHierarchy as IVsSccProject2;

            if (project != null)
            {
                SccEvents.OnProjectBeforeUnload(project, pStubHierarchy);
            }

            return(VSErr.S_OK);
        }
Esempio n. 7
0
        public int OnBeforeCloseProject(IVsHierarchy pHierarchy, int fRemoved)
        {
            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }

            IVsSccProject2 project = pHierarchy as IVsSccProject2;

            if (project != null)
            {
                SccEvents.OnProjectClosed(project, fRemoved != 0);
            }

            return(VSErr.S_OK);
        }
Esempio n. 8
0
        public int OnAfterRenameProject(IVsHierarchy pHierarchy)
        {
            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }

            IVsSccProject2 project = pHierarchy as IVsSccProject2;

            if (project != null)
            {
                // SccProvider forwards this to the SccStore
                SccEvents.OnProjectRenamed(project);
            }

            return(VSErr.S_OK);
        }
        public int OnAfterLoadProject(IVsHierarchy pStubHierarchy, IVsHierarchy pRealHierarchy)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }

            IVsSccProject2 project = pRealHierarchy as IVsSccProject2;

            if (project != null)
            {
                SccEvents.OnProjectLoaded(project);
            }

            return(VSErr.S_OK);
        }
        public int OnAfterRemoveDirectories(int cProjects, int cDirectories, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEDIRECTORYFLAGS[] rgFlags)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (rgpProjects == null || rgpszMkDocuments == null)
            {
                return(VSErr.E_POINTER);
            }

            for (int iProject = 0, iDirectory = 0; (iProject < cProjects) && (iDirectory < cDirectories); iProject++)
            {
                int iLastDirectoryThisProject = (iProject < cProjects - 1) ? rgFirstIndices[iProject + 1] : cDirectories;

                IVsSccProject2 sccProject = rgpProjects[iProject] as IVsSccProject2;
                bool           track      = SccEvents.TrackProjectChanges(sccProject);

                for (; iDirectory < iLastDirectoryThisProject; iDirectory++)
                {
                    if (sccProject == null || !track)
                    {
                        continue; // Not handled by our provider
                    }
                    string dir = rgpszMkDocuments[iDirectory];

                    if (!SvnItem.IsValidPath(dir))
                    {
                        continue;
                    }

                    dir = SvnTools.GetNormalizedFullPath(dir);

                    SccEvents.OnProjectDirectoryRemoved(sccProject, dir, rgFlags[iDirectory]);

                    if (SccProvider.IsActive && track)
                    {
                        SccEvents.AddDelayedDelete(dir);
                    }
                }
            }

            return(VSErr.S_OK);
        }
Esempio n. 11
0
        public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
        {
            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }

            IVsSccProject2 project = pHierarchy as IVsSccProject2;

            if (project != null)
            {
                SccEvents.OnProjectOpened(project, fAdded != 0);
            }
            //else
            //{
            //  IVsSccVirtualFolders vf = pHierarchy as IVsSccVirtualFolders; // Available for webprojects on a server
            //}

            return(VSErr.S_OK);
        }
        public int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (rgpProjects == null || rgpszMkDocuments == null)
            {
                return(VSErr.E_POINTER);
            }

            for (int iProject = 0, iFile = 0; (iProject < cProjects) && (iFile < cFiles); iProject++)
            {
                int iLastFileThisProject = (iProject < cProjects - 1) ? rgFirstIndices[iProject + 1] : cFiles;

                IVsSccProject2 sccProject = rgpProjects[iProject] as IVsSccProject2;
                bool           track      = SccEvents.TrackProjectChanges(sccProject);

                for (; iFile < iLastFileThisProject; iFile++)
                {
                    if (sccProject == null || !track)
                    {
                        continue; // Not handled by our provider
                    }
                    string file = rgpszMkDocuments[iFile];

                    if (!SvnItem.IsValidPath(file))
                    {
                        continue;
                    }

                    file = SvnTools.GetNormalizedFullPath(file);

                    SccEvents.OnProjectFileRemoved(sccProject, file);

                    if (SccProvider.IsActive && track)
                    {
                        SccEvents.AddDelayedDelete(file);
                    }
                }
            }
            return(VSErr.S_OK);
        }
Esempio n. 13
0
 private void OnSolutionRefreshCommand(object sender, EventArgs e)
 {
     SccEvents.OnSolutionRefreshCommand(e);
 }
Esempio n. 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cProjects"></param>
        /// <param name="cDirectories"></param>
        /// <param name="rgpProjects"></param>
        /// <param name="rgFirstIndices"></param>
        /// <param name="rgpszMkDocuments"></param>
        /// <param name="rgFlags"></param>
        /// <returns></returns>
        /// <remarks>Deny a query only if allowing the operation would compromise your stable state</remarks>
        public int OnAfterAddDirectoriesEx(int cProjects, int cDirectories, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDDIRECTORYFLAGS[] rgFlags)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (rgpProjects == null || rgpszMkDocuments == null)
            {
                return(VSErr.E_POINTER);
            }

            bool sccActive = SccProvider.IsActive;

            for (int iProject = 0, iDir = 0; (iProject < cProjects) && (iDir < cDirectories); iProject++)
            {
                int iLastDirectoryThisProject = (iProject < cProjects - 1) ? rgFirstIndices[iProject + 1] : cDirectories;

                IVsSccProject2 sccProject = rgpProjects[iProject] as IVsSccProject2;

                bool trackCopies;
                bool track = SccEvents.TrackProjectChanges(sccProject, out trackCopies);

                for (; iDir < iLastDirectoryThisProject; iDir++)
                {
                    if (!track)
                    {
                        continue;
                    }

                    string dir = rgpszMkDocuments[iDir];

                    if (!SvnItem.IsValidPath(dir))
                    {
                        continue;
                    }

                    dir = SvnTools.GetNormalizedFullPath(dir);
                    string origin = null;

                    if (sccActive && _solutionLoaded)
                    {
                        SvnCache.MarkDirty(dir);
                        TryFindOrigin(dir, out origin);
                    }

                    if (sccProject != null)
                    {
                        SccEvents.OnProjectDirectoryAdded(sccProject, dir, origin);
                    }

                    if (sccActive && trackCopies &&
                        !string.IsNullOrEmpty(origin) &&
                        SvnCache[origin].HasCopyableHistory)
                    {
                        using (SvnSccContext svn = new SvnSccContext(this))
                        {
                            svn.AddParents(dir);
                            svn.MetaCopy(origin, dir);
                        }
                    }
                }
            }

            return(VSErr.S_OK);
        }
Esempio n. 15
0
        public int OnAfterRenameFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgszMkOldNames, string[] rgszMkNewNames, VSRENAMEFILEFLAGS[] rgFlags)
        {
            if (rgszMkNewNames == null || rgpProjects == null || rgszMkOldNames == null || rgszMkOldNames.Length != rgszMkNewNames.Length)
            {
                return(VSErr.E_POINTER);
            }

            // TODO: C++ projects do not send directory renames; but do send OnAfterRenameFile() events
            //       for all files (one at a time). We should detect that case here and fix up this dirt!

            for (int i = 0; i < cFiles; i++)
            {
                string s = rgszMkOldNames[i];
                if (SvnItem.IsValidPath(s))
                {
                    SvnCache.MarkDirty(s);
                }

                s = rgszMkNewNames[i];
                if (SvnItem.IsValidPath(s))
                {
                    SvnCache.MarkDirty(s);
                }
            }

            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }

            ProcessRenames(rgszMkOldNames, rgszMkNewNames);

            for (int iProject = 0, iFile = 0; (iProject < cProjects) && (iFile < cFiles); iProject++)
            {
                int iLastFileThisProject = (iProject < cProjects - 1) ? rgFirstIndices[iProject + 1] : cFiles;

                if (rgpProjects[iProject] != null)
                {
                    IVsSccProject2 sccProject = rgpProjects[iProject] as IVsSccProject2;

                    bool track = SccEvents.TrackProjectChanges(sccProject);

                    for (; iFile < iLastFileThisProject; iFile++)
                    {
                        if (sccProject == null || !track)
                        {
                            continue; // Not handled by our provider
                        }
                        if (!SvnItem.IsValidPath(rgszMkOldNames[iFile]))
                        {
                            continue;
                        }

                        string oldName = SvnTools.GetNormalizedFullPath(rgszMkOldNames[iFile]);
                        string newName = SvnTools.GetNormalizedFullPath(rgszMkNewNames[iFile]);

                        if (oldName == newName)
                        {
                            continue;
                        }

                        SccEvents.OnProjectFileRenamed(sccProject, oldName, newName, rgFlags[iFile]);
                    }
                }
                else
                {
                    // Renaming something in the solution (= solution file itself)
                    for (; iFile < iLastFileThisProject; iFile++)
                    {
                        if (!SvnItem.IsValidPath(rgszMkOldNames[iFile]))
                        {
                            continue;
                        }

                        string oldName = SvnTools.GetNormalizedFullPath(rgszMkOldNames[iFile]);
                        string newName = SvnTools.GetNormalizedFullPath(rgszMkNewNames[iFile]);

                        if (oldName != newName)
                        {
                            SccEvents.OnSolutionRenamedFile(oldName, newName);
                        }

                        SccEvents.Translate_SolutionRenamed(rgszMkOldNames[iFile], rgszMkNewNames[iFile]);
                    }
                }
            }

            return(VSErr.S_OK);
        }
        public int OnAfterOpenSolution(object pUnkReserved, int fNewSolution)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            _solutionLoaded = true;
            SccEvents.OnSolutionOpened(true);

            GetService <IAnkhServiceEvents>().OnSolutionOpened(EventArgs.Empty);

            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }
            try
            {
                VerifySolutionNaming();

                IAnkhSolutionSettings ss = GetService <IAnkhSolutionSettings>();

                if (ss != null && ss.ProjectRoot != null)
                {
                    string rootDir = Path.GetPathRoot(ss.ProjectRoot);
                    if (rootDir.Length == 3 && rootDir.EndsWith(":\\", StringComparison.OrdinalIgnoreCase))
                    {
                        DriveInfo di    = new DriveInfo(rootDir);
                        bool      oldFs = false;

                        switch ((di.DriveFormat ?? "").ToUpperInvariant())
                        {
                        case "FAT32":
                        case "FAT":
                            oldFs = true;
                            break;
                        }

                        if (oldFs)
                        {
                            IAnkhConfigurationService cs = GetService <IAnkhConfigurationService>();

                            if (!cs.GetWarningBool(AnkhWarningBool.FatFsFound))
                            {
                                using (SccFilesystemWarningDialog dlg = new SccFilesystemWarningDialog())
                                {
                                    dlg.Text = Path.GetFileName(ss.SolutionFilename);
                                    if (DialogResult.OK == dlg.ShowDialog(Context))
                                    {
                                        cs.SetWarningBool(AnkhWarningBool.FatFsFound, true);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                IAnkhErrorHandler handler = GetService <IAnkhErrorHandler>();

                if (handler.IsEnabled(ex))
                {
                    handler.OnError(ex);
                }
                else
                {
                    throw;
                }
            }

            return(VSErr.S_OK);
        }
Esempio n. 17
0
        /// <summary>
        /// This method notifies the client after a project has added files.
        /// </summary>
        /// <param name="cProjects">[in] Number of projects to which files were added.</param>
        /// <param name="cFiles">[in] Number of files that were added.</param>
        /// <param name="rgpProjects">[in] Array of projects to which files were added.</param>
        /// <param name="rgFirstIndices">[in] Array of first indices identifying which project each file belongs to. For more information, see IVsTrackProjectDocumentsEvents2.</param>
        /// <param name="rgpszMkDocuments">[in] Array of paths for the files that were processed. This is the same size as cFiles.</param>
        /// <param name="rgFlags">[in] Array of flags. For a list of rgFlags values, see <see cref="VSADDFILEFLAGS" />.</param>
        /// <returns></returns>
        public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            RegisterForSccCleanup(); // Clear the origins table after adding

            SortedList <string, string> copies = null;

            bool sccActive = SccProvider.IsActive;

            for (int iProject = 0, iFile = 0; (iProject < cProjects) && (iFile < cFiles); iProject++)
            {
                int iLastFileThisProject = (iProject < cProjects - 1) ? rgFirstIndices[iProject + 1] : cFiles;

                IVsSccProject2 sccProject = rgpProjects[iProject] as IVsSccProject2;

                bool trackCopies;
                bool track = SccEvents.TrackProjectChanges(sccProject, out trackCopies);

                for (; iFile < iLastFileThisProject; iFile++)
                {
                    if (!track)
                    {
                        continue; // Not handled by our provider
                    }
                    string origin  = null;
                    string newName = rgpszMkDocuments[iFile];

                    if (!SvnItem.IsValidPath(newName))
                    {
                        continue;
                    }

                    newName = SvnTools.GetNormalizedFullPath(newName);

                    if (sccActive && _solutionLoaded)
                    {
                        SvnCache.MarkDirty(newName);
                        TryFindOrigin(newName, out origin);
                    }

                    // We do this before the copies to make sure a failed copy doesn't break the project
                    SccEvents.OnProjectFileAdded(sccProject, newName);

                    if (sccActive && trackCopies &&
                        !string.IsNullOrEmpty(origin) &&
                        SvnCache[origin].HasCopyableHistory)
                    {
                        if (copies == null)
                        {
                            copies = new SortedList <string, string>(StringComparer.OrdinalIgnoreCase);
                        }

                        copies[newName] = origin;
                    }
                }
            }

            if (copies != null)
            {
                using (SvnSccContext svn = new SvnSccContext(Context))
                {
                    foreach (KeyValuePair <string, string> kv in copies)
                    {
                        svn.AddParents(kv.Key);
                        svn.MetaCopy(kv.Value, kv.Key);
                    }
                }
            }

            return(VSErr.S_OK);
        }