Beispiel #1
0
        public void ToStringPrivateGeneratesPublicString()
        {
            PrivateString hidden = "private";
            var           args   = new PrivateArguments("public", hidden);

            Assert.AreEqual("public private", args.ToString(SecureDataMode.Private));
        }
Beispiel #2
0
        // tf get itemspec [/version:versionspec] [/all] [/overwrite] [/force]
        // [/preview] [/recursive] [/noprompt]
        private ProcessInfo GetWorkSpaceProcessInfo(IIntegrationResult result)
        {
            var buffer = new PrivateArguments(
                "get",
                "/recursive",
                "/noprompt");

            if (All)
            {
                buffer.Add("/all");
            }

            if (Overwrite)
            {
                buffer.Add("/overwrite");
            }

            if (Force)
            {
                buffer.Add("/force");
            }

            buffer.AddQuote(WorkingDirectory);

            AppendSourceControlAuthentication(buffer);

            return(NewProcessInfo(buffer, result));
        }
        /// <summary>
        /// When getting by label, the vault command-line client requires a disk path even if you're retrieving
        /// into a working folder.  This retrieves that working path so we can specify it in the get command.  We also
        /// need to know the working directory before we retrieve source if we're going to clean it out, when cleanCopy is true.
        /// Returns true if a working folder was found and WorkingDirectory was set, false if not.
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        protected string GetVaultWorkingFolder(IIntegrationResult result)
        {
            var builder = new PrivateArguments("listworkingfolders");

            AddCommonOptionalArguments(builder);

            ProcessInfo   processInfo   = ProcessInfoFor(builder, result);
            ProcessResult processResult = Execute(processInfo);

            // parse list of working folders
            XmlDocument  xml = GetVaultResponse(processResult, processInfo);
            XmlNodeList  workingFolderNodes = xml.SelectNodes("/vault/listworkingfolders/workingfolder");
            XmlAttribute repositoryFolderAtt;
            XmlAttribute localFolderAtt;

            foreach (XmlNode workingFolderNode in workingFolderNodes)
            {
                repositoryFolderAtt = workingFolderNode.Attributes["reposfolder"];
                localFolderAtt      = workingFolderNode.Attributes["localfolder"];
                if (repositoryFolderAtt != null && localFolderAtt != null)
                {
                    if (repositoryFolderAtt.InnerText == _shim.Folder)
                    {
                        return(localFolderAtt.InnerText);
                    }
                }
            }

            return(null);
        }
Beispiel #4
0
        public void ToStringGeneratesPublicString()
        {
            PrivateString hidden = "private";
            var           args   = new PrivateArguments("public", hidden);

            Assert.AreEqual("public " + hidden.PublicValue, args.ToString());
        }
Beispiel #5
0
 private void AppendSourceControlAuthentication(PrivateArguments buffer)
 {
     if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password.PrivateValue))
     {
         buffer.Add("/login:" + this.BuildTfsAuthenticationString());
     }
 }
Beispiel #6
0
        public void ImplicitOperatorGeneratesInstance()
        {
            PrivateArguments args = "test args";

            Assert.AreEqual(1, args.Count);
            Assert.AreEqual("test args", args.ToString());
        }
Beispiel #7
0
        public void ConstructorWithTwoArgumentsInitialises()
        {
            var args = new PrivateArguments("first", "second");

            Assert.AreEqual(2, args.Count);
            Assert.AreEqual("first second", args.ToString());
        }
Beispiel #8
0
        public void ConstructorWithOneArgumentInitialises()
        {
            var args = new PrivateArguments("test");

            Assert.AreEqual(1, args.Count);
            Assert.AreEqual("test", args.ToString());
        }
