Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance issue with the diff of assets #77

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "PlasticSourceControlRevision.h"
#include "PlasticSourceControlModule.h"
#include "PlasticSourceControlProvider.h"
#include "PlasticSourceControlState.h"
#include "PlasticSourceControlUtils.h"
#include "SPlasticSourceControlSettings.h"
Expand Down Expand Up @@ -52,8 +51,6 @@ bool FPlasticSourceControlRevision::Get(FString& InOutFilename, EConcurrency::Ty
}
else if (State)
{
const FString& PathToPlasticBinary = FPlasticSourceControlModule::Get().GetProvider().AccessSettings().GetBinaryPath();

FString RevisionSpecification;
if (ShelveId != ISourceControlState::INVALID_REVISION)
{
Expand All @@ -66,7 +63,7 @@ bool FPlasticSourceControlRevision::Get(FString& InOutFilename, EConcurrency::Ty
// Format the revision specification of the checked-in file, like rev:Content/BP.uasset#cs:12@repo@server:8087
RevisionSpecification = FString::Printf(TEXT("rev:%s#cs:%d@%s"), *Filename, ChangesetNumber, *State->RepSpec);
}
bCommandSuccessful = PlasticSourceControlUtils::RunDumpToFile(PathToPlasticBinary, RevisionSpecification, InOutFilename);
bCommandSuccessful = PlasticSourceControlUtils::RunGetFile(RevisionSpecification, InOutFilename);
}
else
{
Expand Down
27 changes: 8 additions & 19 deletions Source/PlasticSourceControl/Private/PlasticSourceControlUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "PlasticSourceControlVersions.h"
#include "ISourceControlModule.h"

#include "HAL/PlatformProcess.h"
#include "Misc/FileHelper.h"
#include "Misc/Paths.h"
#include "XmlParser.h"
Expand Down Expand Up @@ -1142,30 +1141,20 @@ bool RunUpdateStatus(const TArray<FString>& InFiles, const EStatusSearchType InS
return bResults;
}

// Run a Plastic "cat" command to dump the binary content of a revision into a file.
// cm cat revid:1230@rep:myrep@repserver:myserver:8084 --raw --file=Name124.tmp
bool RunDumpToFile(const FString& InPathToPlasticBinary, const FString& InRevSpec, const FString& InDumpFileName)
// Run a "getfile" command to dump the binary content of a revision into a file.
bool RunGetFile(const FString& InRevSpec, const FString& InDumpFileName)
{
TRACE_CPUPROFILER_EVENT_SCOPE(PlasticSourceControlUtils::RunDumpToFile);
TRACE_CPUPROFILER_EVENT_SCOPE(PlasticSourceControlUtils::RunGetFile);

int32 ReturnCode = 0;
FString Results;
FString Errors;

// start with the Plastic command itself, then add revspec and temp filename to dump
FString FullCommand = TEXT("cat \"");
FullCommand += InRevSpec;
FullCommand += TEXT("\" --raw --file=\"");
FullCommand += InDumpFileName;
FullCommand += TEXT("\"");

UE_LOG(LogSourceControl, Verbose, TEXT("RunDumpToFile: '%s %s'"), *InPathToPlasticBinary, *FullCommand);
const bool bResult = FPlatformProcess::ExecProcess(*InPathToPlasticBinary, *FullCommand, &ReturnCode, &Results, &Errors);
UE_LOG(LogSourceControl, Log, TEXT("RunDumpToFile: ExecProcess ReturnCode=%d Results='%s'"), ReturnCode, *Results);
if (!bResult || !Errors.IsEmpty())
{
UE_LOG(LogSourceControl, Error, TEXT("RunDumpToFile: ExecProcess ReturnCode=%d Errors='%s'"), ReturnCode, *Errors);
}
TArray<FString> Parameters;
Parameters.Add(InRevSpec);
Parameters.Add(TEXT("--raw"));
Parameters.Add(FString::Printf(TEXT("--file=\"%s\""), *InDumpFileName));
const bool bResult = PlasticSourceControlUtils::RunCommand(TEXT("getfile"), Parameters, TArray<FString>(), Results, Errors);

return bResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,11 @@ bool RunUpdateStatus(const TArray<FString>& InFiles, const EStatusSearchType InS
/**
* Run a Plastic "cat" command to dump the binary content of a revision into a file.
*
* @param InPathToPlasticBinary The path to the Plastic binary
* @param InRevSpec The revision specification to get
* @param InDumpFileName The temporary file to dump the revision
* @returns true if the command succeeded and returned no errors
*/
bool RunDumpToFile(const FString& InPathToPlasticBinary, const FString& InRevSpec, const FString& InDumpFileName);
bool RunGetFile(const FString& InRevSpec, const FString& InDumpFileName);

/**
* Run Plastic "history" and "log" commands and parse their XML results.
Expand Down