Skip to content

Commit

Permalink
Fix #55 Support for xlink sub-repositories with xlinks (history and d…
Browse files Browse the repository at this point in the history
…iff)

In the history window, in the Revision column, also append the name of the depot to the revision itself if if the file is from another repository (xlink)
  • Loading branch information
SRombauts committed Jan 8, 2019
2 parents 20d9a49 + 39b215c commit 48f3ad9
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#include "PlasticSourceControlCommand.h"
#include "PlasticSourceControlModule.h"
#include "PlasticSourceControlUtils.h"
#include "AssetRegistryModule.h"

#include "AssetRegistryModule.h"
#include "Async/Async.h"
#include "HAL/FileManager.h"
#include "Misc/Paths.h"
#include "Async/Async.h"
#include "SourceControlOperations.h"

#define LOCTEXT_NAMESPACE "PlasticSourceControl"

Expand Down Expand Up @@ -77,7 +78,7 @@ bool FPlasticConnectWorker::Execute(FPlasticSourceControlCommand& InCommand)
TArray<FString> ProjectDirs;
ProjectDirs.Add(FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir()));
ProjectDirs.Add(FPaths::ConvertRelativePathToFull(FPaths::ProjectConfigDir()));
PlasticSourceControlUtils::RunUpdateStatus(ProjectDirs, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
PlasticSourceControlUtils::RunUpdateStatus(ProjectDirs, false, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
}
}
else
Expand Down Expand Up @@ -124,7 +125,7 @@ bool FPlasticCheckOutWorker::Execute(FPlasticSourceControlCommand& InCommand)
}

// now update the status of our files
PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, false, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);

return InCommand.bCommandSuccessful;
}
Expand Down Expand Up @@ -213,7 +214,7 @@ bool FPlasticCheckInWorker::Execute(FPlasticSourceControlCommand& InCommand)
}

// now update the status of our files
PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, false, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);

return InCommand.bCommandSuccessful;
}
Expand Down Expand Up @@ -246,7 +247,7 @@ bool FPlasticMarkForAddWorker::Execute(FPlasticSourceControlCommand& InCommand)
}

// now update the status of our files
PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, false, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);

return InCommand.bCommandSuccessful;
}
Expand Down Expand Up @@ -276,7 +277,7 @@ bool FPlasticDeleteWorker::Execute(FPlasticSourceControlCommand& InCommand)
}

// now update the status of our files
PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, false, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);

