public override async Task <bool> SupportsController(DocumentController controller) { if (!(controller is FileDocumentController fileController) || !IdeApp.IsInitialized) { return(false); } project = controller.Owner; 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 == fileController.FilePath) { project = projItem; } } if (project == null) { return(false); } } repo = VersionControlService.GetRepository(project); if (repo == null) { return(false); } var versionInfo = await repo.GetVersionInfoAsync(fileController.FilePath); return(versionInfo.IsVersioned); }
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); }
public static async Task <bool> CanPublishAsync(Repository vc, string path, bool isDir) { if (!VersionControlService.CheckVersionControlInstalled()) { return(false); } if (!(await vc.GetVersionInfoAsync(path)).IsVersioned && isDir) { return(true); } return(false); }
private static async Task <bool> RevertRevisionsAsync(Repository vc, string path, Revision revision, bool test, bool toRevision, CancellationToken cancellationToken) { try { if (test) { return((await vc.GetVersionInfoAsync(path, cancellationToken: cancellationToken)).CanRevert); } 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 <ChangeSetItem> AddFileAsync(FilePath file, CancellationToken cancellationToken = default) { return(AddFile(await repo.GetVersionInfoAsync(file, cancellationToken: cancellationToken))); }