Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
 public void AllowInteractiveAuthorization()
 {
     CheckNotDisposed();
     if (!allowInteractiveAuthorization)
     {
         allowInteractiveAuthorization = true;
         SvnUI.Bind(client, SD.WinForms.MainWin32Window);
     }
 }
Ejemplo n.º 6
0
    static OperateSvnHelper()
    {
        _svnClient = new SvnClient();

        // 绑定图形化SVN操作窗口,比如当需要对SVN鉴权时弹出账户密码输入对话框
        SvnUIBindArgs uiBindArgs = new SvnUIBindArgs();

        SvnUI.Bind(_svnClient, uiBindArgs);
    }
Ejemplo n.º 7
0
 public void AllowInteractiveAuthorization()
 {
     CheckNotDisposed();
     if (!allowInteractiveAuthorization)
     {
         allowInteractiveAuthorization = true;
         SvnUI.Bind(client, WorkbenchSingleton.MainWin32Window);
     }
 }
Ejemplo n.º 8
0
        public bool Update(string path)
        {
            using (var client = new SvnClient())
            {
                SvnUI.Bind(client, parentWindow);
                return(client.Update(path, new SvnUpdateArgs {
                    AddsAsModifications = false, AllowObstructions = false, Depth = SvnDepth.Infinity, IgnoreExternals = true, KeepDepth = true, Revision = SvnRevision.Head, UpdateParents = false
                }));
            }

            return(false);
        }
Ejemplo n.º 9
0
 public void Move(string sourcePath, string destPath)
 {
     /*
      * SvnExec("mv -- " + Quote(sourcePath) + " " + Quote(destPath));
      */
     using (var client = new SvnClient())
     {
         SvnUI.Bind(client, parentWindow);
         var result = client.Move(sourcePath, destPath, new SvnMoveArgs {
             AllowMixedRevisions = false, AlwaysMoveAsChild = false, CreateParents = true, Force = true, MetaDataOnly = false
         });
     }
 }
Ejemplo n.º 10
0
 public void Remove(string path, bool recursive)
 {
     /*
      * SvnExec("rm " + (recursive ? "-r " : "") + "-- " + Quote(path));
      */
     using (var client = new SvnClient())
     {
         SvnUI.Bind(client, parentWindow);
         var result = client.Delete(path, new SvnDeleteArgs {
             Force = true, KeepLocal = false
         });
     }
 }
Ejemplo n.º 11
0
        /*
         * This adds, modifies, and removes index entries to match the working tree.
         */
        public bool AddAll()
        {
            /*
             * var startInfo = GetStartInfo("add -A");
             *
             * // add fails if there are no files (directories don't count)
             * return ExecuteUnless(startInfo, "did not match any files");
             */
            var overallStatus = true;

            using (var client = new SvnClient())
            {
                SvnUI.Bind(client, parentWindow);

                var statusList    = (Collection <SvnStatusEventArgs>)null;
                var svnStatusArgs = new SvnStatusArgs {
                    Depth = SvnDepth.Infinity, IgnoreExternals = false, KeepDepth = false, RetrieveIgnoredEntries = false
                };

                if (client.GetStatus(useSvnStandardDirStructure ? trunkPath : workingCopyPath, svnStatusArgs, out statusList))
                {
                    overallStatus = statusList.Select(svnStatusEventArg =>
                    {
                        switch (svnStatusEventArg.LocalNodeStatus)
                        {
                        case SvnStatus.Missing:
                            logger.WriteLine("Commit: Deleting file {0} due to status = {1}", svnStatusEventArg.FullPath, svnStatusEventArg.LocalNodeStatus);
                            return(client.Delete(svnStatusEventArg.FullPath, new SvnDeleteArgs {
                                KeepLocal = false, Force = false
                            }));

                        case SvnStatus.NotVersioned:
                            logger.WriteLine("Commit: Adding file {0} due to status = {1}", svnStatusEventArg.FullPath, svnStatusEventArg.LocalNodeStatus);
                            return(client.Add(svnStatusEventArg.FullPath, new SvnAddArgs {
                                AddParents = false, Depth = SvnDepth.Infinity, Force = false
                            }));

                        default:
                            return(true);
                        }
                    })
                                    .Aggregate(true, (state, val) => state &= val);
                }
                else
                {
                    overallStatus = false;
                }
            }

            return(overallStatus);
        }
