internal bool DeleteBranch(SvnListEventArgs selectedBranch) { try { if (selectedBranch != null) { using (SvnClient client = new SvnClient()) { // Bind the SharpSvn UI to our client for SSL certificate and credentials SvnUIBindArgs bindArgs = new SvnUIBindArgs(); SvnUI.Bind(client, bindArgs); SvnDeleteArgs arg = new SvnDeleteArgs(); arg.LogMessage = "ADMIN-0: Branch Deleted"; return(client.RemoteDelete(selectedBranch.Uri, arg)); } } return(false); } catch (Exception) { throw; } }
internal List <SvnListEventArgs> GetFolderList(SvnUriTarget targetUri) { try { List <SvnListEventArgs> folderList = new List <SvnListEventArgs>(); using (SvnClient client = new SvnClient()) { // Bind the SharpSvn UI to our client for SSL certificate and credentials SvnUIBindArgs bindArgs = new SvnUIBindArgs(); SvnUI.Bind(client, bindArgs); if (this.CheckUrlValide(client, targetUri)) { Collection <SvnListEventArgs> itemList; if (client.GetList(targetUri, out itemList)) { foreach (SvnListEventArgs component in itemList) { if (component.Entry.NodeKind == SvnNodeKind.Directory) { folderList.Add(component); } } } } } return(folderList); } catch (Exception) { throw; } }
internal bool CreateTag(SvnListEventArgs selectedTrunk, string tagName) { try { if (selectedTrunk != null) { using (SvnClient client = new SvnClient()) { // Bind the SharpSvn UI to our client for SSL certificate and credentials SvnUIBindArgs bindArgs = new SvnUIBindArgs(); SvnUI.Bind(client, bindArgs); string relativeComponentPath = selectedTrunk.BaseUri.AbsoluteUri; Uri tagUri = new Uri(relativeComponentPath + "tags/" + tagName); SvnTarget source = SvnTarget.FromUri(selectedTrunk.Uri); SvnCopyArgs arg = new SvnCopyArgs(); arg.CreateParents = false; arg.LogMessage = string.Format("ADMIN-0: Tag Created from Trunk"); return(client.RemoteCopy(source, tagUri, arg)); } } return(false); } catch (Exception) { throw; } }
internal bool CreateBranch(SvnListEventArgs selectedTag, string branchName) { try { if (selectedTag != null) { using (SvnClient client = new SvnClient()) { // Bind the SharpSvn UI to our client for SSL certificate and credentials SvnUIBindArgs bindArgs = new SvnUIBindArgs(); SvnUI.Bind(client, bindArgs); string relativeComponentPath = string.Join(string.Empty, selectedTag.BaseUri.Segments.Take(selectedTag.BaseUri.Segments.Count() - 1).ToArray()); string server = selectedTag.BaseUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped); Uri barnchUri = new Uri(server + relativeComponentPath + "branches/project/" + branchName); SvnTarget source = SvnTarget.FromUri(selectedTag.Uri); SvnCopyArgs arg = new SvnCopyArgs(); arg.CreateParents = false; arg.LogMessage = string.Format("ADMIN-0: Branch Created from Tag {0}", selectedTag.Name); return(client.RemoteCopy(source, barnchUri, arg)); } } return(false); } catch (Exception) { throw; } }
static OperateSvnHelper() { _svnClient = new SvnClient(); // 绑定图形化SVN操作窗口,比如当需要对SVN鉴权时弹出账户密码输入对话框 SvnUIBindArgs uiBindArgs = new SvnUIBindArgs(); SvnUI.Bind(_svnClient, uiBindArgs); }
internal bool CreateComponents(List <string> componentNameList) { try { using (SvnClient client = new SvnClient()) { // Bind the SharpSvn UI to our client for SSL certificate and credentials SvnUIBindArgs bindArgs = new SvnUIBindArgs(); SvnUI.Bind(client, bindArgs); List <Uri> folderList = new List <Uri>(); if (componentNameList.Count > 0) { foreach (string componentName in componentNameList) { SvnUriTarget componentUrl = new SvnUriTarget(this.componentsUri + "/" + componentName); if (this.CheckUrlValide(client, componentUrl) == false) { folderList.AddRange(new Uri[] { componentUrl.Uri, new Uri(string.Format("{0}/branches/", componentUrl.ToString())), new Uri(string.Format("{0}/branches/archive", componentUrl.ToString())), new Uri(string.Format("{0}/branches/core", componentUrl.ToString())), new Uri(string.Format("{0}/branches/core/ifsapp-8.0", componentUrl.ToString())), new Uri(string.Format("{0}/branches/core/ifsapp-8.0/main", componentUrl.ToString())), new Uri(string.Format("{0}/branches/core/ifsapp-9.0", componentUrl.ToString())), new Uri(string.Format("{0}/branches/core/ifsapp-9.0/main", componentUrl.ToString())), new Uri(string.Format("{0}/branches/project", componentUrl.ToString())), new Uri(string.Format("{0}/tags/", componentUrl.ToString())), new Uri(string.Format("{0}/trunk/", componentUrl.ToString())) }); } } SvnCreateDirectoryArgs arg = new SvnCreateDirectoryArgs(); arg.CreateParents = true; arg.LogMessage = "ADMIN-0: Component structure created."; return(client.RemoteCreateDirectories(folderList, arg)); } } return(false); } catch (Exception) { throw; } }
private void HookUI(AnkhSvnPoolRemoteSession client) { // Let SharpSvnUI handle login and SSL dialogs SvnUIBindArgs bindArgs = new SvnUIBindArgs(); bindArgs.ParentWindow = new OwnerWrapper(DialogOwner); bindArgs.UIService = GetService <IUIService>(); bindArgs.Synchronizer = _syncher; if (Config != null && Config.Instance.PreferPuttyAsSSH) { client.Configuration.SshOverride = SharpSvn.Implementation.SvnSshOverride.ForceSharpPlinkAfterConfig; } SvnUI.Bind(client, bindArgs); }
internal bool CreateProject(string projectName) { try { using (SvnClient client = new SvnClient()) { // Bind the SharpSvn UI to our client for SSL certificate and credentials SvnUIBindArgs bindArgs = new SvnUIBindArgs(); SvnUI.Bind(client, bindArgs); List <Uri> folderList = new List <Uri>(); if (string.IsNullOrWhiteSpace(projectName) == false) { SvnUriTarget projectUrl = new SvnUriTarget(this.projectsUri + "/" + projectName); if (this.CheckUrlValide(client, projectUrl) == false) { folderList.AddRange(new Uri[] { projectUrl.Uri, new Uri(string.Format("{0}/documentation/", projectUrl.ToString())), new Uri(string.Format("{0}/nbproject/", projectUrl.ToString())), new Uri(string.Format("{0}/release/", projectUrl.ToString())), new Uri(string.Format("{0}/tags/", projectUrl.ToString())), new Uri(string.Format("{0}/workspace/", projectUrl.ToString())) }); } SvnCreateDirectoryArgs arg = new SvnCreateDirectoryArgs(); arg.CreateParents = true; arg.LogMessage = "ADMIN-0: Component structure created."; return(client.RemoteCreateDirectories(folderList, arg)); } } return(false); } catch (Exception) { throw; } }
internal List <SvnComponent> GetDocumentComponentListFromExternals(SvnProject seletedProject) { try { List <SvnComponent> componentList = new List <SvnComponent>(); using (SvnClient client = new SvnClient()) { // Bind the SharpSvn UI to our client for SSL certificate and credentials SvnUIBindArgs bindArgs = new SvnUIBindArgs(); SvnUI.Bind(client, bindArgs); SvnUriTarget projectUri = new SvnUriTarget(seletedProject.Path + Properties.Resources.CheckOutPath_Documentation + "/"); string components; if (client.TryGetProperty(projectUri, SvnPropertyNames.SvnExternals, out components)) { if (string.IsNullOrWhiteSpace(components) == false) { string[] componentInforArray = components.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); SvnComponent component; foreach (string componentInfor in componentInforArray) { component = new SvnComponent(componentInfor); componentList.Add(component); } } } } return(componentList); } catch (Exception) { throw; } }
private void CheckOutProject(CheckOutArguments arg) { using (SvnClient client = new SvnClient()) { // Bind the SharpSvn UI to our client for SSL certificate and credentials SvnUIBindArgs bindArgs = new SvnUIBindArgs(); SvnUI.Bind(client, bindArgs); if (arg.ShowMoreLogInformation) { client.Notify += new EventHandler <SvnNotifyEventArgs>(client_Notify); } client.Cancel += new EventHandler <SvnCancelEventArgs>(client_Cancel); Uri rootUri = client.GetRepositoryRoot(arg.ProjectWorkspaceUri); myIfsSvn.CheckOut(client, arg.ProjectNbprojectUri, arg.CheckOutPathNbproject, new SvnCheckOutArgs() { ThrowOnError = false, IgnoreExternals = true }, arg.CleanUpWhenLocked); myIfsSvn.CheckOut(client, arg.ProjectWorkspaceUri, arg.CheckOutPathWorkspace, new SvnCheckOutArgs() { IgnoreExternals = true }, arg.CleanUpWhenLocked); myIfsSvn.CheckOut(client, arg.ProjectDocumentUri, arg.CheckOutPathDocument, new SvnCheckOutArgs() { IgnoreExternals = true }, arg.CleanUpWhenLocked); this.Log("Starting Component Checkout [" + DateTime.Now.ToString() + "]", arg.ShowMoreLogInformation); Uri componentUri; if (arg.HasDocCompornents) { componentUri = new Uri(Properties.Resources.ServerDocumentationOnlinedocframework.Replace("^/", rootUri.AbsoluteUri)); myIfsSvn.CheckOut(client, componentUri, arg.CheckOutPathDocumentEn, null, arg.CleanUpWhenLocked); } foreach (SvnComponent component in arg.CompornentArray) { componentUri = new Uri(component.Path.Replace("^/", rootUri.AbsoluteUri)); this.Log(component.Name, arg.ShowMoreLogInformation); if (component.Type == SvnComponent.SvnComponentType.Work) { myIfsSvn.CheckOut(client, componentUri, arg.CheckOutPathWorkspace + @"\" + component.Name, null, arg.CleanUpWhenLocked); } else if (component.Type == SvnComponent.SvnComponentType.Document) { List <SvnListEventArgs> folderList = myIfsSvn.GetFolderList(componentUri); folderList.RemoveAt(0); foreach (SvnListEventArgs folder in folderList) { myIfsSvn.CheckOut(client, folder.Uri, arg.CheckOutPathDocumentEn + @"\" + folder.Name, null, arg.CleanUpWhenLocked); } } } } }
private void GetUriList(BackgroundWorker worker, DoWorkEventArgs e, SearchArguments arg) { using (SvnClient client = new SvnClient()) { // Bind the SharpSvn UI to our client for SSL certificate and credentials SvnUIBindArgs bindArgs = new SvnUIBindArgs(); SvnUI.Bind(client, bindArgs); Collection <SvnListEventArgs> componentList; client.GetList(arg.ComponentListUri, out componentList); Collection <SvnListEventArgs> branchList; SvnUriTarget branchListUri; double currentProgress = 0; double progressIncrement = 0; int itemcount = componentList.Count(); if (itemcount > 0) { progressIncrement = 100.00 / itemcount; } foreach (SvnListEventArgs component in componentList) { if (worker.CancellationPending) { e.Cancel = true; } else { currentProgress += progressIncrement; worker.ReportProgress(Convert.ToInt32(currentProgress)); if (string.IsNullOrWhiteSpace(component.Path) == false) { branchListUri = new SvnUriTarget(component.Uri + @"branches/project"); try { client.GetList(branchListUri, out branchList); bool match = false; foreach (SvnListEventArgs branch in branchList) { if (worker.CancellationPending) { e.Cancel = true; } else { match = Regex.IsMatch(branch.Name, arg.SearchPattern, RegexOptions.IgnoreCase); if (match) { worker.ReportProgress(Convert.ToInt32(currentProgress), new SearchResults(component.Path, arg.RootUri.Uri, branch.Uri)); } } } } catch (Exception) { } } } } } }
private void LoadStaticcompornetList(BackgroundWorker worker, DoWorkEventArgs e, SearchArguments arg) { using (SvnClient client = new SvnClient()) { // Bind the SharpSvn UI to our client for SSL certificate and credentials SvnUIBindArgs bindArgs = new SvnUIBindArgs(); SvnUI.Bind(client, bindArgs); Collection <SvnListEventArgs> componentList; client.GetList(arg.ComponentListUri, out componentList); SvnListEventArgs root = componentList.Single(c => c.Name == arg.ComponentListUri.FileName); componentList.Remove(root); double currentProgress = 0; double progressIncrement = 0; int itemcount = componentList.Count(); if (itemcount > 0) { progressIncrement = 100.00 / itemcount; } MemoryStream ms = new MemoryStream(); StreamReader rs; SvnUriTarget deployIniUrl; foreach (SvnListEventArgs component in componentList) { if (worker.CancellationPending) { e.Cancel = true; } else { currentProgress += progressIncrement; worker.ReportProgress(Convert.ToInt32(currentProgress)); if (string.IsNullOrWhiteSpace(component.Path) == false) { deployIniUrl = new SvnUriTarget(component.Uri + @"trunk/deploy.ini"); ms.SetLength(0); if (client.Write(deployIniUrl, ms, new SvnWriteArgs() { ThrowOnError = false })) { ms.Position = 0; rs = new StreamReader(ms); string fileContent = rs.ReadToEnd(); int startIndex = fileContent.IndexOf("\r\n[Connections]\r\n"); if (startIndex != -1) { startIndex += "\r\n[Connections]\r\n".Length; int endIndex = fileContent.IndexOf("[", startIndex); if (endIndex == -1) { endIndex = fileContent.Length; } fileContent = fileContent.Substring(startIndex, endIndex - startIndex); string[] componentArray = fileContent.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); List <string> componentStaticList = new List <string>(); foreach (string componentValue in componentArray) { if (componentValue.Contains("STATIC")) { componentStaticList.Add(componentValue.Substring(0, componentValue.IndexOf("=STATIC")).ToLowerInvariant()); } } arg.ComponentDictionary.Add(component.Name, componentStaticList); } } } } } } }