/// <summary>
        /// Defines a method to call after a project upgrade.
        /// </summary>
        /// <param name="pHierarchy">[in] Pointer to the <see cref="T:Microsoft.VisualStudio.Shell.Interop.IVsHierarchy"></see> interface of the project.</param>
        /// <param name="fUpgradeFlag">[in] Integer. Flag indicating the nature of the upgrade. Values taken from the <see cref="T:Microsoft.VisualStudio.Shell.Interop.__VSPPROJECTUPGRADEVIAFACTORYFLAGS"></see> enumeration. Will only be PUVFF_COPYUPGRADE, PUVFF_SXSBACKUP, or PUVFF_COPYBACKUP.</param>
        /// <param name="bstrCopyLocation">[in] String containing the location of the copy upgrade (PUVFF_COPYUPGRADE) or back up copy (PUVFF_COPYBACKUP).</param>
        /// <param name="stUpgradeTime">[in] A <see cref="T:Microsoft.VisualStudio.Shell.Interop.SYSTEMTIME"></see> value. The time the upgrade was done.</param>
        /// <param name="pLogger">[in] Pointer to an <see cref="T:Microsoft.VisualStudio.Shell.Interop.IVsUpgradeLogger"></see> interface to use for logging upgrade messages.</param>
        /// <returns>
        /// If the method succeeds, it returns <see cref="F:Microsoft.VisualStudio.VSErr.S_OK"></see>. If it fails, it returns an error code.
        /// </returns>
        public int OnAfterUpgradeProject(IVsHierarchy pHierarchy, uint fUpgradeFlag, string bstrCopyLocation, SYSTEMTIME stUpgradeTime, IVsUpgradeLogger pLogger)
        {
            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }

            IProjectFileMapper mapper  = GetService <IProjectFileMapper>();
            IFileStatusMonitor monitor = GetService <IFileStatusMonitor>();

            if (monitor == null || mapper == null)
            {
                return(VSErr.S_OK);
            }

            if (SccProvider.IsSafeSccPath(bstrCopyLocation))
            {
                monitor.ScheduleSvnStatus(bstrCopyLocation);
            }

            IVsSccProject2 project = pHierarchy as IVsSccProject2;

            if (project != null)
            {
                ISccProjectInfo info = mapper.GetProjectInfo(new SccProject(null, project));

                if (info != null && !string.IsNullOrEmpty(info.ProjectFile))
                {
                    monitor.ScheduleSvnStatus(info.ProjectFile);
                }
            }

            return(VSErr.S_OK);
        }
示例#2
0
        private void OnSvnSccProviderActivated(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            _sccProvider = GetService <SvnSccProvider>();
            Hook(true, true);
            LoadInitial();
        }
示例#3
0
        public int OnQueryRenameDirectories(IVsProject pProject, int cDirs, string[] rgszMkOldNames, string[] rgszMkNewNames, VSQUERYRENAMEDIRECTORYFLAGS[] rgFlags, VSQUERYRENAMEDIRECTORYRESULTS[] pSummaryResult, VSQUERYRENAMEDIRECTORYRESULTS[] rgResults)
        {
            if (rgszMkNewNames == null || pProject == null || rgszMkOldNames == null)
            {
                return(VSErr.E_POINTER);
            }

            RegisterForSccCleanup(); // Clear the origins
            _collectHints = true;

            for (int i = 0; i < cDirs; i++)
            {
                if (rgResults != null)
                {
                    rgResults[i] = VSQUERYRENAMEDIRECTORYRESULTS.VSQUERYRENAMEDIRECTORYRESULTS_RenameOK;
                }

                string newDoc  = rgszMkNewNames[i];
                string origDoc = rgszMkOldNames[i];

                if (!SccProvider.IsSafeSccPath(newDoc))
                {
                    continue;
                }
                else if (!SccProvider.IsSafeSccPath(origDoc))
                {
                    continue;
                }

                // Save the origins of the to be added files as they are not available in the added event
                newDoc  = SvnTools.GetNormalizedFullPath(newDoc);
                origDoc = SvnTools.GetNormalizedFullPath(origDoc);

                if (newDoc != origDoc)
                {
                    _fileOrigins[newDoc] = origDoc;
                }
                else if (!_fileOrigins.ContainsKey(newDoc))
                {
                    _fileOrigins[newDoc] = null;
                }
            }

            if (pSummaryResult != null)
            {
                pSummaryResult[0] = VSQUERYRENAMEDIRECTORYRESULTS.VSQUERYRENAMEDIRECTORYRESULTS_RenameOK;
            }

            return(VSErr.S_OK);
        }