Ejemplo n.º 12
0
        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;
            }
        }
Ejemplo n.º 13
0
    static void Main(string[] args)
    {
        Uri uri = null;

        if (args.Length < 2 ||
            !Uri.TryCreate(args[0], UriKind.Absolute, out uri))
        {
            Console.Error.WriteLine("Usage: SvnDumpFileToRepository URL PATH");
        }
        using (SvnRepositoryClient repos = new SvnRepositoryClient())
        {
            repos.CreateRepository(args[1]);
        }
        Uri reposUri = SvnTools.LocalPathToUri(args[1], true);

        using (SvnClient client = new SvnClient())
            using (SvnClient client2 = new SvnClient())
            {
                SvnUI.Bind(client, new SvnUIBindArgs());
                string fileName = SvnTools.GetFileName(uri);
                bool   create   = true;
                client.FileVersions(uri,
                                    delegate(object sender, SvnFileVersionEventArgs e)
                {
                    Console.Write("Copying {0} in r{1}", fileName, e.Revision);
                    using (MemoryStream ms = new MemoryStream())
                    {
                        e.WriteTo(ms);     // Write full text to memory stream
                        ms.Position = 0;
                        // And now use 'svnmucc' to update repository
                        client2.RepositoryOperation(reposUri,
                                                    new SvnRepositoryOperationArgs {
                            LogMessage = e.LogMessage
                        },
                                                    delegate(SvnMultiCommandClient mucc)
                        {
                            if (create)
                            {
                                mucc.CreateFile(fileName, ms);
                                create = false;
                            }
                            else
                            {
                                mucc.UpdateFile(fileName, ms);
                            }
                        });
                    }
                });
            }
    }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        public void Tag(string name, string taggerName, string taggerEmail, string comment, DateTime localTime, string taggedPath)
        {
            /*
             * TempFile commentFile;
             *
             * var args = "tag";
             * AddComment(comment, ref args, out commentFile);
             *
             * // tag names are not quoted because they cannot contain whitespace or quotes
             * args += " -- " + name;
             *
             * using (commentFile)
             * {
             *  var startInfo = GetStartInfo(args);
             *  startInfo.EnvironmentVariables["GIT_COMMITTER_NAME"] = taggerName;
             *  startInfo.EnvironmentVariables["GIT_COMMITTER_EMAIL"] = taggerEmail;
             *  startInfo.EnvironmentVariables["GIT_COMMITTER_DATE"] = GetUtcTimeString(localTime);
             *
             *  ExecuteUnless(startInfo, null);
             * }
             */
            using (var client = new SvnClient())
            {
                SvnUI.Bind(client, parentWindow);
                var svnCopyArgs = new SvnCopyArgs {
                    LogMessage = comment, CreateParents = true, AlwaysCopyAsChild = false
                };

                var workingCopyUri = client.GetUriFromWorkingCopy(workingCopyPath);
                var tagsUri        = client.GetUriFromWorkingCopy(tagPath);
                var sourceUri      = useSvnStandardDirStructure ? client.GetUriFromWorkingCopy(trunkPath) : workingCopyUri;
                var tagUri         = new Uri(useSvnStandardDirStructure ? tagsUri : workingCopyUri, name);

                var svnCommitResult = (SvnCommitResult)null;
                var result          = client.RemoteCopy(sourceUri, tagUri, svnCopyArgs, out svnCommitResult);
                if (result)
                {
                    result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnAuthor, taggerName);
                    result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnDate, SvnPropertyNames.FormatDate(localTime));
                }
                result &= client.Update(workingCopyPath, new SvnUpdateArgs {
                    AddsAsModifications = false, AllowObstructions = false, Depth = SvnDepth.Infinity, IgnoreExternals = true, KeepDepth = true, Revision = SvnRevision.Head, UpdateParents = false
                });
            }
        }
