perforce - How to integrate 2 branches programatically -
i have 2 branches in depot.
//depot/project/mainline/... //depot/project/staging/...
i using in-house tool manages build of project, , create build step automatically promotes files mainline staging. have been trying write using p4.net api, following following example. able run powershell commands build tool. plan write c# console application, compile using tool, , execute build step. unfortunately getting example. able create client, create branch spec , sync files down, life of me cant figure out how submit integrate. feel trying over-engineer solution thought. should easy do. attaching broken code below. if dose not make sense, because using trial , error figure stuff out , didn't make final pass through yet. said, if don't need use p4 api, better. requirement there no user input required run commands. if there merge conflict, want automatically accept 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 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);
from command line is:
p4 integrate //depot/project/mainline/... //depot/project/staging/... p4 resolve -am p4 resolve -at p4 resolve -ay p4 submit -d "integrate."
the "resolve -am" automerges files without conflicts. "resolve -at" accepts source of remaining files. on off chance there source files can't accepted (e.g. source revisions have been obliterated, or source , target actions incompatible), "resolve -ay" ignores them.
Comments
Post a Comment