5.1 - Perforce Integration - Shows ignored files in Content Folders

We ran into similar issue with “Submit Content” dialog showing ignored assets, this is a potential fix you can try if you are building from source.

This part is in Engine\Plugins\Developer\PerforceSourceControl\Source\PerforceSourceControl\Private\PerforceSourceControlOperations.cpp,
in function FPerforceUpdateStatusWorker::Execute(), around line 1950.
Top portion is to help find place in code, added code starts at comment // BEGIN_ADDED_CODE

FP4RecordSet Records;
InCommand.bCommandSuccessful &= Connection.RunCommand(TEXT("fstat"), Parameters, Records, InCommand.ResultInfo, FOnIsCancelled::CreateRaw(&InCommand, &FPerforceSourceControlCommand::IsCanceled), InCommand.bConnectionDropped);
ParseUpdateStatusResults(Records, InCommand.ResultInfo.ErrorMessages, OutStates, ContentRoot, BranchModifications);
RemoveRedundantErrors(InCommand, TEXT(" - no such file(s)."), false);
RemoveRedundantErrors(InCommand, TEXT("' is not under client's root '"));
RemoveRedundantErrors(InCommand, TEXT(" - protected namespace - access denied"), false);


// BEGIN_ADDED_CODE
// 
// Currently Perforce integration has an enum value "EPerforceState::Ignored", but nothing is setting it.
// We will try checking which ones are ignored for files that's not in depot yet.
TArray<FString> LocalOnlyFilesToCheck;
TMap<FString, FPerforceSourceControlState*> LocalFileToControlStates;
for (FPerforceSourceControlState& State : OutStates)
{
	// ignore recursive directories that ends with "..."
	if (State.GetState() == EPerforceState::NotInDepot
		&& !State.LocalFilename.EndsWith(TEXT("...")))
	{
		LocalOnlyFilesToCheck.Add(State.LocalFilename);
		LocalFileToControlStates.Add(State.LocalFilename, &State);
	}
}

if (LocalOnlyFilesToCheck.Num() > 0)
{
	// p4's C++ integration doesn't have "p4 ignores -i files..." command, 
	// we will use "p4 add -n files...", where -n option is used as a way to preview whether file can be added or not.
	TArray<FString> IgnoreParams;
	IgnoreParams.Add(TEXT("-n"));
	IgnoreParams.Append(LocalOnlyFilesToCheck);

	FP4RecordSet IgnoreRecords;
	FSourceControlResultInfo IgnoreResultInfo;
	Connection.RunCommand(TEXT("add"), IgnoreParams, IgnoreRecords, IgnoreResultInfo, FOnIsCancelled::CreateRaw(&InCommand, &FPerforceSourceControlCommand::IsCanceled), InCommand.bConnectionDropped);				

	// Note using same way Unreal's code is checking for status by command result messages, 
	// won't work if message is localized but that will be true for the whole integration.
	// Not sure if this works if number of files is very large, it not can try batches.
	const FString IgnoredFileMessage = TEXT(" - ignored file");
	for (const FText& MessageText : IgnoreResultInfo.InfoMessages)
	{
		const FString& MessageString = MessageText.ToString();
		if (MessageString.Contains(IgnoredFileMessage))
		{
			int32 IgnoreStartIndex = MessageString.Find(IgnoredFileMessage);
			FString FileName = MessageString.Mid(0, IgnoreStartIndex);

			// output uses \\ instead of /, replace those to match original inputs
			FileName = FileName.Replace(TEXT("\\"), TEXT("/"));

			if (LocalFileToControlStates.Contains(FileName))
			{
				LocalFileToControlStates[FileName]->SetState(EPerforceState::Ignore);
			}
		}
	}
}
// END_ADDED_CODE
1 Like