private bool ProcessRename(string oldName, string newName) { if (_alreadyProcessed.Contains(newName)) { return(true); } SvnItem old = SvnCache[oldName]; SvnItem nw = SvnCache[newName]; if (old.IsVersioned && !old.IsDeleteScheduled && nw.IsVersionable && (!nw.IsVersioned || nw.IsDeleteScheduled)) { SvnItem opp = nw.Parent; using (SvnSccContext ctx = new SvnSccContext(this)) { if (opp != null && !opp.IsVersioned) { ctx.AddParents(newName); } ctx.MetaMove(oldName, newName); _alreadyProcessed.Add(newName); return(true); } } return(false); }
/// <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); }
/// <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); }