/// <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); }
void OnExited(object sender, EventArgs e) { Process process = sender as Process; IAnkhCommandService cmd = GetService <IAnkhCommandService>(); if (cmd != null) { cmd.PostIdleAction(Dispose); } else { Dispose(); } if (process != null && _resolvedExitCodes != null) { foreach (int ec in _resolvedExitCodes) { if (ec == process.ExitCode) { cmd.PostIdleAction(MarkResolved); break; } } } IFileStatusMonitor m = GetService <IFileStatusMonitor>(); if (m != null) { m.ScheduleSvnStatus(_toMonitor); } }
public int FilesChanged(uint cChanges, string[] rgpszFile, uint[] rggrfChange) { if (rgpszFile == null || cChanges == 0) { return(VSErr.S_OK); } try { string[] nFiles = new string[cChanges]; for (int i = 0; i < cChanges; i++) { nFiles[i] = SvnTools.GetNormalizedFullPath(rgpszFile[i]); } IFileStatusMonitor monitor = GetService <IFileStatusMonitor>(); monitor.ScheduleSvnStatus(nFiles); } catch (Exception ex) { IAnkhErrorHandler eh = GetService <IAnkhErrorHandler>(); if (eh != null && eh.IsEnabled(ex)) { eh.OnError(ex); } else { throw; } } return(VSErr.S_OK); }
public void OnSaved() { SetDirty(false); if (!_isFileDocument) { return; } IFileStatusMonitor statusMonitor = GetService <IFileStatusMonitor>(); statusMonitor.ScheduleSvnStatus(FullPath); }
public override void OnExecute(CommandEventArgs e) { // Refresh all global states on the selected files // * File Status Cache // * Glyph cache (in VS Projects) // * Pending changes // * Editor dirty state // Don't handle individual windows here, they can just override the refresh handler // See WorkingCopyExplorerControl.OnFrameCreated() for some examples on how to do that IFileStatusMonitor monitor = e.GetService <IFileStatusMonitor>(); monitor.ScheduleSvnStatus(e.Selection.GetSelectedFiles(true)); IAnkhOpenDocumentTracker dt = e.GetService <IAnkhOpenDocumentTracker>(); dt.RefreshDirtyState(); IPendingChangesManager pm = e.GetService <IPendingChangesManager>(); pm.Refresh((string)null); // Perform a full incremental refresh on the PC window }
static void SetProjectsManaged(CommandEventArgs e) { ISvnStatusCache cache = e.GetService <ISvnStatusCache>(); IFileStatusMonitor monitor = e.GetService <IFileStatusMonitor>(); IAnkhSccService scc = e.GetService <IAnkhSccService>(); IProjectFileMapper mapper = e.GetService <IProjectFileMapper>(); AnkhMessageBox mb = new AnkhMessageBox(e.Context); if (mapper == null) { return; } List <SccProject> projectsToBeManaged = new List <SccProject>(); SvnItem slnItem = cache[e.Selection.SolutionFilename]; Uri solutionReposRoot = null; if (slnItem.WorkingCopy != null) { solutionReposRoot = slnItem.WorkingCopy.RepositoryRoot; foreach (SccProject project in GetSelection(e.Selection)) { ISccProjectInfo projInfo = mapper.GetProjectInfo(project); if (projInfo == null || projInfo.ProjectDirectory == null || !projInfo.IsSccBindable) { continue; // Some projects can't be managed } SvnItem projectDir = cache[projInfo.ProjectDirectory]; if (projectDir.WorkingCopy == slnItem.WorkingCopy) { // This is a 'normal' project, part of the solution and in the same working copy projectsToBeManaged.Add(project); continue; } bool markAsManaged; bool writeReference; if (projectDir.IsVersioned) { continue; // We don't have to add this one } if (projectDir.IsVersionable) { SvnItem parentDir = GetVersionedParent(projectDir); Debug.Assert(parentDir != null); DialogResult rslt = mb.Show(string.Format(CommandStrings.AddXToExistingWcY, projInfo.ProjectName, parentDir.FullPath), AnkhId.PlkProduct, MessageBoxButtons.YesNoCancel); switch (rslt) { case DialogResult.Cancel: return; case DialogResult.No: if (CheckoutWorkingCopyForProject(e, project, projInfo, solutionReposRoot, out markAsManaged, out writeReference)) { if (markAsManaged) { scc.SetProjectManaged(project, true); } if (writeReference) { scc.EnsureCheckOutReference(project); } continue; } break; case DialogResult.Yes: projectsToBeManaged.Add(project); AddPathToSubversion(e, projInfo.ProjectFile ?? projInfo.ProjectDirectory); continue; } } else { // We have to checkout (and create repository location) if (CheckoutWorkingCopyForProject(e, project, projInfo, solutionReposRoot, out markAsManaged, out writeReference)) { if (markAsManaged) { scc.SetProjectManaged(project, true); } if (writeReference) { scc.EnsureCheckOutReference(project); } continue; } } } } if (!AskSetManagedSelectionProjects(e, mapper, scc, projectsToBeManaged)) { return; } foreach (SccProject project in projectsToBeManaged) { if (!scc.IsProjectManaged(project)) { scc.SetProjectManaged(project, true); monitor.ScheduleSvnStatus(mapper.GetAllFilesOf(project)); // Update for 'New' status } } }
static bool CheckoutWorkingCopyForSolution(CommandEventArgs e, ref bool confirmed) { using (SvnClient cl = e.GetService <ISvnClientPool>().GetClient()) using (AddToSubversion dialog = new AddToSubversion()) { dialog.PathToAdd = e.Selection.SolutionFilename; if (e.Argument is IAnkhSccService) { dialog.CommitAllVisible = false; dialog.CommitAllFiles = false; } else { dialog.CommitAllFiles = true; } if (dialog.ShowDialog(e.Context) != DialogResult.OK) { return(false); // Don't set as managed by AnkhSVN } confirmed = true; if (dialog.CommitAllFiles) { HybridCollection <string> allFiles = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase); string logMessage; string wcPath = dialog.WorkingCopyDir; Uri reposUrl = dialog.RepositoryAddUrl; allFiles.UniqueAddRange(e.GetService <IProjectFileMapper>().GetAllFilesOfAllProjects(true)); using (CreateDirectoryDialog dlg = new CreateDirectoryDialog()) { dlg.Text = CommandStrings.ImportingTitle; dlg.NewDirectoryName = dialog.RepositoryAddUrl.ToString(); dlg.NewDirectoryReadonly = true; if (dlg.ShowDialog(e.Context) != DialogResult.OK) { return(false); } logMessage = dlg.LogMessage; } IAnkhOpenDocumentTracker documentTracker = e.GetService <IAnkhOpenDocumentTracker>(); documentTracker.SaveDocuments(allFiles); // Make sure all files are saved before updating/merging! using (DocumentLock lck = documentTracker.LockDocuments(allFiles, DocumentLockType.NoReload)) using (lck.MonitorChangesForReload()) { e.GetService <IProgressRunner>().RunModal(CommandStrings.ImportingTitle, delegate(object sender, ProgressWorkerArgs a) { SvnImportArgs importArgs = new SvnImportArgs(); importArgs.LogMessage = logMessage; importArgs.Filter += delegate(object ieSender, SvnImportFilterEventArgs ie) { if (ie.NodeKind != SvnNodeKind.Directory) { ie.Filter = !allFiles.Contains(ie.FullPath); } else { bool filter = true; foreach (string p in allFiles) { if (SvnItem.IsBelowRoot(p, ie.FullPath)) { filter = false; break; } } if (filter) { ie.Filter = true; } } }; a.Client.Import(wcPath, reposUrl, importArgs); }); } } else { Collection <SvnInfoEventArgs> info; SvnInfoArgs ia = new SvnInfoArgs(); ia.ThrowOnError = false; if (!cl.GetInfo(dialog.RepositoryAddUrl, ia, out info)) { // Target uri doesn't exist in the repository, let's create if (!RemoteCreateDirectory(e, dialog.Text, dialog.RepositoryAddUrl, cl)) { return(false); // Create failed; bail out } } // Create working copy SvnCheckOutArgs coArg = new SvnCheckOutArgs(); coArg.AllowObstructions = true; cl.CheckOut(dialog.RepositoryAddUrl, dialog.WorkingCopyDir, coArg); // Add solutionfile so we can set properties (set managed) AddPathToSubversion(e, e.Selection.SolutionFilename); IAnkhSolutionSettings settings = e.GetService <IAnkhSolutionSettings>(); IProjectFileMapper mapper = e.GetService <IProjectFileMapper>(); IFileStatusMonitor monitor = e.GetService <IFileStatusMonitor>(); settings.ProjectRoot = SvnTools.GetNormalizedFullPath(dialog.WorkingCopyDir); if (monitor != null && mapper != null) { // Make sure all visible glyphs are updated to reflect a new working copy monitor.ScheduleSvnStatus(mapper.GetAllFilesOfAllProjects()); } } return(true); } }