Ejemplo n.º 1
0
    public bool revertFileInChangelist(string filepath, P4PendingChangelist list)
    {
        string[]    args   = new string[] { "-c", list.Number.ToString(), filepath };
        P4RecordSet setRes = RunCmd("revert", args); // "-c", cl.Number.ToString(), "//depot/path/foo.cs", "//depot/path/bar.cs");

        return(true);
    }
Ejemplo n.º 2
0
        public int Integrate(ArrayList files)
        {
            P4RecordSet record;
            P4RecordSet resolve;


            P4PendingChangelist integrateChangelist = p4.CreatePendingChangelist("PublishIt! changelsit");

            String tmp = "";

            String[] intArgs = { "-c", integrateChangelist.Number.ToString(), "-d", "-i", "-t", "-v", "-b", "phx_published", "" };
            String[] resArgs = { "-at", "" };

            foreach (String file in files)
            {
                tmp        = file.Replace("\\depot\\phoenix\\xbox\\work", "//depot/phoenix/xbox/published");
                intArgs[8] = tmp.Replace("\\", "/");
                record     = Run("integrate", intArgs);

                resArgs[1] = tmp.Replace("\\", "/");
                resolve    = Run("resolve", resArgs);
            }

            String[] subArgs = { "-c", "" };
            subArgs[1] = integrateChangelist.Number.ToString();
            Run("submit", subArgs);

            return(integrateChangelist.Number);
        }
Ejemplo n.º 3
0
 public void submitChangelist(P4PendingChangelist list)
 {
     try
     {
         list.Submit();
     }catch (Exception e)
     {
     }
 }
Ejemplo n.º 4
0
 public override void P4Execute()
 {
     try
     {
         P4PendingChangelist cl = _p4.CreatePendingChangelist(_description);
         _clNumber = cl.Number.ToString();
     }
     catch (Exception e)
     {
         Log.LogError(e.Message);
     }
 }
