Ejemplo n.º 1
0
        //-------------------------------------------------------------------------------------------
        public static P4Result P4Checkout(string filePath, int changelist = -1)
        {
            if (System.IO.Directory.Exists(filePath))
            {
                P4CheckoutDirectory(filePath, changelist);
                return(null);
            }
            else
            {
                char separtor = System.IO.Path.DirectorySeparatorChar;
                if (!filePath.Contains(separtor.ToString()))
                {
                    separtor = System.IO.Path.AltDirectorySeparatorChar;
                }

                int    lastSlashIndex = filePath.LastIndexOf(separtor) + 1;
                string directory      = filePath.Substring(0, lastSlashIndex);
                string fileName       = filePath.Substring(lastSlashIndex, filePath.Length - lastSlashIndex);

                if (changelist == -1)
                {
                    return(Perforce.P4Command(directory, "edit " + fileName));
                }
                else
                {
                    Perforce.P4Command(directory, "edit -c " + changelist + " " + fileName);
                    return(Perforce.P4Command(directory, "reopen -c " + changelist + " " + fileName));
                }
            }
        }
Ejemplo n.º 2
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]));
        }
Ejemplo n.º 3
0
 //---------------------------------------------------------------------------------
 public static P4Result P4RevertUnchanged(int changelist = -1)
 {
     if (changelist == -1)
     {
         return(Perforce.P4Command(Application.dataPath, "revert -a", false));
     }
     else
     {
         return(Perforce.P4Command(Application.dataPath, "revert -a -c " + changelist, false));
     }
 }
Ejemplo n.º 4
0
 //-------------------------------------------------------------------------------------------
 public static P4Result P4Checkout(string workingDirectory, string filename, int changelist = -1)
 {
     if (changelist == -1)
     {
         return(Perforce.P4Command(workingDirectory, "edit " + filename));
     }
     else
     {
         Perforce.P4Command(workingDirectory, "edit -c " + changelist + " " + filename);
         return(Perforce.P4Command(workingDirectory, "reopen -c " + changelist + " " + filename));
     }
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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());
        }
Ejemplo n.º 7
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]));
        }
Ejemplo n.º 8
0
        //-------------------------------------------------------------------------------------------
        public static P4Result P4Add(string filePath, int changelist = -1)
        {
            char separtor = System.IO.Path.DirectorySeparatorChar;

            if (!filePath.Contains(separtor.ToString()))
            {
                separtor = System.IO.Path.AltDirectorySeparatorChar;
            }

            int    lastSlashIndex = filePath.LastIndexOf(separtor) + 1;
            string directory      = filePath.Substring(0, lastSlashIndex);
            string fileName       = filePath.Substring(lastSlashIndex, filePath.Length - lastSlashIndex);

            if (changelist == -1)
            {
                return(Perforce.P4Command(directory, "add -f " + fileName));
            }
            else
            {
                return(Perforce.P4Command(directory, "add -c " + changelist + " -f " + fileName));
            }
        }
Ejemplo n.º 9
0
        //-------------------------------------------------------------------------------------------
        public static void P4CheckoutDirectory(string dirPath, int changelist = -1)
        {
            string path = dirPath;

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

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

            if (changelist == -1)
            {
                Perforce.P4Command(path, "edit " + path + "...");
            }
            else
            {
                Perforce.P4Command(path, "edit -c " + changelist + " " + path + "...", false);
                Perforce.P4Command(path, "reopen -c " + changelist + " " + path + "...", false);                 //reopen so that any already open files are moved there
            }
        }