void DoRefresh(bool showProgressDialog) { ISvnSolutionLayout pls = Context.GetService <ISvnSolutionLayout>(); List <SvnStatusEventArgs> resultList = new List <SvnStatusEventArgs>(); List <string> roots = new List <string>(SvnItem.GetPaths(pls.GetUpdateRoots(null))); Dictionary <string, string> found = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); bool refreshFromList = false; try { if (showProgressDialog) { IProgressRunner pr = Context.GetService <IProgressRunner>(); if (pr.RunModal(PCResources.RetrievingRemoteStatus, delegate(object sender, ProgressWorkerArgs e) { SvnStatusArgs sa = new SvnStatusArgs(); sa.RetrieveRemoteStatus = true; DoFetchRecentChanges(e.Client, sa, roots, resultList, found); }).Succeeded) { refreshFromList = true; } } else { ShowBusyIndicator(); using (SvnClient client = Context.GetService <ISvnClientPool>().GetClient()) { SvnStatusArgs sa = new SvnStatusArgs(); sa.RetrieveRemoteStatus = true; // don't throw error // list is cleared in case of an error // show a label in the list view??? sa.ThrowOnError = false; DoFetchRecentChanges(client, sa, roots, resultList, found); refreshFromList = true; } } } finally { if (refreshFromList) { OnRecentChangesFetched(resultList); } if (!showProgressDialog) { HideBusyIndicator(); } } }
private static void CheckOutAndOpenSolution(CommandEventArgs e, SvnUriTarget checkoutLocation, SvnRevision revision, Uri projectTop, string localDir, Uri projectUri) { IProgressRunner runner = e.GetService <IProgressRunner>(); runner.RunModal(CommandStrings.CheckingOutSolution, delegate(object sender, ProgressWorkerArgs ee) { PerformCheckout(ee, checkoutLocation, revision, localDir); }); Uri file = projectTop.MakeRelativeUri(projectUri); string projectFile = SvnTools.GetNormalizedFullPath(Path.Combine(localDir, SvnTools.UriPartToPath(file.ToString()))); OpenProject(e, projectFile); }
public void OnExecute(CommandEventArgs e) { ILogControl logWindow = e.Selection.GetActiveControl <ILogControl>(); IProgressRunner progressRunner = e.GetService <IProgressRunner>(); if (logWindow == null) { return; } List <SvnRevisionRange> revisions = new List <SvnRevisionRange>(); if (e.Command == AnkhCommand.LogRevertTo) { ISvnLogItem item = EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogItem>()); if (item == null) { return; } // Revert to revision, is revert everything after revisions.Add(new SvnRevisionRange(SvnRevision.Working, item.Revision)); } else { foreach (ISvnLogItem item in e.Selection.GetSelection <ISvnLogItem>()) { revisions.Add(new SvnRevisionRange(item.Revision, item.Revision - 1)); } } if (revisions.Count == 0) { return; } IAnkhOpenDocumentTracker tracker = e.GetService <IAnkhOpenDocumentTracker>(); HybridCollection <string> nodes = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase); foreach (SvnOrigin o in logWindow.Origins) { SvnPathTarget pt = o.Target as SvnPathTarget; if (pt == null) { continue; } foreach (string file in tracker.GetDocumentsBelow(pt.FullPath)) { if (!nodes.Contains(file)) { nodes.Add(file); } } } if (nodes.Count > 0) { tracker.SaveDocuments(nodes); // Saves all open documents below all specified origins } using (DocumentLock dl = tracker.LockDocuments(nodes, DocumentLockType.NoReload)) using (dl.MonitorChangesForReload()) { SvnMergeArgs ma = new SvnMergeArgs(); progressRunner.RunModal(LogStrings.Reverting, delegate(object sender, ProgressWorkerArgs ee) { foreach (SvnOrigin item in logWindow.Origins) { SvnPathTarget target = item.Target as SvnPathTarget; if (target == null) { continue; } ee.Client.Merge(target.FullPath, target, revisions, ma); } }); } }
private static void CheckOutAndOpenProject(CommandEventArgs e, SvnUriTarget checkoutLocation, SvnRevision revision, Uri projectTop, string localDir, Uri projectUri) { IProgressRunner runner = e.GetService <IProgressRunner>(); runner.RunModal(CommandStrings.CheckingOutSolution, delegate(object sender, ProgressWorkerArgs ee) { PerformCheckout(ee, checkoutLocation, revision, localDir); }); Uri file = projectTop.MakeRelativeUri(projectUri); string projectFile = SvnTools.GetNormalizedFullPath(Path.Combine(localDir, SvnTools.UriPartToPath(file.ToString()))); AddProject(e, projectFile); using (ProjectAddInfoDialog pai = new ProjectAddInfoDialog()) { IAnkhSolutionSettings ss = e.GetService <IAnkhSolutionSettings>(); ISvnStatusCache cache = e.GetService <ISvnStatusCache>(); SvnItem rootItem; pai.EnableSlnConnection = false; if (ss == null || cache == null || string.IsNullOrEmpty(ss.ProjectRoot) || !SvnItem.IsBelowRoot(localDir, ss.ProjectRoot) || null == (rootItem = cache[localDir])) { pai.EnableExternal = false; pai.EnableCopy = false; } else { SvnItem dir = rootItem.Parent; if (ss.ProjectRootSvnItem != null && ss.ProjectRootSvnItem.IsVersioned) { HybridCollection <string> dirs = new HybridCollection <string>(); SvnItem exDir = dir; while (exDir != null && exDir.IsBelowPath(ss.ProjectRoot)) { if (exDir.IsVersioned && exDir.WorkingCopy == ss.ProjectRootSvnItem.WorkingCopy) { dirs.Add(exDir.FullPath); } exDir = exDir.Parent; } pai.SetExternalDirs(dirs); pai.EnableExternal = true; } else { pai.EnableExternal = false; } if (rootItem.WorkingCopy != null && dir.WorkingCopy != null) { pai.EnableCopy = (rootItem.WorkingCopy.RepositoryRoot == dir.WorkingCopy.RepositoryRoot) && (rootItem.WorkingCopy.RepositoryId == dir.WorkingCopy.RepositoryId); } else { pai.EnableCopy = false; } } if (pai.ShowDialog(e.Context) == DialogResult.OK) { switch (pai.SelectedMode) { case ProjectAddMode.External: if (pai.ExternalLocation != null) { using (SvnClient cl = e.GetService <ISvnClientPool>().GetNoUIClient()) { string externals; if (!cl.TryGetProperty(pai.ExternalLocation, SvnPropertyNames.SvnExternals, out externals)) { externals = ""; } SvnExternalItem sei; if (pai.ExternalLocked) { sei = new SvnExternalItem(SvnItem.SubPath(localDir, pai.ExternalLocation), checkoutLocation.Uri, revision, revision); } else { sei = new SvnExternalItem(SvnItem.SubPath(localDir, pai.ExternalLocation), checkoutLocation.Uri); } externals = sei.ToString(true) + Environment.NewLine + externals; cl.SetProperty(pai.ExternalLocation, SvnPropertyNames.SvnExternals, externals); } } break; case ProjectAddMode.Copy: using (SvnClient cl = e.GetService <ISvnClientPool>().GetClient()) { string tmpDir = localDir + "-Src-copyTmp"; Directory.CreateDirectory(tmpDir); Directory.Move(Path.Combine(localDir, SvnClient.AdministrativeDirectoryName), Path.Combine(tmpDir, SvnClient.AdministrativeDirectoryName)); SvnCopyArgs ma = new SvnCopyArgs(); ma.MetaDataOnly = true; cl.Copy(tmpDir, localDir, ma); SvnItem.DeleteDirectory(tmpDir, true); cache.MarkDirtyRecursive(localDir); } break; case ProjectAddMode.Unversioned: cache.MarkDirtyRecursive(localDir); SvnItem.DeleteDirectory(Path.Combine(localDir, SvnClient.AdministrativeDirectoryName), true); e.GetService <IFileStatusMonitor>().ScheduleGlyphUpdate(projectFile); // And everything else in the project break; } } } }
public void OnExecute(CommandEventArgs e) { ISvnLogItem selectedLog = EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogItem>()); if (selectedLog == null) { return; } using (PropertyEditorDialog dialog = new PropertyEditorDialog(selectedLog.RepositoryRoot, selectedLog.Revision, true)) { SvnRevisionPropertyListArgs args = new SvnRevisionPropertyListArgs(); args.ThrowOnError = false; SvnPropertyCollection properties = null; if (!e.GetService <IProgressRunner>().RunModal(LogStrings.RetrievingRevisionProperties, delegate(object sender, ProgressWorkerArgs wa) { if (!wa.Client.GetRevisionPropertyList(selectedLog.RepositoryRoot, selectedLog.Revision, args, out properties)) { properties = null; } }).Succeeded) { return; } else if (properties != null) { List <PropertyEditItem> propItems = new List <PropertyEditItem>(); foreach (SvnPropertyValue prop in properties) { PropertyEditItem pi = new PropertyEditItem(dialog.ListView, prop.Key); pi.OriginalValue = pi.Value = pi.BaseValue = prop; propItems.Add(pi); } dialog.PropertyValues = propItems.ToArray(); } if (dialog.ShowDialog(e.Context) != DialogResult.OK) { return; } PropertyEditItem[] finalItems = dialog.PropertyValues; bool hasChanges = false; foreach (PropertyEditItem ei in finalItems) { if (ei.ShouldPersist) { hasChanges = true; break; } } if (!hasChanges) { return; } IProgressRunner progressRunner = e.GetService <IProgressRunner>(); ProgressRunnerResult result = progressRunner.RunModal(LogStrings.UpdatingRevisionProperties, delegate(object sender, ProgressWorkerArgs ee) { foreach (PropertyEditItem ei in finalItems) { if (!ei.ShouldPersist) { continue; } if (ei.IsDeleted) { ee.Client.DeleteRevisionProperty(selectedLog.RepositoryRoot, selectedLog.Revision, ei.PropertyName); } else if (ei.Value.StringValue != null) { ee.Client.SetRevisionProperty(selectedLog.RepositoryRoot, selectedLog.Revision, ei.PropertyName, ei.Value.StringValue); } else { ee.Client.SetRevisionProperty(selectedLog.RepositoryRoot, selectedLog.Revision, ei.PropertyName, ei.Value.RawValue); } } }); if (result.Succeeded) { ILogControl logWindow = e.Selection.GetActiveControl <ILogControl>(); if (logWindow != null) { logWindow.Restart(); } } } // using }