/* public override void PrepareChildNodes (object dataObject) * { * if (dataObject is IWorkspaceObject) { * IWorkspaceObject ce = (IWorkspaceObject) dataObject; * Repository rep = VersionControlService.GetRepository (ce); * if (rep != null) * rep.GetDirectoryVersionInfo (ce.BaseDirectory, false, false); * } else if (dataObject is ProjectFolder) { * ProjectFolder ce = (ProjectFolder) dataObject; * if (ce.ParentWorkspaceObject != null) { * Repository rep = VersionControlService.GetRepository (ce.ParentWorkspaceObject); * if (rep != null) * rep.GetDirectoryVersionInfo (ce.Path, false, false); * } * } * base.PrepareChildNodes (dataObject); * } */ static void AddFolderOverlay(Repository rep, string folder, NodeInfo nodeInfo, bool skipVersionedOverlay) { if (!rep.TryGetVersionInfo(folder, out var vinfo)) { return; } Xwt.Drawing.Image overlay = null; if (vinfo == null || !vinfo.IsVersioned) { overlay = VersionControlService.LoadOverlayIconForStatus(VersionStatus.Unversioned); } else if (vinfo.IsVersioned && !vinfo.HasLocalChanges) { if (!skipVersionedOverlay) { overlay = VersionControlService.overlay_controled; } } else { overlay = VersionControlService.LoadOverlayIconForStatus(vinfo.Status); } if (overlay != null) { nodeInfo.OverlayBottomRight = overlay; } }
public async Task <VersionInfo> GetVersionInfoAsync(CancellationToken cancellationToken = default) { if (versionInfo != null) { return(versionInfo); } try { if (Repository.TryGetVersionInfo(Path, out versionInfo)) { return(versionInfo); } versionInfo = await Repository.GetVersionInfoAsync(Path, VersionInfoQueryFlags.IgnoreCache, cancellationToken).ConfigureAwait(false); if (versionInfo == null) { versionInfo = new VersionInfo(Path, "", IsDirectory, VersionStatus.Unversioned, null, VersionStatus.Unversioned, null); } } catch (OperationCanceledException) { return(null); } catch (Exception ex) { LoggingService.LogError("Version control query failed", ex); versionInfo = VersionInfo.CreateUnversioned(Path, IsDirectory); } return(versionInfo); }
async Task UpdateSubviewsAsync() { var hasVersionInfo = repo.TryGetVersionInfo(this.vcInfo.Document.FilePath, out var info); if (hasVersionInfo) { vcInfo.Item.VersionInfo = info; } if (!hasVersionInfo || !info.IsVersioned) { if (!showSubviews) { return; } showSubviews = false; if (diffViewRef.TryGetTarget(out var diffView) && diffView != null) { mainView.AttachedViews.Remove(diffView); diffView.Dispose(); diffViewRef.SetTarget(null); } if (blameViewRef.TryGetTarget(out var blameView) && blameView != null) { mainView.AttachedViews.Remove(blameView); blameView.Dispose(); blameViewRef.SetTarget(null); } if (logViewRef.TryGetTarget(out var logView) && logView != null) { mainView.AttachedViews.Remove(logView); logView.Dispose(); logViewRef.SetTarget(null); } if (mergeViewRef.TryGetTarget(out var mergeView) && mergeView != null) { mainView.AttachedViews.Remove(mergeView); mergeView.Dispose(); mergeViewRef.SetTarget(null); } } else { if (showSubviews) { return; } showSubviews = true; diffViewRef.SetTarget(await TryAttachView(mainView, vcInfo, DiffCommand.DiffViewHandlers, GettextCatalog.GetString("Changes"), GettextCatalog.GetString("Shows the differences in the code between the current code and the version in the repository"))); blameViewRef.SetTarget(await TryAttachView(mainView, vcInfo, BlameCommand.BlameViewHandlers, GettextCatalog.GetString("Authors"), GettextCatalog.GetString("Shows the authors of the current file"))); logViewRef.SetTarget(await TryAttachView(mainView, vcInfo, LogCommand.LogViewHandlers, GettextCatalog.GetString("Log"), GettextCatalog.GetString("Shows the source control log for the current file"))); mergeViewRef.SetTarget(await TryAttachView(mainView, vcInfo, MergeCommand.MergeViewHandlers, GettextCatalog.GetString("Merge"), GettextCatalog.GetString("Shows the merge view for the current file"))); } }
public static async Task <bool> CanPublishAsync(Repository vc, string path, bool isDir) { if (!VersionControlService.CheckVersionControlInstalled()) { return(false); } return(!(vc.TryGetVersionInfo(path, out var info) && info.IsVersioned && isDir)); }
private static async Task <bool> RevertRevisionsAsync(Repository vc, string path, Revision revision, bool test, bool toRevision, CancellationToken cancellationToken) { try { if (test) { if (vc.TryGetVersionInfo(path, out var info)) { return(info.CanRevert); } return(false); } string question = GettextCatalog.GetString( "Are you sure you want to revert the selected resources to the revision specified (all local changes will be discarded)?"); if (!toRevision) { question = GettextCatalog.GetString( "Are you sure you want to revert the changes from the revision selected on these resources?"); } if (MessageService.AskQuestion(question, GettextCatalog.GetString("Note: The reversion will occur in your working copy, so you will still need to perform a commit to complete it."), AlertButton.Cancel, AlertButton.Revert) != AlertButton.Revert) { return(false); } await new RevertWorker(vc, path, revision, toRevision).StartAsync(cancellationToken); return(true); } catch (OperationCanceledException) { return(false); } catch (Exception ex) { if (test) { LoggingService.LogError(ex.ToString()); } else { MessageService.ShowError(GettextCatalog.GetString("Version control command failed."), ex); } return(false); } }
public async Task <VersionInfo> GetVersionInfoAsync(CancellationToken cancellationToken = default) { if (versionInfo != null) { return(versionInfo); } try { if (!Repository.TryGetVersionInfo(Path, out versionInfo)) { versionInfo = new VersionInfo(Path, "", IsDirectory, VersionStatus.Unversioned, null, VersionStatus.Unversioned, null); } return(versionInfo); } catch (OperationCanceledException) { return(null); } catch (Exception ex) { LoggingService.LogError("Version control query failed", ex); versionInfo = VersionInfo.CreateUnversioned(Path, IsDirectory); } return(versionInfo); }
public override void BuildNode(ITreeBuilder builder, object dataObject, NodeInfo nodeInfo) { if (!builder.Options["ShowVersionControlOverlays"]) { return; } // Add status overlays if (dataObject is WorkspaceObject) { WorkspaceObject ce = (WorkspaceObject)dataObject; Repository rep = VersionControlService.GetRepository(ce); if (rep != null) { rep.GetDirectoryVersionInfoAsync(ce.BaseDirectory, false, false); AddFolderOverlay(rep, ce.BaseDirectory, nodeInfo, false); } return; } else if (dataObject is ProjectFolder) { ProjectFolder ce = (ProjectFolder)dataObject; if (ce.ParentWorkspaceObject != null) { Repository rep = VersionControlService.GetRepository(ce.ParentWorkspaceObject); if (rep != null) { rep.GetDirectoryVersionInfoAsync(ce.Path, false, false); AddFolderOverlay(rep, ce.Path, nodeInfo, true); } } return; } WorkspaceObject prj; FilePath file; if (dataObject is ProjectFile) { ProjectFile pfile = (ProjectFile)dataObject; prj = pfile.Project; file = pfile.FilePath; } else { SystemFile pfile = (SystemFile)dataObject; prj = pfile.ParentWorkspaceObject; file = pfile.Path; } if (prj == null) { return; } Repository repo = VersionControlService.GetRepository(prj); if (repo == null) { return; } if (repo.TryGetVersionInfo(file, out var vi)) { var overlay = VersionControlService.LoadOverlayIconForStatus(vi.Status); if (overlay != null) { nodeInfo.OverlayBottomRight = overlay; } } }