[Help("Syncs a clean clientspec (should NOT be the client you are running this out of), and mirrors it into another p4 server via 3 streams. See the SyncPerforceServers.cs for details")]
[Help("SourceClient=<client>", "p4 client on the source server (which is the active server that normal UAT p4 scripts would use")]
[Help("Server=<server:port>", "p4 server for the target (in the format server:port). There needs to be a client mapped to same directory as SourceClient is mapped to")]
[Help("User=<user>", "(optional) p4 username on the target server")]
[Help("SyncList=<fileset+fileset+...>", "(optional) a + separated list of p4 file paths to sync when getting latest from source stream (//Server/UE5/Engine/...+//Server/UE5/Templates/...")]
[Help("SyncListFile=<path>", "(optional) a text file that contains a list of p4 paths to sync, one per line. It can contain - prefixed lines to remove subpaths from being copied to target server")]
[Help("Submit", "REQUIRED for this script to work (it's actually processed by different code, so it must be specified)")]
[Help("HideSpew", "If specified, this command will not list the file outputs in each command")]
[Help("SkipSync", "If specified, the sync from SourceClient will not be preformed")]
[Help("SkipReconcile", "If specified, the reconcile into the target server's incoming stream will not be performed")]
[Help("SkipMergeToStaging", "If specified, the merge from Incoming and Main streams into the Staging stream will not be performed")]
[Help("SkipCopyToMain", "If specified, the final copy from Staging to Main will not be performed")]
Logger.LogError("Submitting is not allowed, which is required for this script. Run again with -submit, which is currently the only way to allow submitting via P4.");
return;
}
#regionSourcesetup
// get source client info
Logger.LogInformation($"Looking up client {SourceClientName} for user {P4Env.User}...");
thrownewAutomationException("You are running this from a UAT compiled in your clean directory! That means you have a non-clean directory to work from. You need to use another stream's UAT instance");
}
#endregion
#regionIncomingclientsetup
Logger.LogInformation($"Looking for an incoming client mapped to '{CleanDir}' on target server '{Server}'...");
// find an incoming client on target server that maps to the clean directory we will sync to
thrownewAutomationException($"Unable to find an incoming client on target server that is mapped to {CleanDir}");
}
if(IncomingClients.Length>1)
{
thrownewAutomationException($"Multiple clients are mapped to '{CleanDir}' on the target server, unable to determine the client to use. [{string.Join(",", IncomingClients.Select(x => x.Name))}");
Logger.LogInformation($"Files to skip (technically, it will sync then 'remove from workspace'):");
foreach(stringRevertinReverts)
{
Logger.LogInformation($" {Revert}");
}
}
}
Logger.LogInformation("");
if(!bSkipMergeToStaging)
{
Logger.LogInformation($"NOTE: The MERGE from {IncomingStreamName} to {StagingStreamName} is expected/likely to require manual resolving. This script will pause if needed, allowing you to resolve in p4v manually.");
}
Logger.LogInformation($"If everything looks good, press Enter to start! (Or Control-C to cancel)");
// tell the incoming workspace that what is on disc is up to date - this is a lie if other people are also mirroring servers, because someone else may have updated this stream
// without this clientspec knowing - however, because the sync from the source server (done above) is ground truth, we don't need to actually pull anything down. reconciling
// will fail, however, if this client is out of date
Logger.LogInformation($"Syncrhonizing server state...");
intCL=P4IncomingClient.CreateChange(Description:$"Reconciling changes on target incoming stream from {P4Env.ServerAndPort} / {SourceClient.Stream} to {Server} / {IncomingStreamName}");
Logger.LogError($"Failed to resolve the merge from {MainStreamName} to {StagingStreamName}. This is unexpected, and indicates that the staging directory was dirtied outside of this process. Resolve everything in changelist {CL}, then press enter to continue. \nIf you kill this script, you can run this script again with \"-skipsync-skipreconcile\".");
Console.ReadLine();
}
// Nothing should have gone into Staging since the last time we did this, so this _should_ not fail, but if it does, alert the user and have them try again
try
{
P4StagingClient.Submit(CL);
}
catch(P4Exception)
{
Logger.LogError($"Submit of changelist {CL} failed for unknown reason. Submit manually, then press enter to continue. \nIf you kill this script, you can run this script again with \"-skipsync-skipreconcile\" to get to this step faster.");
Logger.LogError($"Manual resolves are needed when merging {IncomingStreamName} to {StagingStreamName}. This is expected. Resolve changelist {CL}, then press enter to continue. \nIf you kill this script, you can run this script again with \"-skipsync-skipreconcile\" to get to this step faster.");
Console.ReadLine();
}
try
{
P4StagingClient.Submit(CL);
}
catch(P4Exception)
{
Logger.LogError($"Submit of changelist {CL} failed for unknown reason. Submit manually, then press enter to continue. \nIf you kill this script, you can run this script again with \"-skipsync-skipreconcile\" to get to this step faster.");
Logger.LogError($"Submit of changelist {CL} failed for unknown reason. Submit manually, then press enter to continue. \nIf you kill this script, you can run this script again with \"-skipsync-skipreconcile-skipmergetostaging\" to get to this step faster.");