Files
UnrealEngineUWP/Engine/Source/Developer/SourceControl/Public/SourceControlResultInfo.h
paul chipchase 82618a9ffd Capture info messages for all perforce commands, the calling code can then decide if the info is important or not.
#rb juan.legaz
#jira UE-175581

### Perforce Connection
- FP4ClientUser now takes a FSourceControlResultInfo structure to store the warning/error messages generated during a perforce command, in addition we can now store info messages.
-- In almost all cases the array that was being passed in to store the warning/error messages came from a FSourceControlResultInfo so it doesn't change the overall flow.
- Rather than override ClientUser::OutputInfo to get the info messages we have overridden FP4ClientUser::Message instead as this is the preferred way in the cpp p4 api to capturing messages.
-- One difference between ::Message and the older capturing methods is that the older methods seemed to result in a newline character at the end of the message, which we do not see with the newer capture method. As some of our result parsing code relies on this behavior FP4ClientUser::Message will append this newline character for now until the parsing code can be fixed.
- For now FP4ClientUser still overrides ::OutputInfo, ::OutputError and ::HandleError but only to add a checkNoEntry() to each one. This is so that we can confirm that there are no remaining uses of it before removing it entirely.
- All classes derived from FP4ClientUser have been updated to work with the changes. In some cases this meant changing the override of ClientUser::OutputInfo to ClientUser::Message.
-- With a little bit of work we could probably remove these derived classes now that FP4ClientUser supports capturing the info messages which would help simplify the code base however this should be done in a future work item.

### Misc
- Remove ::FPerforceSourceControlProvider::GetWorkspaceList rather than update it, as it is not used.
- Add FSourceControlResultInfo::HasErrors to check if the struct contains errors or not.
-- Did not replace existing use of FPerforceSourceControlProvider::ErrorMessages.IsEmpty() that should be done as it's own work item.

[CL 30208418 by paul chipchase in ue5-main branch]
2023-12-08 06:47:37 -05:00

60 lines
1.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Containers/Array.h"
#include "Containers/UnrealString.h"
#include "CoreTypes.h"
#include "Internationalization/Text.h"
#include "Misc/EnumClassFlags.h"
/** Accumulated error and info messages for a source control operation. */
struct FSourceControlResultInfo
{
enum class EAdditionalErrorContext : uint32
{
None = 0,
/** A connection to the server could not be established */
ConnectionFailed = 1 << 0,
/** The connection to the server dropped before the operation could be completed */
ConnectionDropped = 1 << 1
};
FRIEND_ENUM_CLASS_FLAGS(EAdditionalErrorContext);
/** Append any messages from another FSourceControlResultInfo, ensuring to keep any already accumulated info. */
void Append(const FSourceControlResultInfo& InResultInfo)
{
InfoMessages.Append(InResultInfo.InfoMessages);
ErrorMessages.Append(InResultInfo.ErrorMessages);
Tags.Append(InResultInfo.Tags);
AdditionalErrorContext |= InResultInfo.AdditionalErrorContext;
}
SOURCECONTROL_API void OnConnectionFailed();
SOURCECONTROL_API void OnConnectionDroped();
SOURCECONTROL_API bool DidConnectionFail() const;
bool HasErrors() const
{
return !ErrorMessages.IsEmpty();
}
/** Info and/or warning message storage */
TArray<FText> InfoMessages;
/** Potential error message storage */
TArray<FText> ErrorMessages;
/** Additional arbitrary information attached to the command */
TArray<FString> Tags;
private:
/** Contains additional info about any errors encountered */
EAdditionalErrorContext AdditionalErrorContext = EAdditionalErrorContext::None;
};
ENUM_CLASS_FLAGS(FSourceControlResultInfo::EAdditionalErrorContext);