public MercurialContext(MercurialProvider provider, string sourcePath) { if (provider == null) { throw new ArgumentNullException("provider"); } if (string.IsNullOrEmpty(sourcePath)) { return; } var match = MercurialPathRegex.Match(sourcePath); if (!match.Success) { throw new ArgumentException("Invalid source path (missing repository name)."); } var repositoryName = match.Groups[1].Value; var branchName = match.Groups[2].Value; var repositoryRelativePath = (match.Groups[3].Value ?? string.Empty).TrimStart('/'); SourceRepository repository; if (string.IsNullOrEmpty(branchName)) { branchName = "default"; } else { this.PathSpecifiedBranch = branchName; } if (!string.IsNullOrEmpty(repositoryName)) { repository = provider.Repositories.FirstOrDefault(r => r.Name == repositoryName); if (repository == null) { throw new ArgumentException("Invalid repository: " + repositoryName); } } else { repository = provider.Repositories.FirstOrDefault(); if (repository == null) { throw new InvalidOperationException("No repositories are defined in this provider."); } } this.Branch = branchName; this.Repository = repository; this.RepositoryRelativePath = repositoryRelativePath; var fileOps = provider.Agent.GetService <IFileOperationsExecuter>(); this.WorkspaceDiskPath = fileOps.CombinePath(repository.GetDiskPath(fileOps), repositoryRelativePath); }
public override ProviderBase CreateFromForm() { var provider = new MercurialProvider { HgExecutablePath = this.txtExePath.Text, CommittingUser = this.txtTagUser.Text }; return(provider); }