Example #1
0
        //-------------------------------------------------------------------------------------------
        public static int GetChangelist(string description)
        {
            string directory = System.IO.Directory.GetCurrentDirectory();
            string client    = Perforce.GetCurrentClient();
            string filename;
            string command;

            if (Application.platform == UnityEngine.RuntimePlatform.OSXEditor || Application.platform == UnityEngine.RuntimePlatform.OSXPlayer)
            {
                filename = "/bin/bash";
                command  = "-c \"p4 changes -c " + client + " -s pending | grep '" + description + "'\"";
            }
            else
            {
                filename = "cmd.exe";
                command  = "/C p4 changes -c " + client + " -s pending | findstr /R \"" + description + "\"";
            }
            var    res    = Perforce.ShellCommand(directory, command, filename, true);
            string change = res.stdout;

            if (change.Length == 0)
            {
                return(-1);
            }

            return(System.Convert.ToInt32(res.stdout.Split(' ')[1]));
        }
Example #2
0
        //-------------------------------------------------------------------------------------------
        public static void P4AddDirectory(string dirPath, int changelist = -1)
        {
            string path = dirPath;

            if (!System.IO.Directory.Exists(path))
            {
                return;
            }

            if (!path.EndsWith("/"))
            {
                path += "/";
            }
            string filename;
            string command;

            if (Application.platform == UnityEngine.RuntimePlatform.OSXEditor || Application.platform == UnityEngine.RuntimePlatform.OSXPlayer)
            {
                filename = "/bin/bash";

                if (changelist == -1)
                {
                    command = "-c \"find . -type f -print | p4 -x - add\"";
                }
                else
                {
                    command = "-c \"find . -type f -print | p4 -x - add -c " + changelist + "\"";
                }
            }
            else
            {
                filename = "cmd.exe";

                if (changelist == -1)
                {
                    command = "/C dir * /B /S | p4 -x - add";
                }
                else
                {
                    command = "/C dir * /B /S | p4 -x - add -c " + changelist;
                }
            }
            Perforce.ShellCommand(path, command, filename, false);
        }
Example #3
0
        //-------------------------------------------------------------------------------------------
        public static string GetCurrentClient()
        {
            string directory = System.IO.Directory.GetCurrentDirectory();
            string filename;
            string command;

            if (Application.platform == UnityEngine.RuntimePlatform.OSXEditor || Application.platform == UnityEngine.RuntimePlatform.OSXPlayer)
            {
                filename = "/bin/bash";
                command  = "-c \"p4 client -o | grep '^Client:'\"";
            }
            else
            {
                filename = "cmd.exe";
                command  = "/C p4 change -o | findstr /R /B \"Client\"";
            }
            var res = Perforce.ShellCommand(directory, command, filename, true);

            return(res.stdout.Split('\t')[1].Trim());
        }
Example #4
0
        //-------------------------------------------------------------------------------------------
        public static int CreateChangelist(string description)
        {
            string directory = System.IO.Directory.GetCurrentDirectory();
            string filename;
            string command;

            if (Application.platform == UnityEngine.RuntimePlatform.OSXEditor || Application.platform == UnityEngine.RuntimePlatform.OSXPlayer)
            {
                filename = "/bin/bash";
                command  = "-c \"(p4 change -o | grep '^\\(Change\\|Client\\|User\\|Description\\)'; echo ' " + description + "') | p4 change -i\"";
            }
            else
            {
                filename = "cmd.exe";
                command  = "/C p4 change -o | findstr /R /B \"Change Client User Description\" > p4.txt & echo     " + description + " >> p4.txt & type p4.txt | p4 change -i";
            }
            var res = Perforce.ShellCommand(directory, command, filename, true);

            //parse out the CL number from "Change 12345 created ..."
            return(System.Convert.ToInt32(res.stdout.Split(' ')[1]));
        }