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

List files changed in the selected changeset #117

Merged
merged 14 commits into from
May 7, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FPlasticSourceControlChangeset
FString Comment;
FString Branch;
// Note: array of file States, each with one Revision for Diffing (like for Files and ShelvedFiles in FPlasticSourceControlChangelist)
TArray<TSharedRef<class FPlasticSourceControlState, ESPMode::ThreadSafe>> Files;
TArray<FPlasticSourceControlStateRef> Files;

void PopulateSearchString(TArray<FString>& OutStrings) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void IPlasticSourceControlWorker::RegisterWorkers(FPlasticSourceControlProvider&
PlasticSourceControlProvider.RegisterWorker("RenameBranch", FGetPlasticSourceControlWorker::CreateStatic(&InstantiateWorker<FPlasticRenameBranchWorker>));
PlasticSourceControlProvider.RegisterWorker("DeleteBranches", FGetPlasticSourceControlWorker::CreateStatic(&InstantiateWorker<FPlasticDeleteBranchesWorker>));
PlasticSourceControlProvider.RegisterWorker("GetChangesets", FGetPlasticSourceControlWorker::CreateStatic(&InstantiateWorker<FPlasticGetChangesetsWorker>));
PlasticSourceControlProvider.RegisterWorker("GetChangesetFiles", FGetPlasticSourceControlWorker::CreateStatic(&InstantiateWorker<FPlasticGetChangesetFilesWorker>));
PlasticSourceControlProvider.RegisterWorker("MakeWorkspace", FGetPlasticSourceControlWorker::CreateStatic(&InstantiateWorker<FPlasticMakeWorkspaceWorker>));
PlasticSourceControlProvider.RegisterWorker("Sync", FGetPlasticSourceControlWorker::CreateStatic(&InstantiateWorker<FPlasticSyncWorker>));
PlasticSourceControlProvider.RegisterWorker("SyncAll", FGetPlasticSourceControlWorker::CreateStatic(&InstantiateWorker<FPlasticSyncWorker>));
Expand Down Expand Up @@ -241,6 +242,17 @@ FText FPlasticGetChangesets::GetInProgressString() const
return LOCTEXT("SourceControl_GetChangesets", "Getting the list of changesets...");
}

FName FPlasticGetChangesetFiles::GetName() const
{
return "GetChangesetFiles";
}

FText FPlasticGetChangesetFiles::GetInProgressString() const
{
return FText::Format(LOCTEXT("SourceControl_GetChangesetFiles", "Getting the list of files in changeset {0}..."), FText::AsNumber(Changeset->ChangesetId));
}


static bool AreAllFiles(const TArray<FString>& InFiles)
{
for (const FString& File : InFiles)
Expand Down Expand Up @@ -1396,6 +1408,41 @@ bool FPlasticGetChangesetsWorker::UpdateStates()
}



FName FPlasticGetChangesetFilesWorker::GetName() const
{
return "GetChangesetFiles";
}

bool FPlasticGetChangesetFilesWorker::Execute(FPlasticSourceControlCommand& InCommand)
{
TRACE_CPUPROFILER_EVENT_SCOPE(FPlasticGetChangesetFilesWorker::Execute);

check(InCommand.Operation->GetName() == GetName());
TSharedRef<FPlasticGetChangesetFiles, ESPMode::ThreadSafe> Operation = StaticCastSharedRef<FPlasticGetChangesetFiles>(InCommand.Operation);

if (!Operation->Changeset.IsValid())
{
return false;
}

{
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunGetChangesetFiles(Operation->Changeset.ToSharedRef(), Operation->Files, InCommand.ErrorMessages);
}

{
InCommand.bCommandSuccessful &= PlasticSourceControlUtils::GetChangesetNumber(InCommand.ChangesetNumber, InCommand.ErrorMessages);
}

return InCommand.bCommandSuccessful;
}

bool FPlasticGetChangesetFilesWorker::UpdateStates()
{
return false;
}


FName FPlasticUpdateStatusWorker::GetName() const
{
return "UpdateStatus";
Expand Down Expand Up @@ -2566,6 +2613,7 @@ bool FPlasticUnshelveWorker::Execute(FPlasticSourceControlCommand& InCommand)
TArray<FString> Parameters;
Parameters.Add(TEXT("apply"));
Parameters.Add(FString::Printf(TEXT("sh:%d"), ChangelistState->ShelveId));
// TODO --noinput
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunCommand(TEXT("shelveset"), Parameters, FilesToUnshelve, InCommand.InfoMessages, InCommand.ErrorMessages);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
class FPlasticSourceControlProvider;
typedef TSharedRef<class FPlasticSourceControlBranch, ESPMode::ThreadSafe> FPlasticSourceControlBranchRef;
typedef TSharedRef<class FPlasticSourceControlChangeset, ESPMode::ThreadSafe> FPlasticSourceControlChangesetRef;
typedef TSharedPtr<class FPlasticSourceControlChangeset, ESPMode::ThreadSafe> FPlasticSourceControlChangesetPtr;
typedef TSharedRef<class FPlasticSourceControlLock, ESPMode::ThreadSafe> FPlasticSourceControlLockRef;


Expand Down Expand Up @@ -265,6 +266,25 @@ class FPlasticGetChangesets final : public FSourceControlOperationBase
};


/**
* Internal operation to list files in a changeset, using "cm log cs:<ChangesetId>"
*/
class FPlasticGetChangesetFiles final : public FSourceControlOperationBase
{
public:
// ISourceControlOperation interface
virtual FName GetName() const override;

virtual FText GetInProgressString() const override;

// Changeset to list files from
FPlasticSourceControlChangesetPtr Changeset;

// List of files changed in the changeset
TArray<FPlasticSourceControlStateRef> Files;
};


/** Called when first activated on a project, and then at project load time.
* Look for the root directory of the Plastic workspace (where the ".plastic/" subdirectory is located). */
class FPlasticConnectWorker final : public IPlasticSourceControlWorker
Expand Down Expand Up @@ -611,6 +631,20 @@ class FPlasticGetChangesetsWorker final : public IPlasticSourceControlWorker
int32 CurrentChangesetId;
};

/** list files in changeset. */
class FPlasticGetChangesetFilesWorker final : public IPlasticSourceControlWorker
{
public:
explicit FPlasticGetChangesetFilesWorker(FPlasticSourceControlProvider& InSourceControlProvider)
: IPlasticSourceControlWorker(InSourceControlProvider)
{}
virtual ~FPlasticGetChangesetFilesWorker() = default;
// IPlasticSourceControlWorker interface
virtual FName GetName() const override;
virtual bool Execute(class FPlasticSourceControlCommand& InCommand) override;
virtual bool UpdateStates() override;
};

/** Plastic update the workspace to latest changes */
class FPlasticSyncWorker final : public IPlasticSourceControlWorker
{
Expand Down
Loading