Exemplo n.º 1
0
        void UpdateSelector(WindowTitleBuilder builder)
        {
            string selectorInfo;
            string error;

            int cmdres = CmdRunner.ExecuteCommandWithResult(
                string.Format("{0} wi --machinereadable --fieldseparator={1}",
                              DEFAULT_PLASTIC_COMMAND, FIELD_SEPARATOR),
                mWkPath, out selectorInfo, out error, false);

            if (cmdres != 0 || !string.IsNullOrEmpty(error))
            {
                return;
            }

            string[] chunks = selectorInfo.Trim().Split(
                new string[] { FIELD_SEPARATOR }, StringSplitOptions.RemoveEmptyEntries);

            if (chunks.Length != 3)
            {
                builder.SetSelector(string.Empty);
                return;
            }

            string selector = string.Format("{0}:{1}@{2}",
                                            chunks[0].ToLower(), chunks[1], chunks[2]);

            builder.SetSelector(selector);
        }
        private static void UpdateCommand()
        {
            int result = CmdRunner.ExecuteCommandWithResult(
                String.Format("cm upd {0}", Environment.CurrentDirectory),
                Environment.CurrentDirectory);

            Console.WriteLine(string.Format("The update command finished with result: " + result));
        }
        private static bool ExecuteCommand(string command, out string error)
        {
            string output;
            int    result = CmdRunner.ExecuteCommandWithResult(command, WorkingDirectory, out output, out error, true);

            if (string.IsNullOrEmpty(error))
            {
                error = output;
            }
            return(result == 0);
        }
        private static void MkWkCommand()
        {
            int result = CmdRunner.ExecuteCommandWithResult(
                String.Format("cm mkwk test {0}", Environment.CurrentDirectory),
                Environment.CurrentDirectory);

            if (result > 0)
            {
                throw new Exception("Sorry, but I couldn't create a workspace. :(");
            }

            Console.WriteLine(string.Format("The mkwk command executed with result: " + result));
        }
Exemplo n.º 5
0
        string GetWorkspacePath(string solutionpath)
        {
            string wkPath;
            string error;

            int cmdres = CmdRunner.ExecuteCommandWithResult(
                string.Format("{0} gwp . --format=\"{{1}}\"", DEFAULT_PLASTIC_COMMAND),
                Directory.GetParent(solutionpath).FullName, out wkPath, out error, false);

            if (cmdres != 0 || !string.IsNullOrEmpty(error))
            {
                return(null);
            }

            return(wkPath.Trim());
        }
        private static void SomeCommandsInShell()
        {
            string repos = CmdRunner.ExecuteCommandWithStringResult(
                "cm lrep",
                Environment.CurrentDirectory, true);

            string output;
            string error;

            CmdRunner.ExecuteCommandWithResult(
                "cm rmwk .",
                Environment.CurrentDirectory, out output, out error, true);

            Console.WriteLine("The Plastic server has the following repositories: ");
            PrintResult(repos);
            Console.WriteLine(String.Format("The workspace was deleted. Output: {0}. Error: {1} ",
                                            output, error));
        }
Exemplo n.º 7
0
        static void SetStatusToTesting(string branch, Config config)
        {
            string command = string.Format(
                "cm setattribute att:status@{1} br:{0}@{1} TESTING", branch, config.PlasticRepo);
            string output;
            string error;
            int    cmdResult = CmdRunner.ExecuteCommandWithResult(
                command, Environment.CurrentDirectory, out output, out error, true);

            if (cmdResult == 0)
            {
                return;
            }

            mLog.WarnFormat(
                "Couldn't set the 'status' attribute of branch '{0}' to 'TESTING'", branch);
            mLog.InfoFormat("Command output: {0}", output);
            mLog.ErrorFormat("Command error: {1}", error);
        }
Exemplo n.º 8
0
        internal void Replicate(
            IList branches, string src, string dst,
            string wkpath, int initBranch)
        {
            int init = Environment.TickCount;

            string cmd = "{3} replicate \"br:{0}@{1}\" \"rep:{2}\"";

            int count = 0;

            foreach (Branch branch in branches)
            {
                if (count < initBranch)
                {
                    ++count;
                    continue;
                }

                mLog.InfoFormat("Replicating branch {0}. {1} of {2}. " +
                                "Time so far {3}",
                                branch.Name, count++, branches.Count,
                                TimeSpan.FromMilliseconds(Environment.TickCount - init)
                                .ToString());

                string command = string.Format(
                    cmd, branch.Name, src, dst, mCmExec);

                //replicate
                try
                {
                    int ini       = Environment.TickCount;
                    int cmdresult = CmdRunner.ExecuteCommandWithResult(
                        command, wkpath);
                    mLog.InfoFormat("Branch {0} replicated in {1} ms",
                                    branch.Name, Environment.TickCount - ini);

                    if (!(cmdresult == 0) && mStopOnError)
                    {
                        throw new Exception(
                                  "Replication didn't finished properly: Branch" +
                                  branch.Name);
                    }
                }
                catch (Exception e)
                {
                    mLog.ErrorFormat("Failed to replicate branch {0}. {1}{2} " +
                                     "at {3}",
                                     branch.Name, e.Message,
                                     Environment.NewLine, e.StackTrace);

                    if (mStopOnError)
                    {
                        throw e;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }