void ExecuteInner(string Dir, int PR) { string PRNum = PR.ToString(); // Discard any old changes we may have committed RunGit("reset --hard"); // show-ref is just a double check that the PR exists //var Refs = RunGit("show-ref"); /*if (!Refs.Contains("refs/remotes/origin/pr/" + PRNum)) * { * throw new AutomationException("This is not among the refs: refs/remotes/origin/pr/{0}", PRNum); * }*/ RunGit(String.Format("fetch origin refs/pull/{0}/head:pr/{1}", PRNum, PRNum)); RunGit(String.Format("checkout pr/{0} --", PRNum)); int CLBase; string DepotBase; ScanForBranchAndCL_BaseVersion(String.Format("log --author=TimSweeney --author=UnrealBot -100 pr/{0} --", PRNum), out DepotBase, out CLBase); int CLLive; string DepotLive; ScanForBranchAndCL_LiveVersion(String.Format("log -100 pr/{0} --", PRNum), out DepotLive, out CLLive); if (CLLive == 0 && CLBase == 0) { throw new AutomationException("Could not find a base change and branch using either method."); } int CL = 0; string Depot = ""; if (CLBase > CLLive) { CL = CLBase; Depot = DepotBase; } else { CL = CLLive; Depot = DepotLive; } if (CL < 2000000 || String.IsNullOrWhiteSpace(Depot)) { throw new AutomationException("Could not find a base change and branch using either method."); } P4ClientInfo NewClient = P4.GetClientInfo(P4Env.Client); foreach (var p in NewClient.View) { LogInformation("{0} = {1}", p.Key, p.Value); } string TestClient = P4Env.User + "_" + Environment.MachineName + "_PullRequests_" + Depot.Replace("/", "_"); NewClient.Owner = P4Env.User; NewClient.Host = Environment.MachineName; NewClient.RootPath = Dir; NewClient.Name = TestClient; NewClient.View = new List <KeyValuePair <string, string> >(); NewClient.View.Add(new KeyValuePair <string, string>(Depot + "/...", "/...")); NewClient.Stream = null; if (!P4.DoesClientExist(TestClient)) { P4.CreateClient(NewClient); } var P4Sub = new P4Connection(P4Env.User, TestClient, P4Env.ServerAndPort); P4Sub.Sync(String.Format("-f -k -q {0}/...@{1}", Depot, CL)); var Change = P4Sub.CreateChange(null, String.Format("GitHub pull request #{0}", PRNum)); P4Sub.ReconcileNoDeletes(Change, CommandUtils.MakePathSafeToUseWithCommandLine(CombinePaths(Dir, bDoingUT ? "UnrealTournament" : "Engine", "..."))); P4Sub.Shelve(Change); P4Sub.Revert(Change, "-k //..."); }