return InCommand.bCommandSuccessful;
}
Expand Down Expand Up @@ -365,7 +366,7 @@ bool FPlasticRevertUnchangedWorker::Execute(FPlasticSourceControlCommand& InComm
TArray<FString> ProjectDirs;
ProjectDirs.Add(FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir()));
ProjectDirs.Add(FPaths::ConvertRelativePathToFull(FPaths::ProjectConfigDir()));
PlasticSourceControlUtils::RunUpdateStatus(ProjectDirs, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
PlasticSourceControlUtils::RunUpdateStatus(ProjectDirs, false, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);

return InCommand.bCommandSuccessful;
}
Expand Down Expand Up @@ -401,7 +402,7 @@ bool FPlasticRevertAllWorker::Execute(FPlasticSourceControlCommand& InCommand)
TArray<FString> ProjectDirs;
ProjectDirs.Add(FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir()));
ProjectDirs.Add(FPaths::ConvertRelativePathToFull(FPaths::ProjectConfigDir()));
PlasticSourceControlUtils::RunUpdateStatus(ProjectDirs, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
PlasticSourceControlUtils::RunUpdateStatus(ProjectDirs, false, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);

return InCommand.bCommandSuccessful;
}
Expand Down Expand Up @@ -459,7 +460,7 @@ bool FPlasticUpdateStatusWorker::Execute(FPlasticSourceControlCommand& InCommand

if (InCommand.Files.Num() > 0)
{
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, Operation->ShouldUpdateHistory(), InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
// Remove all "is not in a workspace" error and convert the result to "success" if there are no other errors
PlasticSourceControlUtils::RemoveRedundantErrors(InCommand, TEXT("is not in a workspace."));
if (!InCommand.bCommandSuccessful)
Expand All @@ -481,7 +482,7 @@ bool FPlasticUpdateStatusWorker::Execute(FPlasticSourceControlCommand& InCommand
if (State.IsSourceControlled())
{
// Get the history of the file (on all branches)
InCommand.bCommandSuccessful &= PlasticSourceControlUtils::RunGetHistory(File, InCommand.ErrorMessages, History);
InCommand.bCommandSuccessful &= PlasticSourceControlUtils::RunGetHistory(File, State.RepSpec, InCommand.ErrorMessages, History);
if (State.IsConflicted())
{
// In case of a merge conflict, we need to put the tip of the "remote branch" on top of the history
Expand Down Expand Up @@ -513,7 +514,7 @@ bool FPlasticUpdateStatusWorker::Execute(FPlasticSourceControlCommand& InCommand
TArray<FString> ProjectDirs;
ProjectDirs.Add(FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir()));
ProjectDirs.Add(FPaths::ConvertRelativePathToFull(FPaths::ProjectConfigDir()));
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunUpdateStatus(ProjectDirs, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
InCommand.bCommandSuccessful = PlasticSourceControlUtils::RunUpdateStatus(ProjectDirs, false, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
}

// don't use the ShouldUpdateModifiedState() hint here as it is specific to Perforce: the above normal Plastic status has already told us this information (like Git and Mercurial)
Expand Down Expand Up @@ -670,7 +671,7 @@ bool FPlasticCopyWorker::Execute(FPlasticSourceControlCommand& InCommand)
TArray<FString> BothFiles;
BothFiles.Add(Origin);
BothFiles.Add(Destination);
PlasticSourceControlUtils::RunUpdateStatus(BothFiles, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
PlasticSourceControlUtils::RunUpdateStatus(BothFiles, false, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
}
else
{
Expand Down Expand Up @@ -718,7 +719,7 @@ bool FPlasticSyncWorker::Execute(FPlasticSourceControlCommand& InCommand)
TArray<FString> ProjectDirs;
ProjectDirs.Add(FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir()));
ProjectDirs.Add(FPaths::ConvertRelativePathToFull(FPaths::ProjectConfigDir()));
PlasticSourceControlUtils::RunUpdateStatus(ProjectDirs, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
PlasticSourceControlUtils::RunUpdateStatus(ProjectDirs, false, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
}
// else: optim, no need to update the status of our files since this is done immediately after by the Editor
}
Expand Down Expand Up @@ -767,7 +768,7 @@ bool FPlasticResolveWorker::Execute(FPlasticSourceControlCommand& InCommand)
}

// now update the status of our files
PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);
PlasticSourceControlUtils::RunUpdateStatus(InCommand.Files, false, InCommand.Concurrency, InCommand.ErrorMessages, States, InCommand.ChangesetNumber, InCommand.BranchName);

return InCommand.bCommandSuccessful;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void FPlasticSourceControlProvider::Close()
UserName.Empty();
}

TSharedRef<FPlasticSourceControlState, ESPMode::ThreadSafe> FPlasticSourceControlProvider::GetStateInternal(const FString& Filename)
TSharedRef<FPlasticSourceControlState, ESPMode::ThreadSafe> FPlasticSourceControlProvider::GetStateInternal(const FString& Filename) const
{
TSharedRef<FPlasticSourceControlState, ESPMode::ThreadSafe>* State = StateCache.Find(Filename);
if(State != NULL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FPlasticSourceControlProvider : public ISourceControlProvider
virtual const FName& GetName(void) const override;
virtual bool QueryStateBranchConfig(const FString& ConfigSrc, const FString& ConfigDest) /* override UE4.20 */ { return false; }
virtual void RegisterStateBranches(const TArray<FString>& BranchNames, const FString& ContentRoot) /* override UE4.20 */ {}
virtual int32 GetStateBranchIndex(const FString& BranchName) const /* override UE4.20 */ { return INDEX_NONE; }
virtual int32 GetStateBranchIndex(const FString& InBranchName) const /* override UE4.20 */ { return INDEX_NONE; }
virtual ECommandResult::Type GetState( const TArray<FString>& InFiles, TArray< TSharedRef<ISourceControlState, ESPMode::ThreadSafe> >& OutState, EStateCacheUsage::Type InStateCacheUsage ) override;
virtual TArray<FSourceControlStateRef> GetCachedStateByPredicate(TFunctionRef<bool(const FSourceControlStateRef&)> Predicate) const override;
virtual FDelegateHandle RegisterSourceControlStateChanged_Handle( const FSourceControlStateChanged::FDelegate& SourceControlStateChanged ) override;
Expand Down Expand Up @@ -108,7 +108,7 @@ class FPlasticSourceControlProvider : public ISourceControlProvider
}

/** Helper function used to update state cache */
TSharedRef<FPlasticSourceControlState, ESPMode::ThreadSafe> GetStateInternal(const FString& Filename);
TSharedRef<FPlasticSourceControlState, ESPMode::ThreadSafe> GetStateInternal(const FString& Filename) const;

/**
* Register a worker with the provider.
Expand Down Expand Up @@ -166,7 +166,7 @@ class FPlasticSourceControlProvider : public ISourceControlProvider
int32 ChangesetNumber;

/** State cache */
TMap<FString, TSharedRef<class FPlasticSourceControlState, ESPMode::ThreadSafe> > StateCache;
mutable TMap<FString, TSharedRef<class FPlasticSourceControlState, ESPMode::ThreadSafe> > StateCache;

/** The currently registered source control operations */
TMap<FName, FGetPlasticSourceControlWorker> WorkersMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "PlasticSourceControlRevision.h"
#include "PlasticSourceControlModule.h"
#include "PlasticSourceControlProvider.h"
#include "PlasticSourceControlState.h"
#include "PlasticSourceControlUtils.h"
#include "SPlasticSourceControlSettings.h"

Expand All @@ -15,9 +16,8 @@
bool FPlasticSourceControlRevision::Get( FString& InOutFilename ) const
{
const FPlasticSourceControlModule& PlasticSourceControl = FModuleManager::LoadModuleChecked<FPlasticSourceControlModule>("PlasticSourceControl");
const FPlasticSourceControlState& State = *PlasticSourceControl.GetProvider().GetStateInternal(Filename);
const FString& PathToPlasticBinary = PlasticSourceControl.AccessSettings().GetBinaryPath();
const FString& RepositoryName = PlasticSourceControl.GetProvider().GetRepositoryName();
const FString& ServerUrl = PlasticSourceControl.GetProvider().GetServerUrl();

// if a filename for the temp file wasn't supplied generate a unique-ish one
if(InOutFilename.Len() == 0)
Expand All @@ -36,8 +36,8 @@ bool FPlasticSourceControlRevision::Get( FString& InOutFilename ) const
}
else
{
// Format the revision specification of the file, like revid:1230@rep:myrep@repserver:myserver:8084
const FString RevisionSpecification = FString::Printf(TEXT("revid:%d@rep:%s@repserver:%s"), RevisionId, *RepositoryName, *ServerUrl);
// Format the revision specification of the file, like revid:1230@repo@server:8087
const FString RevisionSpecification = FString::Printf(TEXT("revid:%d@%s"), RevisionId, *State.RepSpec);
bCommandSuccessful = PlasticSourceControlUtils::RunDumpToFile(PathToPlasticBinary, RevisionSpecification, InOutFilename);
}
return bCommandSuccessful;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ class FPlasticSourceControlState : public ISourceControlState, public TSharedFro
virtual bool IsDeleted() const override;
virtual bool IsIgnored() const override;
virtual bool CanEdit() const override;
virtual bool CanDelete() const override;
virtual bool IsUnknown() const override;
virtual bool IsModified() const override;
virtual bool CanAdd() const override;
virtual bool CanDelete() const override;
virtual bool IsConflicted() const override;
virtual bool CanRevert() const; // override; TODO UE 4.19 only - commented for backward compatibility

Expand All @@ -90,6 +90,9 @@ class FPlasticSourceControlState : public ISourceControlState, public TSharedFro
/** Filename on disk */
FString LocalFilename;

/** Depot and Server info (in the form repo@server:port) */
FString RepSpec;

/** Relative filename of the file in merge conflict */
FString PendingMergeFilename;

Expand Down
Loading

0 comments on commit 48f3ad9

Please sign in to comment.