Beispiel #9
0
        private ProcessInfo NewProcessInfo(PrivateArguments args, IIntegrationResult result)
        {
            string workingDirectory = Path.GetFullPath(result.BaseFromWorkingDirectory(WorkingDirectory));

            if (!Directory.Exists(workingDirectory))
            {
                Directory.CreateDirectory(workingDirectory);
            }

            var processInfo = new ProcessInfo(Executable, args, workingDirectory);

            processInfo.StreamEncoding = Encoding.UTF8;

            if (!string.IsNullOrEmpty(CodePage))
            {
                int codePage;
                if (int.TryParse(CodePage, out codePage))
                {
                    processInfo.StreamEncoding = Encoding.GetEncoding(codePage);
                }
                else
                {
                    throw new CruiseControlException(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Code page {0} could not be parsed to an encoding via instruction : Encoding.GetEncoding(codePage)", CodePage));
                }
            }

            processInfo.TimeOut = 600000;
            return(processInfo);
        }
Beispiel #10
0
        private ProcessInfo VersionHistoryProcessInfo(IIntegrationResult from, IIntegrationResult to, bool bForceGetLatestVersion)
        {
            var builder = new PrivateArguments();

            builder.Add("versionhistory ", _shim.Folder);

            // Look only for changes, unless caller asked us to get the latest folder
            // version regardless of whether there's been a change.
            if (!bForceGetLatestVersion)
            {
                // use folderVersion when possible because it's faster and more accurate
                if (_folderVersion != 0)
                {
                    builder.Add("-beginversion ", (_folderVersion + 1).ToString(CultureInfo.CurrentCulture));
                }
                else
                {
                    builder.Add("-begindate ", from.StartTime.ToString("s", CultureInfo.CurrentCulture));
                    builder.Add("-enddate ", to.StartTime.ToString("s", CultureInfo.CurrentCulture));
                }
            }

            // we only ever need the most recent change
            builder.Add("-rowlimit ", "1");

            AddCommonOptionalArguments(builder);
            return(ProcessInfoFor(builder, from));
        }
Beispiel #11
0
        private ProcessInfo RevertWorkingCopy(IIntegrationResult result)
        {
            var buffer = new PrivateArguments("revert", "--recursive");

            buffer.Add(null, Path.GetFullPath(result.BaseFromWorkingDirectory(WorkingDirectory)), true);

            return(NewProcessInfo(buffer, result));
        }
        /// <summary>
        /// Prepare an AccuRev command for execution.
        /// </summary>
        /// <param name="args">arguments for the "accurev" command</param>
        /// <param name="result">IntegrationResult for which the command will be run</param>
        /// <returns>a ProcessInfo object primed to execute the specified command</returns>
        private ProcessInfo PrepCommand(PrivateArguments args, IIntegrationResult result)
        {
            Log.Debug(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Preparing to run AccuRev command: {0} {1}", Executable, args));
            ProcessInfo command = new ProcessInfo(Executable, args, result.BaseFromWorkingDirectory(Workspace));

            SetEnvironmentVariables(command.EnvironmentVariables, result);
            return(command);
        }
Beispiel #13
0
 private void AppendUsernameAndPassword(PrivateArguments builder)
 {
     if (!string.IsNullOrEmpty(Username))
     {
         PrivateString userPlusPass = "******"-Y" + Username + "," + Password.PrivateValue + "\"";
         builder.Add(userPlusPass);
     }
 }
Beispiel #14
0
        private ProcessInfo CleanupWorkingCopy(IIntegrationResult result)
        {
            var buffer = new PrivateArguments("cleanup");

            buffer.Add(null, Path.GetFullPath(result.BaseFromWorkingDirectory(WorkingDirectory)), true);

            return(NewProcessInfo(buffer, result));
        }
Beispiel #15
0
        public void AddQuoteWithPrefixedValueAdds()
        {
            var args = new PrivateArguments();

            args.AddQuote("pre=", "test Value");
            Assert.AreEqual(1, args.Count);
            Assert.AreEqual("pre=\"test Value\"", args.ToString());
        }
Beispiel #16
0
        public void AddIfWithAutoQuoteValueAddsOnTrue()
        {
            var args = new PrivateArguments();

            args.AddIf(true, "pre=", "test Value", true);
            Assert.AreEqual(1, args.Count);
            Assert.AreEqual("pre=\"test Value\"", args.ToString());
        }
Beispiel #17
0
        public void PlusOperatorAddsPublicValue()
        {
            PrivateArguments args = "test args";

            args += "value";
            Assert.AreEqual(2, args.Count);
            Assert.AreEqual("test args value", args.ToString());
        }
Beispiel #18
0
        public void AddIfWithAutoQuoteValueDoesNotAddOnFalse()
        {
            var args = new PrivateArguments();

            args.AddIf(false, "pre=", "test Value", true);
            Assert.AreEqual(0, args.Count);
            Assert.AreEqual(string.Empty, args.ToString());
        }
Beispiel #19
0
        public void AddWithValueAdds()
        {
            var args = new PrivateArguments();

            args.Add("testValue");
            Assert.AreEqual(1, args.Count);
            Assert.AreEqual("testValue", args.ToString());
        }
Beispiel #20
0
        public void AddIfWithPrefixedValueAddsOnTrue()
        {
            var args = new PrivateArguments();

            args.AddIf(true, "pre=", "test Value");
            Assert.AreEqual(1, args.Count);
            Assert.AreEqual("pre=test Value", args.ToString());
        }
Beispiel #21
0
        private ProcessInfo RemoveLabelProcessInfo(IIntegrationResult result)
        {
            var builder = new PrivateArguments();

            builder.Add("deletelabel ", _shim.Folder);
            builder.Add(result.Label);
            AddCommonOptionalArguments(builder);
            return(ProcessInfoFor(builder, result));
        }
Beispiel #22
0
        private ProcessInfo NewCheckoutProcessInfo(IIntegrationResult result)
        {
            var buffer = new PrivateArguments("checkout");

            buffer.Add(string.Empty, TrunkUrl, true);
            buffer.Add(null, Path.GetFullPath(result.BaseFromWorkingDirectory(WorkingDirectory)), true);
            AppendCommonSwitches(buffer);
            return(NewProcessInfo(buffer, result));
        }
Beispiel #23
0
 private void AppendCommonSwitches(PrivateArguments buffer, bool isExternal)
 {
     if ((this.AuthCaching != AuthCachingMode.Always) && (!isExternal || (this.AuthCaching == AuthCachingMode.None)))
     {
         buffer.AddIf(!string.IsNullOrEmpty(this.Username), "--username ", this.Username, true);
         buffer.AddIf(this.Password != null, "--password ", this.Password, true);
         buffer.Add("--no-auth-cache");
     }
     buffer.Add("--non-interactive");
 }
Beispiel #24
0
        //		HISTORY_COMMAND_FORMAT = "log url --revision {LastRevision}:HEAD --verbose --xml --non-interactive";
        private ProcessInfo NewHistoryProcessInfoFromRevision(string lastRevision, IIntegrationResult to, string url)
        {
            var buffer = new PrivateArguments("log");

            buffer.Add(null, url, true);
            buffer.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, "-r {0}:HEAD", string.IsNullOrEmpty(lastRevision) ? "0" : lastRevision));
            buffer.Add("--verbose --xml");
            AppendCommonSwitches(buffer, url != this.TrunkUrl);
            return(NewProcessInfo(buffer, to));
        }
