public void SubmitOptionsNoneTest() { bool unicode = false; string uri = "localhost:6666"; string user = "******"; string pass = string.Empty; string ws_client = "admin_space"; for (int i = 0; i < 1; i++) // run once for ascii, once for unicode { Process p4d = Utilities.DeployP4TestServer(TestDir, 6, unicode); Server server = new Server(new ServerAddress(uri)); try { Repository rep = new Repository(server); using (Connection con = rep.Connection) { con.UserName = user; con.Client = new Client(); con.Client.Name = ws_client; Assert.AreEqual(con.Status, ConnectionStatus.Disconnected); Assert.AreEqual(con.Server.State, ServerState.Unknown); Assert.IsTrue(con.Connect(null)); Assert.AreEqual(con.Server.State, ServerState.Online); Assert.AreEqual(con.Status, ConnectionStatus.Connected); Assert.AreEqual("admin", con.Client.OwnerName); Utilities.SetClientRoot(rep, TestDir, unicode, ws_client); Changelist change = new Changelist(5, true); change.initialize(con); SubmitCmdOptions submitOptions = new SubmitCmdOptions(Perforce.P4.SubmitFilesCmdFlags.None, 5, null, null, null); SubmitResults sr = change.Submit(submitOptions); FileSpec fs = FileSpec.DepotSpec("//depot/MyCode/NewFile.txt"); Options ops = new Options(); IList <FileMetaData> actual = rep.GetFileMetaData(ops, fs); FileAction expected = FileAction.None; Assert.AreEqual(expected, actual[0].Action); Assert.IsNotNull(sr); Assert.AreEqual(1, sr.Files.Count); } } finally { Utilities.RemoveTestServer(p4d, TestDir); } unicode = !unicode; } }
public void SubmitOptionsShelvedTest() { bool unicode = false; string uri = "localhost:6666"; string user = "******"; string pass = string.Empty; string ws_client = "admin_space"; for (int i = 0; i < 1; i++) // run once for ascii, once for unicode { Process p4d = Utilities.DeployP4TestServer(TestDir, 6, unicode); Server server = new Server(new ServerAddress(uri)); try { Repository rep = new Repository(server); using (Connection con = rep.Connection) { con.UserName = user; con.Client = new Client(); con.Client.Name = ws_client; Assert.AreEqual(con.Status, ConnectionStatus.Disconnected); Assert.AreEqual(con.Server.State, ServerState.Unknown); Assert.IsTrue(con.Connect(null)); Assert.AreEqual(con.Server.State, ServerState.Online); Assert.AreEqual(con.Status, ConnectionStatus.Connected); Assert.AreEqual("admin", con.Client.OwnerName); Utilities.SetClientRoot(rep, TestDir, unicode, ws_client); Changelist change = new Changelist(5, true); change.initialize(con); FileSpec fs = FileSpec.DepotSpec("//depot/MyCode/NewFile.txt"); ShelveFilesCmdOptions shelvedOptions = new ShelveFilesCmdOptions(ShelveFilesCmdFlags.None, null, 5); rep.Connection.Client.ShelveFiles(shelvedOptions, fs); rep.Connection.Client.RevertFiles(null, fs); SubmitResults sr = null; try { SubmitCmdOptions submitOptions = new SubmitCmdOptions(Perforce.P4.SubmitFilesCmdFlags.SubmitShelved, 5, null, null, null); sr = change.Submit(submitOptions); } catch (P4Exception e) { String msg = String.Format("Command '{0}' throws exception '{1}' \r\n StackTrace: {2}", e.CmdLine, e.Message, e.StackTrace); Assert.IsTrue(false, msg); } Assert.IsNotNull(sr); Assert.AreEqual(1, sr.Files.Count); } } finally { Utilities.RemoveTestServer(p4d, TestDir); } unicode = !unicode; } }
private void RunBuild(bool async) { DateTime buildTime = DateTime.Now; String buildId = buildTime.ToString("MMddyyHHmmss"); String buildFolder = buildTime.ToString("MM-dd-yy_HHmmss"); String buildPath = Path.Combine(mBuildFolderTxt.Text, buildFolder); int idx = 0; while ((Directory.Exists(buildPath)) && (idx < 26)) { buildPath = Path.Combine(mBuildFolderTxt.Text, buildTime.ToString("MM-dd-yy HHmmss") + ((char)((int)'a' + idx))); } if (idx >= 26) { return; } string logFile = Path.Combine(buildPath, "BuildLog.txt"); Directory.CreateDirectory(buildPath); String ConStr = mServerConnection.Text; String User = mUserText.Text; String Password = mPaswordTxt.Text; String Target = mSolutionPath.Text; Server pServer = new Server(new ServerAddress(ConStr)); rep = new Repository(pServer); Connection con = rep.Connection; con.Connect(null); log = new StreamWriter(logFile); Client buildClient = new Client(); buildClient.Name = "p4apinet_solution_builder_sample_application_client"; buildClient.OwnerName = con.UserName; buildClient.ViewMap = new ViewMap(); buildClient.Root = buildPath; buildClient.Options = ClientOption.AllWrite; buildClient.LineEnd = LineEnd.Local; buildClient.SubmitOptions = new ClientSubmitOptions(false, SubmitType.SubmitUnchanged); string depotPath = mSolutionPath.Text; IList <FileMetaData> fmd = null; try { fmd = rep.GetFileMetaData(null, FileSpec.DepotSpec(depotPath)); } catch {} if ((fmd == null) || (fmd.Count != 1)) { string message = string.Format("The solution file \"{0}\" does not exist in the depot.", depotPath); MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (mSolutionPath.Text.EndsWith(".sln")) { depotPath = mSolutionPath.Text.Substring(0, mSolutionPath.Text.LastIndexOf('/')); } string depotFolder = depotPath.Substring(depotPath.LastIndexOf('/') + 1); depotPath += "/..."; String clientPath = String.Format("//{0}/{1}/...", buildClient.Name, depotFolder); MapEntry entry = new MapEntry(MapType.Include, new DepotPath(depotPath), new ClientPath(clientPath)); buildClient.ViewMap.Add(entry); rep.CreateClient(buildClient); con.Client = rep.GetClient(buildClient.Name); string localPath = clientPath; localPath = localPath.TrimStart('/'); localPath = localPath.TrimEnd('.'); localPath = localPath.Substring(localPath.IndexOf('/') + 1); localPath = localPath.Replace('/', '\\'); string solutionName = Target.Substring(depotPath.LastIndexOf('/')); solutionName = solutionName.TrimStart('/'); localPath = Path.Combine(buildPath, localPath, solutionName); int lastChange = GetLastChange(); AsynchSetLastChange(lastChange); IList <Changelist> changes = GetChangesAfter(changeAtLastBuild, lastChange); changeAtLastBuild = lastChange; if (changes != null) { for (idx = 0; idx < changes.Count; idx++) { AsynchAddLineToLog(changes[idx].ToString(true)); } } if (async) { Thread buildThread = new Thread(new ParameterizedThreadStart(RunBuildProc)); buildThread.IsBackground = true; buildThread.Start(localPath); } else { RunBuildProc(localPath); } con.Disconnect(null); }