Ejemplo n.º 16
0
        public bool Add(string path)
        {
            /*
             * var startInfo = GetStartInfo("add -- " + Quote(path));
             *
             * // add fails if there are no files (directories don't count)
             * return ExecuteUnless(startInfo, "did not match any files");
             */

            using (var client = new SvnClient())
            {
                SvnUI.Bind(client, parentWindow);
                return(client.Add(path, new SvnAddArgs {
                    AddParents = false, Depth = SvnDepth.Infinity, Force = true
                }));
            }

            return(false);
        }
Ejemplo n.º 17
0
        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;
            }
        }
Ejemplo n.º 18
0
        private void btnCommit_Click(object sender, EventArgs e)
        {
            if (txtSystemCode.Text == "")
            {
                return;
            }
            var           localAppsCSFileVersion = FileVersionInfo.GetVersionInfo(string.Format("d:/APPS_CS/{0}/{1}", txtSystemCode.Text, txtApp.Text));
            SvnCommitArgs args = new SvnCommitArgs();

            args.LogMessage = string.Format("System {0} version {1} Commit", txtSystemCode, localAppsCSFileVersion.FileVersion);
            SvnCommitResult result;

            using (var client = new SvnClient())
            {
                try
                {
                    SvnUI.Bind(client, this);
                    var addArgs = new SvnAddArgs()
                    {
                        Force = true
                    };
                    client.Add(string.Format("d:/APPS_CS/{0}", txtSystemCode.Text.ToLower()), addArgs);
                    client.Commit(string.Format("d:/APPS_CS/{0}", txtSystemCode.Text.ToLower()), args, out result);
                    if (result != null)
                    {
                        MessageBox.Show("Successfully commited revision " + result.Revision);
                    }
                    else
                    {
                        MessageBox.Show("No changes have been made to working copy since it was checked out.");
                    }
                }
                catch (SvnException se)
                {
                    MessageBox.Show(se.Message + "Error: " + se.SvnErrorCode + Environment.NewLine,
                                    "svn commit error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 19
0
        private void btnCommit_Click(object sender, EventArgs e)
        {
            if (tbFileName.Text.Length == 0)
            {
                MessageBox.Show("dosya seç");
                return;
            }
            SvnCommitArgs args = new SvnCommitArgs();

            args.LogMessage = tbMessage.Text;
            SvnCommitResult result;

            using (SharpSvn.SvnClient client = new SharpSvn.SvnClient())
            {
                try
                {
                    SvnUI.Bind(client, this);

                    client.Commit(tbFileName.Text, args, out result);
                    if (result != null)
                    {
                        MessageBox.Show("başarıyla revize edildi" + result.Revision + ".");
                    }
                    else
                    {
                        MessageBox.Show("teslim edildiğinden beri hiçbir değişiklilik yapılmamıştır");
                    }
                }

                catch (SvnException se)
                {
                    MessageBox.Show(se.Message + "Error: " + se.SvnErrorCode + Environment.NewLine,
                                    "svn commit error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 20
0
        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;
            }
        }
Ejemplo n.º 21
0
        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 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);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 23
0
 internal SvnRevisionProvider(string path)
 {
     Path = path;
     SvnUI.Bind(svnClient, new SvnUIBindArgs());
 }
        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)
                            {
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 25
0
        public bool Commit(string authorName, string authorEmail, string comment, DateTime localTime)
        {
            /*
             * TempFile commentFile;
             *
             * var args = "commit";
             * AddComment(comment, ref args, out commentFile);
             *
             * using (commentFile)
             * {
             *  var startInfo = GetStartInfo(args);
             *  startInfo.EnvironmentVariables["GIT_AUTHOR_NAME"] = authorName;
             *  startInfo.EnvironmentVariables["GIT_AUTHOR_EMAIL"] = authorEmail;
             *  startInfo.EnvironmentVariables["GIT_AUTHOR_DATE"] = GetUtcTimeString(localTime);
             *
             *  // also setting the committer is supposedly useful for converting to Mercurial
             *  startInfo.EnvironmentVariables["GIT_COMMITTER_NAME"] = authorName;
             *  startInfo.EnvironmentVariables["GIT_COMMITTER_EMAIL"] = authorEmail;
             *  startInfo.EnvironmentVariables["GIT_COMMITTER_DATE"] = GetUtcTimeString(localTime);
             *
             *  // ignore empty commits, since they are non-trivial to detect
             *  // (e.g. when renaming a directory)
             *  return ExecuteUnless(startInfo, "nothing to commit");
             * }
             */
            if (string.IsNullOrEmpty(authorName))
            {
                return(false);
            }
            using (var client = new SvnClient())
            {
                SvnUI.Bind(client, parentWindow);
                var svnCommitArgs = new SvnCommitArgs {
                    LogMessage = comment
                };

                var svnCommitResult = (SvnCommitResult)null;
                var result          = client.Commit(useSvnStandardDirStructure ? trunkPath : workingCopyPath, svnCommitArgs, out svnCommitResult);
                // commit without files results in result=true and svnCommitResult=null
                if (svnCommitResult != null)
                {
                    if (result)
                    {
                        var workingCopyUri = client.GetUriFromWorkingCopy(useSvnStandardDirStructure ? trunkPath : workingCopyPath);

                        result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnAuthor, authorName);
                        result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnDate, SvnPropertyNames.FormatDate(localTime));

                        result &= client.Update(workingCopyPath, new SvnUpdateArgs {
                            AddsAsModifications = false, AllowObstructions = false, Depth = SvnDepth.Infinity, IgnoreExternals = true, KeepDepth = true, Revision = SvnRevision.Head, UpdateParents = false
                        });
                    }
                    else
                    {
                        MessageBox.Show(string.Format("{0} Error Code: {1}{2}", svnCommitResult.PostCommitError, "", Environment.NewLine), "SVN Commit Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                return(result);
            }
            return(false);
        }
Ejemplo n.º 26
0
        public void VssLabel(string name, string taggerName, string taggerEmail, string comment, DateTime localTime, string taggedPath)
        {
            using (var client = new SvnClient())
            {
                SvnUI.Bind(client, parentWindow);

                var codeBasePath = useSvnStandardDirStructure ? this.trunkPath : workingCopyPath;
                var relativePath = taggedPath.StartsWith(codeBasePath) ? taggedPath.Substring(codeBasePath.Length) : null;
                if (relativePath == null || client.GetUriFromWorkingCopy(taggedPath) == null)
                {
                    throw new ArgumentException(string.Format("invalid path {0}", taggedPath));
                }

                var fullLabelPath = Path.Combine(labelPath, name + relativePath);

                Uri repositoryRootUri = client.GetUriFromWorkingCopy(workingCopyPath);

                var codeBaseUri  = client.GetUriFromWorkingCopy(codeBasePath);
                var labelBaseUri = client.GetUriFromWorkingCopy(labelPath);

                var relativeSourceUri = new Uri(taggedPath.Substring(workingCopyPath.Length), UriKind.Relative);
                relativeSourceUri = repositoryRootUri.MakeRelativeUri(new Uri(repositoryRootUri, relativeSourceUri));

                var relativeLabelUri = new Uri(fullLabelPath.Substring(workingCopyPath.Length), UriKind.Relative);
                relativeLabelUri = repositoryRootUri.MakeRelativeUri(new Uri(repositoryRootUri, relativeLabelUri));

                var sourceUri = client.GetUriFromWorkingCopy(taggedPath);
                var labelUri  = new Uri(labelBaseUri, name + "/" + sourceUri.ToString().Substring(codeBaseUri.ToString().Length));

                var fullLabelPathExists = client.GetUriFromWorkingCopy(fullLabelPath) != null;

                // check intermediate parents
                var intermediateParentNames = labelUri.ToString().Substring(labelBaseUri.ToString().Length).Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Reverse().Skip(1).Reverse();
                var intermediateParentRelativeUriToCreate = new List <string>();
                {
                    var intermediatePath    = labelPath;
                    var intermediateUriPath = repositoryRootUri.MakeRelativeUri(labelBaseUri).ToString();
                    foreach (var parent in intermediateParentNames)
                    {
                        intermediatePath     = Path.Combine(intermediatePath, parent);
                        intermediateUriPath += parent + "/";
                        if (client.GetUriFromWorkingCopy(intermediatePath) == null)
                        {
                            intermediateParentRelativeUriToCreate.Add(intermediateUriPath.Substring(0, intermediateUriPath.Length - 1));
                        }
                    }
                }


                // perform svn copy or svn delete + svn copy if necessary
                var result          = true;
                var svnCommitResult = (SvnCommitResult)null;

                client.RepositoryOperation(repositoryRootUri, new SvnRepositoryOperationArgs {
                    LogMessage = comment
                }, delegate(SvnMultiCommandClient muccClient)
                {
                    // if label path already exists, delete first
                    if (fullLabelPathExists)
                    {
                        result &= muccClient.Delete(Uri.UnescapeDataString(relativeLabelUri.ToString()));
                    }

                    // create intermediate parents if necessary
                    foreach (var parentRelativeUri in intermediateParentRelativeUriToCreate)
                    {
                        result &= muccClient.CreateDirectory(Uri.UnescapeDataString(parentRelativeUri));
                    }

                    result &= muccClient.Copy(Uri.UnescapeDataString(relativeSourceUri.ToString()), Uri.UnescapeDataString(relativeLabelUri.ToString()));
                }, out svnCommitResult);

                if (result)
                {
                    result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnAuthor, taggerName);
                    result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnDate, SvnPropertyNames.FormatDate(localTime));
                }

                result &= client.Update(workingCopyPath, new SvnUpdateArgs {
                    AddsAsModifications = false, AllowObstructions = false, Depth = SvnDepth.Infinity, IgnoreExternals = true, KeepDepth = true, Revision = SvnRevision.Head, UpdateParents = false
                });
            }
        }
Ejemplo n.º 27
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtRemotePath.Text))
            {
                MessageBox.Show("必须输入远程目录", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrWhiteSpace(txtOutputPath.Text))
            {
                MessageBox.Show("必须输入文件输出目录", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Task.Run(() =>
            {
                List <ChangedFile> changedFiles = new List <ChangedFile>();
                var deleteList  = new List <string>();
                var includeList = txtInclude.Text.Split(Environment.NewLine.ToCharArray(),
                                                        StringSplitOptions.RemoveEmptyEntries);
                using (SvnRemoteSession remoteSession = new SvnRemoteSession(new Uri(txtRemotePath.Text)))
                {
                    SvnUI.Bind(remoteSession, new SvnUIBindArgs());
                    SvnRemoteLogArgs svnRemoteLogArgs = new SvnRemoteLogArgs();
                    var svnRemoteLocationSegmentEventArgsCollection =
                        new Collection <SvnRemoteLocationSegmentEventArgs>();
                    remoteSession.GetLocationSegments("/", out svnRemoteLocationSegmentEventArgsCollection);
                    foreach (var svnRemoteLocationSegmentEventArgse in svnRemoteLocationSegmentEventArgsCollection)
                    {
                        if (!long.TryParse(txtFirstRevision.Text, out var startRevision))
                        {
                            startRevision = 0;
                        }

                        startRevision =
                            svnRemoteLocationSegmentEventArgse.StartRevision > startRevision
                                ? svnRemoteLocationSegmentEventArgse.StartRevision
                                : startRevision;
                        if (!long.TryParse(txtSecondRevision.Text, out var endRevision))
                        {
                            endRevision = long.MaxValue;
                        }

                        endRevision = svnRemoteLocationSegmentEventArgse.EndRevision < endRevision
                            ? svnRemoteLocationSegmentEventArgse.EndRevision
                            : endRevision;
                        remoteSession.Log("/", new SvnRevisionRange(startRevision, endRevision), ((o, args) =>
                        {
                            foreach (var argsChangedPath in args.ChangedPaths)
                            {
                                if (cbDontIncludeDelete.Checked)
                                {
                                    if (argsChangedPath.Action == SvnChangeAction.Delete)
                                    {
                                        deleteList.Add(argsChangedPath.Path);
                                        changedFiles = changedFiles.Where(x => x.Path != argsChangedPath.Path).ToList();
                                        continue;
                                    }

                                    if (deleteList.Contains(argsChangedPath.Path))
                                    {
                                        continue;
                                    }
                                }

                                if (argsChangedPath.ContentModified == false)
                                {
                                    continue;
                                }

                                if (rbDontInclude.Checked && includeList.Any(x => argsChangedPath.Path.IndexOf(x) >= 0))
                                {
                                    continue;
                                }

                                if (rbInclude.Checked && !includeList.Any(x => argsChangedPath.Path.IndexOf(x) >= 0))
                                {
                                    continue;
                                }

                                ChangedFile changedFile = new ChangedFile();
                                changedFile.Path = argsChangedPath.Path;
                                changedFile.Author = args.Author;
                                changedFile.Message = args.LogMessage;
                                changedFile.FirstModifyAction = argsChangedPath.Action.ToString();
                                changedFile.FirstModifyRevision = args.Revision;
                                if (cbComparedEvery.Checked || !changedFiles.Contains(changedFile))
                                {
                                    changedFiles.Add(changedFile);
                                }
                            }
                        }));
                    }

                    //File.AppendAllLines("E:/123.txt", changedFiles.Select(x => $"文件信息:{x.Path}\t文件是否是修改:{x.FirstModifyAction}\t文件初次修改版本号:{x.FirstModifyRevision}\t初次修改作者:{x.Author}\t提交信息:{x.Message}"));
                    var wb      = new XLWorkbook(new MemoryStream(Properties.Resources.model));
                    int lineNum = 1;
                    if (wb.TryGetWorksheet("ソース一覧", out IXLWorksheet iWorksheet))
                    {
                        foreach (var changedFile in changedFiles)
                        {
                            var row = iWorksheet.Row(lineNum + 2);
                            row.Cell("A").SetValue(lineNum);
                            row.Cell("B").SetValue(Path.GetDirectoryName(changedFile.Path));
                            row.Cell("C").SetValue(Path.GetFileName(changedFile.Path));
                            if (changedFile.FirstModifyAction == "Add")
                            {
                                row.Cell("H").SetValue("○");
                            }
                            else if (changedFile.FirstModifyAction == "Modify")
                            {
                                row.Cell("I").SetValue("○");
                            }

                            row.Cell("J").SetValue(changedFile.Author);
                            if (cbWriteFirstRevision.Checked)
                            {
                                row.Cell("L").Value = "版本号:" + changedFile.FirstModifyRevision;
                            }

                            if (cbWriteFirstAction.Checked)
                            {
                                row.Cell("L").Value += "执行操作" + changedFile.FirstModifyAction;
                            }

                            lineNum++;
                        }

                        var range = iWorksheet.Range(3, 1, lineNum + 1, 12);
                        range.Style.Border.BottomBorder = XLBorderStyleValues.Dotted;
                        range.Style.Border.RightBorder  = XLBorderStyleValues.Thin;
                        wb.SaveAs(txtOutputPath.Text);
                    }
                }

                this.Invoke((MethodInvoker)(() =>
                {
                    btnStart.Enabled = true;
                    btnStart.Text = "开始";
                }));
                MessageBox.Show("处理完成");
            });
            btnStart.Enabled = false;
            btnStart.Text    = "处理中";
        }
Ejemplo n.º 28
0
        private bool generateXMLSystems()
        {
            Cursor.Current = Cursors.WaitCursor;
            int    contador = 0;
            string servidor = "";

            // lets get the counter for the XML file version
            using (var getContador = new SP(Values.gDatos, "pGetContador"))
            {
                getContador.AddParameterValue("Contador", contador);
                getContador.AddParameterValue("Serv", servidor);
                getContador.AddParameterValue("Codigo", "XMLSystems");
                try
                {
                    getContador.Execute();
                }
                catch (Exception ex)
                {
                    CTWin.MsgError(ex.Message);
                    return(false);
                }
                if (getContador.LastMsg.Substring(0, 2) != "OK")
                {
                    CTWin.MsgError(getContador.LastMsg);
                    return(false);
                }
                contador = Convert.ToInt32(getContador.ReturnValues()["@Contador"]);
            }
            // create the root of the XML doc
            XDocument xmlDocument;
            string    _xml = string.Format(
                @"<?xml version='1.0' encoding='utf - 8'?>
<!--{0} systems file-->
<systemsfile version='{0}'>
<specials>
</specials>
<systems>
</systems>
</systemsfile>", contador);

            xmlDocument = XDocument.Parse(_xml);
            var serverSystemsPath = "\\\\VALSRV02\\APPS_CS";
            //get files in apps directory
            var serverSystemsDir = Directory.GetFiles(serverSystemsPath).Where(f => Path.GetExtension(f) == ".zip");

            //create the rootDir element
            foreach (var filePath in serverSystemsDir)
            {
                var fileInfo        = new FileInfo(filePath);
                var xSpecialElement = new XElement("special", new XAttribute("name", Path.GetFileNameWithoutExtension(filePath)));
                var xSElement       = new XElement("File", new XAttribute("path", filePath.Replace(serverSystemsPath, "").Replace(fileInfo.Name, "").Substring(1)), new XAttribute("fileName", fileInfo.Name), new XAttribute("fileSize", fileInfo.Length), new XAttribute("fileTime", fileInfo.LastWriteTime));
                xSpecialElement.Add(xSElement);
                xmlDocument.Descendants("specials").FirstOrDefault().Add(xSpecialElement);
            }
            var directories = Directory.GetDirectories(serverSystemsPath);

            foreach (var directoryPath in directories.Where(x => !x.Contains(".svn")))
            {
                var dirInfo        = new DirectoryInfo(directoryPath);
                var xSystemElement = new XElement("system", new XAttribute("name", dirInfo.Name));
                xSystemElement.Add(xmlFromDirectory(directoryPath, serverSystemsPath));
                xmlDocument.Descendants("systems").FirstOrDefault().Add(xSystemElement);
            }
            var localXmlFile = "d:\\APPS_CS\\systems.xml";

            xmlDocument.Save(localXmlFile);
            // commit new file to svn
            SvnCommitArgs args = new SvnCommitArgs();

            args.LogMessage = string.Format("systems.xml file version {0} Commit", contador);
            SvnCommitResult result;

            using (var client = new SvnClient())
            {
                try
                {
                    SvnUI.Bind(client, this);
                    client.Commit(localXmlFile, args, out result);
                    if (result != null)
                    {
                        CTLM.StatusMsg("Successfully commited revision " + result.Revision);
                    }
                    else
                    {
                        CTLM.StatusMsg("No changes have been made to working copy since it was checked out.");
                    }
                }
                catch (SvnException se)
                {
                    CTLM.StatusMsg(se.Message + "Error: " + se.SvnErrorCode);
                }
            }
            return(true);
        }