public void SubmitFile() { connected = con.Connect(null); if (connected) { try { // Submit the edit comment = tbComment.Text; myChange = p4.GetChangelist(myChange.Id); myChange.Description = comment; p4.UpdateChangelist(myChange); myChange.Submit(new Options()); EnableFileEdit(); Console.WriteLine("The file is submitted!"); } catch (P4Exception e) { MessageBox.Show("サブミットに失敗しました。\n" + "正常にチェックアウトされているファイルか確認してください。"); Console.WriteLine("Couldn't submit file!\n {0} : {1}", e.ErrorCode, e.Message); } } else { MessageBox.Show("ワークスペースに正しく接続できているか確認してください。"); } }
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 SubmitShelvedFromChangelist() { bool unicode = false; string uri = "localhost:6666"; string user = "******"; string pass = string.Empty; string ws_client = "admin_space"; for (int i = 0; i < 2; i++) // run once for ascii, once for unicode { Process p4d = Utilities.DeployP4TestServer(TestDir, 13, 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; bool connected = con.Connect(null); Assert.IsTrue(connected); Assert.AreEqual(con.Status, ConnectionStatus.Connected); Utilities.SetClientRoot(rep, TestDir, unicode, ws_client); Changelist change = new Changelist(5, true); change.initialize(con); // shelve the files in changelist 5 con.Client.ShelveFiles(new ShelveFilesCmdOptions(ShelveFilesCmdFlags.None, null, change.Id)); // revert the checked out file that was shelved FileSpec file = new FileSpec(new DepotPath("//..."), null, null, null); con.Client.RevertFiles(new RevertCmdOptions(RevertFilesCmdFlags.None, change.Id), file); // submit the shelved file SubmitCmdOptions submitOptions = new SubmitCmdOptions(Perforce.P4.SubmitFilesCmdFlags.SubmitShelved, 5, null, null, null); change.Submit(submitOptions); P4CommandResult last = rep.Connection.LastResults; Assert.IsTrue(last.Success); } } finally { Utilities.RemoveTestServer(p4d, TestDir); } unicode = !unicode; } }
public void SubmitTest() { 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); SubmitResults sr = change.Submit(null); 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; } }
public void GetChangelistWithUTCConversionTest() { bool unicode = false; string uri = "localhost:6666"; string user = "******"; string pass = string.Empty; string ws_client = "admin_space"; for (int i = 0; i < 2; 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; bool connected = con.Connect(null); Assert.IsTrue(connected); Assert.AreEqual(con.Status, ConnectionStatus.Connected); Utilities.SetClientRoot(rep, TestDir, unicode, ws_client); P4Command cmd = new P4Command(rep, "change", true, "5"); Options opts = new Options(); opts["-o"] = null; Changelist fromChangeCommand = new Changelist(); P4CommandResult results = cmd.Run(opts); if (results.Success) { fromChangeCommand.initialize(rep.Connection); fromChangeCommand.FromChangeCmdTaggedOutput((results.TaggedOutput[0]), server.Metadata.DateTimeOffset, FormBase.DSTMismatch(server.Metadata)); } SubmitResults sr = fromChangeCommand.Submit(null); int submitted = 17; if (unicode) { submitted = 13; } cmd = new P4Command(rep, "change", true, submitted.ToString()); opts = new Options(); opts["-o"] = null; fromChangeCommand = new Changelist(); results = cmd.Run(opts); if (results.Success) { fromChangeCommand.initialize(rep.Connection); fromChangeCommand.FromChangeCmdTaggedOutput((results.TaggedOutput[0]), server.Metadata.DateTimeOffset, FormBase.DSTMismatch(server.Metadata)); } Changelist fromDescribeCommand = rep.GetChangelist(submitted, null); Assert.AreEqual(fromDescribeCommand.ModifiedDate, fromChangeCommand.ModifiedDate); } } finally { Utilities.RemoveTestServer(p4d, TestDir); } unicode = !unicode; } }