Ejemplo n.º 5
0
        public void Test003_AddFiles()
        {
            p4.Disconnect();
            p4.Charset = "utf16le-bom";
            p4.Connect();

            string testPath = Path.Combine(p4ClientRootDirectory, "TestUnicode");

            //Create some test files
            Directory.CreateDirectory(testPath);

            P4PendingChangelist cl = p4.CreatePendingChangelist("TestUnicode");

            string[] args = new string[13];
            args[0] = "-c";
            args[1] = cl.Number.ToString();
            args[2] = "-tunicode";

            for (int i = 0; i < 10; i++)
            {
                string       fn       = string.Format("File{0}", i);
                string       contents = string.Format("this is file: {0}\nEn español.\nΚαλημέρα κόσμε\nこんにちは 世界", i);
                StreamWriter sw       = new StreamWriter(Path.Combine(testPath, fn), false, System.Text.Encoding.Unicode);
                sw.Write(contents);
                sw.Close();

                args[i + 3] = Path.Combine(testPath, fn);
            }
            P4UnParsedRecordSet r = p4.RunUnParsed("add", args);

            Assert.AreEqual(r.Messages.Length, 10, "Invalid response from p4 add");
            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(string.Format("//depot/TestUnicode/File{0}#1 - opened for add", i), r.Messages[i], "Invalid response from p4 add");
            }

            r = cl.Submit();
            Assert.AreEqual("Submitting change 8.", r.Messages[0], "Unexpected output from p4 submit");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Add a fileName to Perforce then submit it.
        /// Used for testing
        /// </summary>
        /// <param name="vsFileName">The file name to add then submit.</param>
        /// <param name="message">The first line of the P4 command result if no error, else the error message.</param>
        /// <returns>false if error (see message)</returns>
        public bool AddAndSubmitFile(string vsFileName, out string message)
        {
            // Need to do this for unit testing, or we get NullReferenceException in P4API
            Connect();
            Disconnect();

            P4PendingChangelist cl = null;

            try
            {
                cl = _p4.CreatePendingChangelist("A testing changelist");
            }
            catch (NullReferenceException ex)
            {
                Trace.WriteLine(String.Format("P4Service.AddAndSubmitFile: {0}", ex.Message));
            }

            P4RecordSet recordSet;
            string      p4FileName = GetP4FileName(vsFileName);
            bool        result     = SendCommand("add", out message, out recordSet, "-c", cl.Number.ToString(), p4FileName);

            if (!result)
            {
                return(false);
            }

            P4UnParsedRecordSet unparsedRecordset = null;

            try
            {
                unparsedRecordset = cl.Submit();
            }
            catch (P4API.Exceptions.RunUnParsedException ex)
            {
                message = HandleRunUnParsedExceptionError(ex);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 7
0
 public void addFileToChangelist(string filepath, P4PendingChangelist list)
 {
     string[] args = new string[] { "-c", list.Number.ToString(), filepath };
     RunCmd("add", args); // "-c", cl.Number.ToString(), "//depot/path/foo.cs", "//depot/path/bar.cs");
 }
Ejemplo n.º 8
0
        private static void generateFileListsinternal(object objin)
        {
            List <string> scenariosToProcess = objin as List <string>;

            //if we had some problem launching XFS, die out
            if (!XFSInterface.launchApp())
            {
                return;
            }


            //perforce connections
            P4Interface         perforce = new P4Interface();
            P4PendingChangelist cl       = perforce.createChangeList("openFileLists for archive reordering");


            //wait a bit after game launch to ensure that the game is loaded
            XFSInterface.launchGame();
            System.Threading.Thread.Sleep(10000);



            for (int i = 0; i < scenariosToProcess.Count; i++)
            {
                //Has the user pressed 'cancel' ?
                if (mIsWorking == false)
                {
                    sendStatusMsg("User stopped work");
                    break;
                }

                string launchString      = scenariosToProcess[i].Substring(0, scenariosToProcess[i].LastIndexOf(@"."));
                string scenariodir       = gameDirectory + @"\scenario\" + scenariosToProcess[i].Substring(0, scenariosToProcess[i].LastIndexOf(@"\"));
                string fileOpenLogStr    = scenariodir + @"\FileopenLog.txt";
                bool   addFileToPerforce = true;

                sendStatusMsg("Processing " + scenariosToProcess[i]);

                //there's a bit of logic here that we have to do.
                //considering there's like 800 states that a file can be in wrt perforce...
                if (File.Exists(fileOpenLogStr))
                {
                    P4FileStatus fstat = perforce.getFileStatus(fileOpenLogStr);

                    //is the file checked into perforce?
                    if (!fstat.IsFileInPerforce)
                    {
                        addFileToPerforce = true;
                    }
                    else
                    {
                        addFileToPerforce = false;

                        if (!fstat.IsFileCheckedOutByMe)
                        {
                            //checkout the file
                            //NOTE .txt isn't exclusive, so we don't care if someone else has it checked out.
                            perforce.checkoutFileToChangelist(fileOpenLogStr, cl);
                            sendStatusMsg("..Checking out " + fileOpenLogStr);
                        }
                    }

                    //this is a local delete so we can use the MOVE command;
                    try
                    {
                        File.Delete(fileOpenLogStr);
                    }
                    catch (System.Exception e)
                    {
                        sendStatusMsg("..Error Deleting " + fileOpenLogStr);
                        sendStatusMsg("..Skipping File " + fileOpenLogStr);
                        continue;
                    }
                }


                //do this a couple times to esnure it's actualy being done!
                for (int k = 0; k < 3; k++)
                {
                    XFSInterface.clearOpenFileList();
                    System.Threading.Thread.Sleep(100);
                }

                const int cNumSecondsToWait = 45;
                sendStatusMsg("..Launching " + launchString);
                XFSInterface.launchScenario(launchString);
                System.Threading.Thread.Sleep(cNumSecondsToWait * 1000);

                XFSInterface.safeOpenFileList();
                System.Threading.Thread.Sleep(10000);


                //move the file from work to the directory
                do
                {
                    try
                    {
                        File.Move(gameDirectory + @"\FileopenLog.txt", fileOpenLogStr);
                        break;
                    }
                    catch (System.Exception e)
                    {
                    }
                } while (true);


                //check file back into perforce here.
                if (addFileToPerforce)
                {
                    perforce.addFileToChangelist(fileOpenLogStr, cl);
                    sendStatusMsg("..Adding " + fileOpenLogStr);
                }

                //update our status message on the main form
                sendStatusMsg("..Finished " + scenariosToProcess[i]);

                System.Threading.Thread.Sleep(5000);
            }

            perforce.submitChangelist(cl);
            sendStatusMsg("..Changelist " + cl.Number + " submitted");
            perforce.Disconnect();

            mIsWorking = false;
            sendStatusMsg("!DONE");
        }