protected void OnInit() { BazaarVersionControl bvc = null; BazaarRepository repo = null; VersionControlItem vcitem = GetItems()[0]; string path = vcitem.Path; List <FilePath> addFiles = null; Solution solution = (Solution)vcitem.WorkspaceObject; foreach (VersionControlSystem vcs in VersionControlService.GetVersionControlSystems()) { if (vcs is BazaarVersionControl) { bvc = (BazaarVersionControl)vcs; } } if (null == bvc || !bvc.IsInstalled) { throw new Exception("Can't use bazaar"); } bvc.Init(path); repo = new BazaarRepository(bvc, string.Format("file://{0}", path)); addFiles = GetAllFiles(solution); repo.Add(addFiles.ToArray(), false, null); solution.NeedsReload = true; }
public static bool Show(VersionControlItemList items, bool test) { if (items.Count != 1) { return(false); } VersionControlItem item = items [0]; if (item.VersionInfo.IsVersioned) { if (test) { return(true); } string path = item.Path; if (Services.ProjectService.IsSolutionItemFile(item.Path.FullPath)) { path = IdeApp.Workspace.FindSolutionItem(item.Path.FullPath).BaseDirectory; } else if (Services.ProjectService.IsWorkspaceItemFile(item.Path.FullPath)) { path = IdeApp.Workspace.GetAllItems <WorkspaceItem> ().First(x => x.FileName.FullPath == item.Path.FullPath).BaseDirectory; } StatusView d = new StatusView(path, item.Repository); IdeApp.Workbench.OpenDocument(d, true); return(true); } return(false); }
protected void OnMerge() { VersionControlItem vcitem = GetItems()[0]; MercurialRepository repo = ((MercurialRepository)vcitem.Repository); repo.Merge(); } // OnMerge
protected void OnBind() { VersionControlItem vcitem = GetItems()[0]; BazaarRepository repo = (BazaarRepository)vcitem.Repository; string boundBranch = repo.GetBoundBranch(vcitem.Path); var bsd = new BranchSelectionDialog(new string[] { boundBranch }, boundBranch, vcitem.Path.FullPath, false, false, false, false); try { if ((int)Gtk.ResponseType.Ok == bsd.Run() && !string.IsNullOrEmpty(bsd.SelectedLocation)) { BazaarTask worker = new BazaarTask(); worker.Description = string.Format("Binding to {0}", bsd.SelectedLocation); worker.Operation = delegate { repo.Bind(bsd.SelectedLocation, vcitem.Path, worker.ProgressMonitor); }; worker.Start(); } } finally { bsd.Destroy(); } }
protected void OnRebase() { VersionControlItem vcitem = GetItems()[0]; MercurialRepository repo = ((MercurialRepository)vcitem.Repository); Dictionary <string, BranchType> branches = repo.GetKnownBranches(vcitem.Path); string defaultBranch = string.Empty, localPath = vcitem.IsDirectory? (string)vcitem.Path.FullPath: Path.GetDirectoryName(vcitem.Path.FullPath); foreach (KeyValuePair <string, BranchType> branch in branches) { if (BranchType.Parent == branch.Value) { defaultBranch = branch.Key; break; } } // check for parent branch Dialogs.BranchSelectionDialog bsd = new Dialogs.BranchSelectionDialog(branches.Keys, defaultBranch, localPath, false, true, true, false); try { if ((int)Gtk.ResponseType.Ok == bsd.Run() && !string.IsNullOrEmpty(bsd.SelectedLocation)) { MercurialTask worker = new MercurialTask(); worker.Description = string.Format("Rebasing on {0}", bsd.SelectedLocation); worker.Operation = delegate { repo.Rebase(bsd.SelectedLocation, vcitem.Path, bsd.SaveDefault, bsd.Overwrite, worker.ProgressMonitor); }; worker.Start(); } } finally { bsd.Destroy(); } } // OnRebase
void HandleDocumentChanged(object sender, EventArgs e) { var document = Ide.IdeApp.Workbench.ActiveDocument; try { if (document == null || !document.IsFile || document.Project == null || document.Window.FindView <IDiffView> () >= 0) { return; } var repo = VersionControlService.GetRepository(document.Project); if (repo == null) { return; } var versionInfo = repo.GetVersionInfo(document.FileName, VersionInfoQueryFlags.IgnoreCache); if (!versionInfo.IsVersioned) { return; } var item = new VersionControlItem(repo, document.Project, document.FileName, false, null); var vcInfo = new VersionControlDocumentInfo(document.PrimaryView, item, item.Repository); TryAttachView <IDiffView> (document, vcInfo, DiffCommand.DiffViewHandlers); TryAttachView <IBlameView> (document, vcInfo, BlameCommand.BlameViewHandlers); TryAttachView <ILogView> (document, vcInfo, LogCommand.LogViewHandlers); TryAttachView <IMergeView> (document, vcInfo, MergeCommand.MergeViewHandlers); } catch (Exception ex) { // If a user is hitting this, it will show a dialog box every time they // switch to a document or open a document, so suppress the crash dialog // This bug *should* be fixed already, but it's hard to tell. LogReportingService.ReportUnhandledException(ex, false, true); } }
void AttachViewContents(MonoDevelop.Ide.Gui.Document document) { if (document == null || document.Project == null) { return; } var repo = VersionControlService.GetRepository(document.Project); if (repo == null) { return; } if (!document.IsFile || !repo.GetVersionInfo(document.FileName).IsVersioned) { return; } if (document.Editor == null) { return; } var item = new VersionControlItem(repo, document.Project, document.FileName, false, null); TryAttachView <IDiffView> (document, item, DiffCommand.DiffViewHandlers); TryAttachView <IBlameView> (document, item, BlameCommand.BlameViewHandlers); TryAttachView <ILogView> (document, item, LogCommand.LogViewHandlers); TryAttachView <IMergeView> (document, item, MergeCommand.MergeViewHandlers); }
private List <FilePath> GetWorkingPaths(VersionControlItem item) { List <FilePath> paths = new List <FilePath>(); var solution = item.WorkspaceObject as Solution; if (solution != null) { //Add Solution paths.Add(solution.BaseDirectory); //Add linked files. foreach (var path in solution.GetItemFiles(true)) { if (!path.IsChildPathOf(solution.BaseDirectory)) { paths.Add(path); } } } else { var project = (Project)item.WorkspaceObject; paths.Add(project.BaseDirectory); } return(paths); }
void TryAttachView <T>(Document document, VersionControlItem item, string type) where T : IAttachableViewContent { var handler = AddinManager.GetExtensionObjects <IVersionControlViewHandler <T> > (type).FirstOrDefault(h => h.CanHandle(item)); if (handler != null) { document.Window.AttachViewContent(handler.CreateView(item, document.PrimaryView)); } }
void HandleDocumentOpened (object sender, Ide.Gui.DocumentEventArgs e) { if (e.Document.Project == null) return; var repo = VersionControlService.GetRepository (e.Document.Project); if (repo == null) return; var item = new VersionControlItem (repo, e.Document.Project, e.Document.FileName, false); DiffView.AttachViewContents (e.Document, item); }
protected void OnBzrPublish() { VersionControlItem vcitem = GetItems()[0]; BazaarRepository repo = ((BazaarRepository)vcitem.Repository); Dictionary <string, BranchType> branches = repo.GetKnownBranches(vcitem.Path); string defaultBranch = string.Empty, localPath = vcitem.IsDirectory ? (string)vcitem.Path.FullPath : Path.GetDirectoryName(vcitem.Path.FullPath); if (repo.IsModified(BazaarRepository.GetLocalBasePath(vcitem.Path.FullPath))) { MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, GettextCatalog.GetString("You have uncommitted local changes. Push anyway?")); try { if ((int)ResponseType.Yes != md.Run()) { return; } } finally { md.Destroy(); } } // warn about uncommitted changes foreach (KeyValuePair <string, BranchType> branch in branches) { if (BranchType.Parent == branch.Value) { defaultBranch = branch.Key; break; } } // check for parent branch var bsd = new BranchSelectionDialog(branches.Keys, defaultBranch, localPath, false, true, true, true); try { if ((int)Gtk.ResponseType.Ok == bsd.Run() && !string.IsNullOrEmpty(bsd.SelectedLocation)) { BazaarTask worker = new BazaarTask(); worker.Description = string.Format("Pushing to {0}", bsd.SelectedLocation); worker.Operation = delegate { repo.Push(bsd.SelectedLocation, vcitem.Path, bsd.SaveDefault, bsd.Overwrite, bsd.OmitHistory, worker.ProgressMonitor); }; worker.Start(); } } finally { bsd.Destroy(); } }
protected void OnUncommit() { VersionControlItem vcitem = GetItems()[0]; MercurialRepository repo = (MercurialRepository)vcitem.Repository; MercurialTask worker = new MercurialTask(); worker.Description = string.Format("Uncommitting {0}", vcitem.Path); worker.Operation = delegate { repo.Uncommit(vcitem.Path, worker.ProgressMonitor); }; worker.Start(); } // OnUncommit
protected void CanGetOutgoing(CommandInfo item) { if (1 == GetItems().Count) { VersionControlItem vcitem = GetItems()[0]; item.Visible = (vcitem.Repository is MercurialRepository); } else { item.Visible = false; } } // CanGetOutgoing
static void HandleDocumentChanged(object sender, EventArgs e) { var document = Ide.IdeApp.Workbench.ActiveDocument; try { if (document == null || !document.IsFile || document.Window.FindView <ILogView> () >= 0) { return; } WorkspaceObject project = document.Project; if (project == null) { // Fix for broken .csproj and .sln files not being seen as having a project. foreach (var projItem in Ide.IdeApp.Workspace.GetAllItems <UnknownSolutionItem> ()) { if (projItem.FileName == document.FileName) { project = projItem; } } if (project == null) { return; } } var repo = VersionControlService.GetRepository(project); if (repo == null) { return; } var versionInfo = repo.GetVersionInfo(document.FileName, VersionInfoQueryFlags.IgnoreCache); if (!versionInfo.IsVersioned) { return; } var item = new VersionControlItem(repo, project, document.FileName, false, null); var vcInfo = new VersionControlDocumentInfo(document.PrimaryView, item, item.Repository); TryAttachView(document, vcInfo, DiffCommand.DiffViewHandlers); TryAttachView(document, vcInfo, BlameCommand.BlameViewHandlers); TryAttachView(document, vcInfo, LogCommand.LogViewHandlers); TryAttachView(document, vcInfo, MergeCommand.MergeViewHandlers); } catch (Exception ex) { // If a user is hitting this, it will show a dialog box every time they // switch to a document or open a document, so suppress the crash dialog // This bug *should* be fixed already, but it's hard to tell. LoggingService.LogInternalError(ex); } }
protected void CanInit(CommandInfo item) { if (1 == GetItems().Count) { VersionControlItem vcitem = GetItems()[0]; if (vcitem.WorkspaceObject is Solution && null == vcitem.Repository) { item.Visible = true; return; } } item.Visible = false; }
protected void CanUncommit(CommandInfo item) { if (1 == GetItems().Count) { VersionControlItem vcitem = GetItems()[0]; if (vcitem.Repository is BazaarRepository) { item.Visible = ((BazaarRepository)vcitem.Repository).CanUncommit(vcitem.Path); return; } } item.Visible = false; }
protected void CanIgnore(CommandInfo item) { if (1 == GetItems().Count) { VersionControlItem vcitem = GetItems()[0]; if (vcitem.Repository is MercurialRepository) { item.Visible = !((MercurialRepository)vcitem.Repository).IsVersioned(vcitem.Path); return; } } item.Visible = false; } // CanIgnore
protected void CanPull(CommandInfo item) { if (1 == GetItems().Count) { VersionControlItem vcitem = GetItems()[0]; item.Visible = (vcitem.Repository is BazaarRepository && ((BazaarRepository)vcitem.Repository).CanPull(vcitem.Path)); } else { item.Visible = false; } }
protected void CanMerge(CommandInfo item) { if (1 == GetItems().Count) { VersionControlItem vcitem = GetItems()[0]; item.Visible = (vcitem.Repository is MercurialRepository && ((MercurialRepository)vcitem.Repository).CanMerge(vcitem.Path)); } else { item.Visible = false; } } // CanMerge
protected void OnUnbind() { VersionControlItem vcitem = GetItems()[0]; BazaarRepository repo = (BazaarRepository)vcitem.Repository; BazaarTask worker = new BazaarTask(); worker.Description = string.Format("Unbinding {0}", vcitem.Path); worker.Operation = delegate { repo.Unbind(vcitem.Path, worker.ProgressMonitor); }; worker.Start(); }
protected void CanRebase(CommandInfo item) { if (1 == GetItems().Count) { VersionControlItem vcitem = GetItems()[0]; if (vcitem.Repository is MercurialRepository) { var repo = vcitem.Repository as MercurialRepository; item.Visible = (repo.CanPull(vcitem.Path) && repo.CanRebase()); } } item.Visible = false; } // CanRebase
void HandleDocumentOpened(object sender, Ide.Gui.DocumentEventArgs e) { if (e.Document.Project == null) { return; } var repo = VersionControlService.GetRepository(e.Document.Project); if (repo == null) { return; } if (!e.Document.IsFile || !repo.GetVersionInfo(e.Document.FileName).IsVersioned) { return; } var item = new VersionControlItem(repo, e.Document.Project, e.Document.FileName, false, null); DiffView.AttachViewContents(e.Document, item); }
public static void AttachViewContents(Document document, VersionControlItem item) { IWorkbenchWindow window = document.Window; if (window.SubViewContents.Any(sub => sub is ComparisonView)) { return; } VersionControlDocumentInfo info = new VersionControlDocumentInfo(document, item); ComparisonView comparisonView = new ComparisonView(info); window.AttachViewContent(comparisonView); window.AttachViewContent(new PatchView(comparisonView, info)); window.AttachViewContent(new BlameView(info)); window.AttachViewContent(new LogView(info)); info.Start(); }
private static void FeedVersionControlData(ICollection <VersionControlItem> versionControlItemCollection, TfsTeamProjectCollection tpc, string projectName) { VersionControlServer vcs = tpc.GetService <VersionControlServer>(); ItemSet items = vcs.GetItems("$/" + projectName + "/*", RecursionType.None); foreach (Item item in items.Items) { int itemChangeSetId = item.ChangesetId; DateTime lastInnerCheckInDate = DateTime.MinValue; int lastInnerChangeSetId = 0; IEnumerable history = vcs.QueryHistory(item.ServerItem, VersionSpec.Latest, item.DeletionId, RecursionType.Full, null, new ChangesetVersionSpec(itemChangeSetId), VersionSpec.Latest, Int32.MaxValue, false, false); IEnumerator enumerator = history.GetEnumerator(); if (enumerator.MoveNext()) { Changeset lastChangeSet = enumerator.Current as Changeset; if (lastChangeSet != null) { lastInnerCheckInDate = lastChangeSet.CreationDate; lastInnerChangeSetId = lastChangeSet.ChangesetId; } } VersionControlItem vci = new VersionControlItem() { DisplayName = item.ServerItem, ItemChangeSetId = itemChangeSetId, ItemLastCheckIn = item.CheckinDate, InnerChangeSetId = lastInnerChangeSetId, InnerLastCheckIn = lastInnerCheckInDate }; versionControlItemCollection.Add(vci); } }
void HandleDocumentOpened(object sender, Ide.Gui.DocumentEventArgs e) { if (!e.Document.IsFile || e.Document.Project == null) { return; } var repo = VersionControlService.GetRepository(e.Document.Project); if (repo == null || !repo.GetVersionInfo(e.Document.FileName).IsVersioned) { return; } var item = new VersionControlItem(repo, e.Document.Project, e.Document.FileName, false, null); TryAttachView <IDiffView> (e.Document, item, DiffCommand.DiffViewHandlers); TryAttachView <IBlameView> (e.Document, item, BlameCommand.BlameViewHandlers); TryAttachView <ILogView> (e.Document, item, LogCommand.LogViewHandlers); TryAttachView <IMergeView> (e.Document, item, MergeCommand.MergeViewHandlers); }
public static bool Show(VersionControlItemList items, bool test) { if (items.Count != 1) { return(false); } VersionControlItem item = items [0]; if (item.Repository.IsVersioned(item.Path)) { if (test) { return(true); } StatusView d = new StatusView(item.Path, item.Repository); IdeApp.Workbench.OpenDocument(d, true); return(true); } return(false); }
protected void OnExport() { VersionControlItem vcitem = GetItems()[0]; BazaarRepository repo = ((BazaarRepository)vcitem.Repository); FileChooserDialog fsd = new FileChooserDialog(GettextCatalog.GetString("Choose export location"), null, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); fsd.SetCurrentFolder(vcitem.Path.FullPath.ParentDirectory); try { if ((int)Gtk.ResponseType.Accept == fsd.Run() && !string.IsNullOrEmpty(fsd.Filename)) { BazaarTask worker = new BazaarTask(); worker.Description = string.Format("Exporting to {0}", fsd.Filename); worker.Operation = delegate { repo.Export(vcitem.Path, fsd.Filename, worker.ProgressMonitor); }; worker.Start(); } } finally { fsd.Destroy(); } } // OnExport
public static void AttachViewContents(Document document, VersionControlItem item) { IWorkbenchWindow window = document.Window; if (window.SubViewContents.Any(sub => sub is DiffView)) { return; } VersionControlDocumentInfo info = new VersionControlDocumentInfo(document, item, item.Repository); DiffView comparisonView = new DiffView(info); window.AttachViewContent(comparisonView); // window.AttachViewContent (new PatchView (comparisonView, info)); window.AttachViewContent(new BlameView(info)); window.AttachViewContent(new LogView(info)); if (info.VersionInfo != null && info.VersionInfo.Status == VersionStatus.Conflicted) { window.AttachViewContent(new MergeView(info)); } }
protected void OnGetOutgoing() { VersionControlItem vcitem = GetItems()[0]; MercurialRepository repo = ((MercurialRepository)vcitem.Repository); Dictionary <string, BranchType> branches = repo.GetKnownBranches(vcitem.Path); string defaultBranch = string.Empty, localPath = vcitem.IsDirectory? (string)vcitem.Path.FullPath: Path.GetDirectoryName(vcitem.Path.FullPath); foreach (KeyValuePair <string, BranchType> branch in branches) { if (BranchType.Parent == branch.Value) { defaultBranch = branch.Key; break; } } // check for parent branch Dialogs.BranchSelectionDialog bsd = new Dialogs.BranchSelectionDialog(branches.Keys, defaultBranch, localPath, false, false, false, false); try { if ((int)Gtk.ResponseType.Ok == bsd.Run()) { MercurialTask worker = new MercurialTask(); worker.Description = string.Format("Outgoing to {0}", bsd.SelectedLocation); worker.Operation = delegate { repo.LocalBasePath = MercurialRepository.GetLocalBasePath(localPath); Revision[] history = repo.GetOutgoing(bsd.SelectedLocation); DispatchService.GuiDispatch(() => { var view = new MonoDevelop.VersionControl.Views.LogView(localPath, true, history, repo); IdeApp.Workbench.OpenDocument(view, true); }); }; worker.Start(); } } finally { bsd.Destroy(); } } // OnGetOutgoing
public VersionControlDocumentInfo(DocumentView document, VersionControlItem item, Repository repository) { this.Document = document; this.Item = item; this.Repository = repository; }
private List<FilePath> GetWorkingPaths(VersionControlItem item) { List<FilePath> paths = new List<FilePath>(); var solution = item.WorkspaceObject as Solution; if (solution != null) { //Add Solution paths.Add(solution.BaseDirectory); //Add linked files. foreach (var path in solution.GetItemFiles(true)) { if (!path.IsChildPathOf(solution.BaseDirectory)) { paths.Add(path); } } } else { var project = (Project)item.WorkspaceObject; paths.Add(project.BaseDirectory); } return paths; }
public VersionControlDocumentInfo (Document document, VersionControlItem item) { this.Document = document; this.Item = item; }
public static void AttachViewContents (Document document, VersionControlItem item) { IWorkbenchWindow window = document.Window; if (window.SubViewContents.Any (sub => sub is DiffView)) return; VersionControlDocumentInfo info = new VersionControlDocumentInfo (document, item); DiffView comparisonView = new DiffView (info); window.AttachViewContent (comparisonView); // window.AttachViewContent (new PatchView (comparisonView, info)); window.AttachViewContent (new BlameView (info)); window.AttachViewContent (new LogView (info)); if (info.VersionInfo != null && info.VersionInfo.Status == VersionStatus.Conflicted) window.AttachViewContent (new MergeView (info)); }
public static void AttachViewContents (Document document, VersionControlItem item) { IWorkbenchWindow window = document.Window; if (window.SubViewContents.Any (sub => sub is ComparisonView)) return; VersionControlDocumentInfo info = new VersionControlDocumentInfo (document, item); ComparisonView comparisonView = new ComparisonView (info); window.AttachViewContent (comparisonView); window.AttachViewContent (new PatchView (comparisonView, info)); window.AttachViewContent (new BlameView (info)); window.AttachViewContent (new LogView (info)); info.Start (); }
protected void OnIgnore() { VersionControlItem vcitem = GetItems()[0]; ((BazaarRepository)vcitem.Repository).Ignore(new [] { vcitem.Path }); }
public VersionControlDocumentInfo (IViewContent document, VersionControlItem item, Repository repository) { this.Document = document; this.Item = item; this.Repository = repository; }