Beispiel #25
0
        //		HISTORY_COMMAND_FORMAT = "log url --revision \"{{{StartDate}}}:{{{EndDate}}}\" --verbose --xml --non-interactive";
        private ProcessInfo NewHistoryProcessInfo(IIntegrationResult from, IIntegrationResult to, string url)
        {
            var buffer = new PrivateArguments("log");

            buffer.Add(null, url, true);
            buffer.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, "-r \"{{{0}}}:{{{1}}}\"", FormatCommandDate(from.StartTime), FormatCommandDate(to.StartTime)));
            buffer.Add("--verbose --xml");
            AppendCommonSwitches(buffer, url != this.TrunkUrl);
            return(NewProcessInfo(buffer, to));
        }
Beispiel #26
0
        private ProcessInfo PropGetProcessInfo(IIntegrationResult result)
        {
            var buffer = new PrivateArguments("propget");

            buffer.AddIf(CheckExternalsRecursive, "-R");
            AppendCommonSwitches(buffer);
            buffer.Add("svn:externals");
            buffer.Add(TrunkUrl);
            return(NewProcessInfo(buffer, result));
        }
Beispiel #27
0
        private PrivateArguments LabelProcessInfoArgs(string label, string oldLabel)
        {
            var builder = new PrivateArguments();

            builder.Add("label ", Project, true);
            builder.Add("-L", label);
            builder.AddIf(!string.IsNullOrEmpty(oldLabel), "-VL", oldLabel);
            AppendUsernameAndPassword(builder);
            builder.Add("-I-Y");
            return(builder);
        }
Beispiel #28
0
        // "history ""{0}"" -excludeactions label,obliterate -rowlimit 0 -begindate {1:s} -enddate {2:s}
        // rowlimit 0 or -1 means unlimited (default is 1000 if not specified)
        // TODO: might want to make rowlimit configurable?
        private PrivateArguments BuildHistoryProcessArgs(DateTime from, DateTime to)
        {
            var builder = new PrivateArguments();

            builder.Add("history ", _shim.Folder);
            builder.Add(_shim.HistoryArgs);
            builder.Add("-begindate ", from.ToString("s", CultureInfo.CurrentCulture));
            builder.Add("-enddate ", to.ToString("s", CultureInfo.CurrentCulture));
            AddCommonOptionalArguments(builder);
            return(builder);
        }
Beispiel #29
0
        // tf dir [/server:servername] itemspec [/version:versionspec]
        // [/recursive] [/folders] [/deleted]
        private ProcessInfo CheckProjectProcessInfo(IIntegrationResult result)
        {
            var buffer = new PrivateArguments("dir", "/folders");

            buffer.Add("/server:", Server);
            buffer.AddQuote(ProjectPath);

            AppendSourceControlAuthentication(buffer);

            return(NewProcessInfo(buffer, result));
        }
Beispiel #30
0
        // tf workspaces /delete [/owner:ownername] [/computer:computername]
        // [/server:servername] workspacename
        private ProcessInfo DeleteWorkSpaceProcessInfo(IIntegrationResult result)
        {
            var buffer = new PrivateArguments("workspace", "/delete");

            buffer.Add("-server:", Server);
            buffer.AddQuote(Workspace);

            AppendSourceControlAuthentication(buffer);

            return(NewProcessInfo(buffer, result));
        }