I have 2 branches in my depot.
//depot/project/mainline/...
//depot/project/staging/...
I am using an in-house tool that manages the build of the project, and would like to create a build step that automatically promotes all the files from mainline into staging. I have been trying to write it using p4.net API, following the following example. I am able to run powershell commands from the build tool. My plan was to write a c# console application, compile it using the tool, and then execute it as a build step. Unfortunately I am getting nowhere with that example. I am able to create a client, create a branch spec and even sync the files down, but I for the life of me cant figure out how to submit the integrate. I feel like I am trying to over-engineer a solution thought. This is something that should be easy to do. I am attaching my broken code below. If it dose not make sense, its because I am using trial and error to figure stuff out and didn't make a final pass through it yet. That said, if i don't need to use the p4 api, all the better. The only requirement is that there be no user input required to run the commands. If there is a merge conflict, I want to automatically accept the source.
Thanks
string uri = "server";
string user = "user";
string pass = null;
string ws_client = "Project-Temp-"+ Guid.NewGuid().ToString();
Server server = new Server(new ServerAddress(uri));
Repository rep = new Repository(server);
Connection con = rep.Connection;
con.UserName = user;
con.Client = new Client();
con.Client.Name = ws_client;
con.Client.ViewMap = new ViewMap();
con.Connect(null);
Credential cred = con.Login(pass, null, null);
rep.DeleteClient(con.Client, null);
rep.CreateClient(con.Client);
con.Client.ViewMap.Clear();
con.Client.ViewMap.Add("//depot/project/...", String.Format("//{0}/...", con.Client.Name), MapType.Include);
rep.UpdateClient(con.Client);
var files = con.Client.SyncFiles(new SyncFilesCmdOptions(SyncFilesCmdFlags.None, -1));
ViewMap vm = new ViewMap();
vm.Add(new MapEntry(MapType.Include,new ClientPath("//depot/project/mainline/..."), new ClientPath("//depot/project/staging/...")));
string msg = "Mainline to Staging";
BranchSpec bs = new BranchSpec("Project-Temp", user, DateTime.Now, DateTime.Now, msg, true, vm, null, null);
int change = -1;
IntegrateFilesCmdOptions BranchOptions = new IntegrateFilesCmdOptions(IntegrateFilesCmdFlags.None, change, -1, "Project-Temp", null, null);
rep.CreateBranchSpec(bs);
rep.UpdateClient(con.Client);
var integrated = con.Client.IntegrateFiles(BranchOptions);
con.Client.ResolveFiles(files, new ResolveCmdOptions(ResolveFilesCmdFlags.AutomaticYoursMode, change));
rep.DeleteClient(con.Client, null);