示例#4
0
        /// <summary>
        /// Determines if it is okay to add a collection of files (possibly from source control) whose final destination may be different from a source location.
        /// </summary>
        /// <param name="pProject">[in] Project making the request about adding files.</param>
        /// <param name="cFiles">[in] The number of files represented in the rgpszNewMkDocuments, rgpszSrcMkDocuments, rgFlags, and rgResults arrays.</param>
        /// <param name="rgpszNewMkDocuments">[in] An array of file names that indicate the files' final destination.</param>
        /// <param name="rgpszSrcMkDocuments">[in] An array of file names specifying the source location of the files.</param>
        /// <param name="rgFlags">[in] An array of values, one element for each file, from the <see cref="T:Microsoft.VisualStudio.Shell.Interop.VSQUERYADDFILEFLAGS"></see> enumeration.</param>
        /// <param name="pSummaryResult">[out] Returns an overall status for all files as a value from the <see cref="T:Microsoft.VisualStudio.Shell.Interop.VSQUERYADDFILERESULTS"></see> enumeration.</param>
        /// <param name="rgResults">[out] An array that is to be filled in with the status of each file. Each status is a value from the <see cref="T:Microsoft.VisualStudio.Shell.Interop.VSQUERYADDFILERESULTS"></see> enumeration.</param>
        /// <returns>
        /// If the method succeeds, it returns <see cref="F:Microsoft.VisualStudio.VSErr.S_OK"></see>. If it fails, it returns an error code.
        /// </returns>
        /// <remarks>Deny a query only if allowing the operation would compromise your stable state</remarks>
        public int OnQueryAddFilesEx(IVsProject pProject, int cFiles, string[] rgpszNewMkDocuments, string[] rgpszSrcMkDocuments, VSQUERYADDFILEFLAGS[] rgFlags, VSQUERYADDFILERESULTS[] pSummaryResult, VSQUERYADDFILERESULTS[] rgResults)
        {
            // For now, we allow adding all files as is
            // We might propose moving files to within a managed root

            RegisterForSccCleanup(); // Clear the origins table after adding
            _collectHints = true;    // Some projects call HandsOff(file) on which files they wish to import. Use that to get more information

            for (int i = 0; i < cFiles; i++)
            {
                rgResults[i] = VSQUERYADDFILERESULTS.VSQUERYADDFILERESULTS_AddOK;

                string newDoc  = rgpszNewMkDocuments[i];
                string origDoc = rgpszSrcMkDocuments[i];

                if (!SccProvider.IsSafeSccPath(newDoc))
                {
                    continue;
                }
                else if (!SccProvider.IsSafeSccPath(origDoc))
                {
                    continue;
                }

                // Save the origins of the to be added files as they are not available in the added event
                newDoc  = SvnTools.GetNormalizedFullPath(newDoc);
                origDoc = SvnTools.GetNormalizedFullPath(origDoc);

                // Some additions (e.g. drag&drop in C# project report the same locations. We use the hints later, but collect the targets anyway
                if (newDoc != origDoc)
                {
                    _fileOrigins[newDoc] = origDoc;
                }
                else if (!_fileOrigins.ContainsKey(newDoc))
                {
                    _fileOrigins[newDoc] = null;
                }
            }

            if (pSummaryResult != null)
            {
                pSummaryResult[0] = VSQUERYADDFILERESULTS.VSQUERYADDFILERESULTS_AddOK;
            }

            return(VSErr.S_OK);
        }
示例#5
0
        /// <summary>
        /// Accesses a specified set of files and asks all implementers of this method to release any locks that may exist on those files.
        /// </summary>
        /// <param name="grfRequiredAccess">[in] A value from the <see cref="T:Microsoft.VisualStudio.Shell.Interop.__HANDSOFFMODE"></see> enumeration, indicating the type of access requested. This can be used to optimize the locks that actually need to be released.</param>
        /// <param name="cFiles">[in] The number of files in the rgpszMkDocuments array.</param>
        /// <param name="rgpszMkDocuments">[in] If there are any locks on this array of file names, the caller wants them to be released.</param>
        /// <returns>
        /// If the method succeeds, it returns <see cref="F:Microsoft.VisualStudio.VSErr.S_OK"></see>. If it fails, it returns an error code.
        /// </returns>
        public int HandsOffFiles(uint grfRequiredAccess, int cFiles, string[] rgpszMkDocuments)
        {
            if (_collectHints && rgpszMkDocuments != null)
            {
                // Some projects call HandsOffFiles of files they want to add. Use that to collect extra origin information
                foreach (string file in rgpszMkDocuments)
                {
                    if (!SccProvider.IsSafeSccPath(file))
                    {
                        continue;
                    }

                    string fullFile = SvnTools.GetNormalizedFullPath(file);
                    if (!_fileHints.Contains(fullFile))
                    {
                        _fileHints.Add(fullFile);
                    }
                }
            }
            return(VSErr.S_OK);
        }
示例#6
0
 private void OnGitSccProviderActivated(object sender, EventArgs e)
 {
     _sccProvider = GetService <ITheAnkhGitSccProvider>() as SccProvider;
     Hook(true, true);
     LoadInitial();
 }
示例#7
0
 private void OnSvnSccProviderActivated(object sender, EventArgs e)
 {
     _sccProvider = GetService <SvnSccProvider>();
     Hook(true, true);
     LoadInitial();
 }