本文整理汇总了C++中FSourceControlStatePtr::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ FSourceControlStatePtr::IsValid方法的具体用法?C++ FSourceControlStatePtr::IsValid怎么用?C++ FSourceControlStatePtr::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSourceControlStatePtr
的用法示例。
在下文中一共展示了FSourceControlStatePtr::IsValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSetupStateBasedOnFile
SPlatformSetupMessage::ESetupState SPlatformSetupMessage::GetSetupStateBasedOnFile(bool bForce) const
{
if (!FPaths::FileExists(TargetFilename))
{
return MissingFiles;
}
else
{
ISourceControlModule& SCC = ISourceControlModule::Get();
if (SCC.IsEnabled() && SCC.GetProvider().IsAvailable())
{
ISourceControlProvider& Provider = SCC.GetProvider();
FSourceControlStatePtr SourceControlState = Provider.GetState(TargetFilename, bForce ? EStateCacheUsage::ForceUpdate : EStateCacheUsage::Use);
if (SourceControlState.IsValid())
{
if (SourceControlState->IsSourceControlled())
{
if (SourceControlState->CanCheckout())
{
return NeedsCheckout;
}
}
else
{
//@TODO: Should we instead try to add the file?
}
}
}
// SCC is disabled or unavailable
const bool bIsReadOnly = FPlatformFileManager::Get().GetPlatformFile().IsReadOnly(*TargetFilename);
return bIsReadOnly ? ReadOnlyFiles : ReadyToModify;
}
}
示例2: GenerateMergeTabContents
TSharedRef<SDockTab> FMerge::GenerateMergeWidget(const UBlueprint& Object, TSharedRef<FBlueprintEditor> Editor)
{
auto ActiveTabPtr = ActiveTab.Pin();
if( ActiveTabPtr.IsValid() )
{
// just bring the tab to the foreground:
auto CurrentTab = FGlobalTabmanager::Get()->InvokeTab(MergeToolTabId);
check( CurrentTab == ActiveTabPtr );
return ActiveTabPtr.ToSharedRef();
}
// merge the local asset with the depot, SCC provides us with the last common revision as
// a basis for the merge:
TSharedPtr<SWidget> Contents;
if (!PendingMerge(Object))
{
// this should load up the merge-tool, with an asset picker, where they
// can pick the asset/revisions to merge against
Contents = GenerateMergeTabContents(Editor, nullptr, FRevisionInfo::InvalidRevision(), nullptr, FRevisionInfo::InvalidRevision(), &Object, FOnMergeResolved());
}
else
{
// @todo DO: this will probably need to be async.. pulling down some old versions of assets:
const FString& PackageName = Object.GetOutermost()->GetName();
const FString& AssetName = Object.GetName();
FSourceControlStatePtr SourceControlState = FMergeToolUtils::GetSourceControlState(PackageName);
if (!SourceControlState.IsValid())
{
DisplayErrorMessage(
FText::Format(
LOCTEXT("MergeFailedNoSourceControl", "Aborted Load of {0} from {1} because the source control state was invalidated")
, FText::FromString(AssetName)
, FText::FromString(PackageName)
)
);
Contents = SNew(SHorizontalBox);
}
else
{
ISourceControlState const& SourceControlStateRef = *SourceControlState;
FRevisionInfo CurrentRevInfo = FRevisionInfo::InvalidRevision();
const UBlueprint* RemoteBlueprint = Cast< UBlueprint >(LoadHeadRev(PackageName, AssetName, SourceControlStateRef, CurrentRevInfo));
FRevisionInfo BaseRevInfo = FRevisionInfo::InvalidRevision();
const UBlueprint* BaseBlueprint = Cast< UBlueprint >(LoadBaseRev(PackageName, AssetName, SourceControlStateRef, BaseRevInfo));
Contents = GenerateMergeTabContents(Editor, BaseBlueprint, BaseRevInfo, RemoteBlueprint, CurrentRevInfo, &Object, FOnMergeResolved());
}
}
TSharedRef<SDockTab> Tab = FGlobalTabmanager::Get()->InvokeTab(MergeToolTabId);
Tab->SetContent(Contents.ToSharedRef());
ActiveTab = Tab;
return Tab;
}
示例3: Update
bool FGetStateLatentCommand::Update()
{
FSourceControlStatePtr SourceControlState = ISourceControlModule::Get().GetProvider().GetState(SourceControlHelpers::PackageFilename(Filename), EStateCacheUsage::Use);
if(!SourceControlState.IsValid())
{
UE_LOG(LogSourceControl, Error, TEXT("Failed to get a valid state for file: %s"), *Filename);
}
else
{
if(!SourceControlState->IsCheckedOut())
{
UE_LOG(LogSourceControl, Error, TEXT("File '%s' should be checked out, but isnt."), *Filename);
}
else
{
if(SourceControlState->GetHistorySize() == 0)
{
UE_LOG(LogSourceControl, Error, TEXT("Failed to get a valid history for file: %s"), *Filename);
}
else
{
TSharedPtr<ISourceControlRevision, ESPMode::ThreadSafe> HistoryItem = SourceControlState->GetHistoryItem(0);
if(!HistoryItem.IsValid())
{
UE_LOG(LogSourceControl, Error, TEXT("Failed to get a valid history item 0 for file: %s"), *Filename);
}
}
}
}
return true;
}
示例4: GetSCCStateImage
const FSlateBrush* SWorldHierarchyItem::GetSCCStateImage() const
{
FSourceControlStatePtr SourceControlState = ISourceControlModule::Get().GetProvider().GetState(LevelModel->GetPackageFileName(), EStateCacheUsage::Use);
if(SourceControlState.IsValid())
{
return FEditorStyle::GetBrush(SourceControlState->GetSmallIconName());
}
return NULL;
}
示例5: GetSCCStateTooltip
FText SWorldHierarchyItem::GetSCCStateTooltip() const
{
FSourceControlStatePtr SourceControlState = ISourceControlModule::Get().GetProvider().GetState(LevelModel->GetPackageFileName(), EStateCacheUsage::Use);
if(SourceControlState.IsValid())
{
return SourceControlState->GetDisplayTooltip();
}
return FText::GetEmpty();
}
示例6: ExecuteSCCOpenForAdd
void FPathContextMenu::ExecuteSCCOpenForAdd()
{
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
// Get a list of package names in the selected paths
TArray<FString> PackageNames;
GetPackageNamesInSelectedPaths(PackageNames);
TArray<FString> PackagesToAdd;
TArray<UPackage*> PackagesToSave;
for ( auto PackageIt = PackageNames.CreateConstIterator(); PackageIt; ++PackageIt )
{
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(SourceControlHelpers::PackageFilename(*PackageIt), EStateCacheUsage::Use);
if ( SourceControlState.IsValid() && !SourceControlState->IsSourceControlled() )
{
PackagesToAdd.Add(*PackageIt);
// Make sure the file actually exists on disk before adding it
FString Filename;
if ( !FPackageName::DoesPackageExist(*PackageIt, NULL, &Filename) )
{
UPackage* Package = FindPackage(NULL, **PackageIt);
if ( Package )
{
PackagesToSave.Add(Package);
}
}
}
}
if ( PackagesToAdd.Num() > 0 )
{
// If any of the packages are new, save them now
if ( PackagesToSave.Num() > 0 )
{
const bool bCheckDirty = false;
const bool bPromptToSave = false;
TArray<UPackage*> FailedPackages;
const FEditorFileUtils::EPromptReturnCode Return = FEditorFileUtils::PromptForCheckoutAndSave(PackagesToSave, bCheckDirty, bPromptToSave, &FailedPackages);
if(FailedPackages.Num() > 0)
{
// don't try and add files that failed to save - remove them from the list
for(auto FailedPackageIt = FailedPackages.CreateConstIterator(); FailedPackageIt; FailedPackageIt++)
{
PackagesToAdd.Remove((*FailedPackageIt)->GetName());
}
}
}
if ( PackagesToAdd.Num() > 0 )
{
SourceControlProvider.Execute(ISourceControlOperation::Create<FMarkForAdd>(), SourceControlHelpers::PackageFilenames(PackagesToAdd));
}
}
}
示例7: Tick
void SSettingsEditorCheckoutNotice::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
{
SCompoundWidget::Tick(AllottedGeometry, InCurrentTime, InDeltaTime);
// cache selected settings object's configuration file state
DefaultConfigCheckOutTimer += InDeltaTime;
if (DefaultConfigCheckOutTimer >= 1.0f)
{
bool NewCheckOutNeeded = false;
DefaultConfigQueryInProgress = true;
FString CachedConfigFileName = ConfigFilePath.Get();
if (!CachedConfigFileName.IsEmpty())
{
if (ISourceControlModule::Get().IsEnabled())
{
// note: calling QueueStatusUpdate often does not spam status updates as an internal timer prevents this
ISourceControlModule::Get().QueueStatusUpdate(CachedConfigFileName);
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(CachedConfigFileName, EStateCacheUsage::Use);
NewCheckOutNeeded = SourceControlState.IsValid() && SourceControlState->CanCheckout();
DefaultConfigQueryInProgress = SourceControlState.IsValid() && SourceControlState->IsUnknown();
}
else
{
NewCheckOutNeeded = (FPaths::FileExists(CachedConfigFileName) && IFileManager::Get().IsReadOnly(*CachedConfigFileName));
DefaultConfigQueryInProgress = false;
}
// file has been checked in or reverted
if ((NewCheckOutNeeded == true) && (DefaultConfigCheckOutNeeded == false))
{
OnFileProbablyModifiedExternally.ExecuteIfBound();
}
}
DefaultConfigCheckOutNeeded = NewCheckOutNeeded;
DefaultConfigCheckOutTimer = 0.0f;
}
}
示例8: LoadReferencingPackages
void FAssetFixUpRedirectors::LoadReferencingPackages(TArray<FRedirectorRefs>& RedirectorsToFix, TArray<UPackage*>& OutReferencingPackagesToSave) const
{
FScopedSlowTask SlowTask( RedirectorsToFix.Num(), LOCTEXT( "LoadingReferencingPackages", "Loading Referencing Packages..." ) );
SlowTask.MakeDialog();
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
// Load all packages that reference each redirector, if possible
for ( auto RedirectorRefsIt = RedirectorsToFix.CreateIterator(); RedirectorRefsIt; ++RedirectorRefsIt )
{
SlowTask.EnterProgressFrame(1);
FRedirectorRefs& RedirectorRefs = *RedirectorRefsIt;
if ( ISourceControlModule::Get().IsEnabled() )
{
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(RedirectorRefs.Redirector->GetOutermost(), EStateCacheUsage::Use);
const bool bValidSCCState = !SourceControlState.IsValid() || SourceControlState->IsAdded() || SourceControlState->IsCheckedOut() || SourceControlState->CanCheckout() || !SourceControlState->IsSourceControlled() || SourceControlState->IsIgnored();
if ( !bValidSCCState )
{
RedirectorRefs.bRedirectorValidForFixup = false;
RedirectorRefs.FailureReason = LOCTEXT("RedirectorFixupFailed_BadSCC", "Redirector could not be checked out or marked for delete");
}
}
// Load all referencers
for ( auto PackageNameIt = RedirectorRefs.ReferencingPackageNames.CreateConstIterator(); PackageNameIt; ++PackageNameIt )
{
const FString PackageName = (*PackageNameIt).ToString();
// Find the package in memory. If it is not in memory, try to load it
UPackage* Package = FindPackage(NULL, *PackageName);
if ( !Package )
{
Package = LoadPackage(NULL, *PackageName, LOAD_None);
}
if ( Package )
{
if ( Package->PackageFlags & PKG_CompiledIn )
{
// This is a script reference
RedirectorRefs.bRedirectorValidForFixup = false;
RedirectorRefs.FailureReason = FText::Format(LOCTEXT("RedirectorFixupFailed_CodeReference", "Redirector is referenced by code. Package: {0}"), FText::FromString(PackageName));
}
else
{
// If we found a valid package, mark it for save
OutReferencingPackagesToSave.AddUnique(Package);
}
}
}
}
}
示例9: PendingMerge
bool FMerge::PendingMerge(const UBlueprint& BlueprintObj) const
{
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
bool bPendingMerge = false;
if( SourceControlProvider.IsEnabled() )
{
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(BlueprintObj.GetOutermost(), EStateCacheUsage::Use);
bPendingMerge = SourceControlState.IsValid() && SourceControlState->IsConflicted();
}
return bPendingMerge;
}
示例10: InitWithConfigAndProperty
void UPropertyConfigFileDisplayRow::InitWithConfigAndProperty(const FString& InConfigFileName, UProperty* InEditProperty)
{
ConfigFileName = FPaths::ConvertRelativePathToFull(InConfigFileName);
ExternalProperty = InEditProperty;
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
// We will add source control soon...
FSourceControlStatePtr SourceControlState = nullptr; // SourceControlProvider.GetState(ConfigFileName, EStateCacheUsage::Use);
// Only include config files that are currently checked out or packages not under source control
{
if (FPaths::FileExists(ConfigFileName))
{
if (SourceControlState.IsValid())
{
bIsFileWritable = SourceControlState->IsCheckedOut() || SourceControlState->IsAdded();
}
else
{
bIsFileWritable = !IFileManager::Get().IsReadOnly(*ConfigFileName);
}
}
else
{
if (SourceControlState.IsValid())
{
bIsFileWritable = (SourceControlState->IsSourceControlled() && SourceControlState->CanAdd());
}
else
{
bIsFileWritable = false;
}
}
}
}
示例11: DeleteSourceContentFiles
void FAssetDeleteModel::DeleteSourceContentFiles()
{
IFileManager& FileManager = IFileManager::Get();
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
for (const auto& Pair : SourceFileToAssetCount)
{
const auto& Path = Pair.Key;
// We can only delete this path if there are no (non-deleted) objects referencing it
if (Pair.Value != 0)
{
continue;
}
// One way or another this file is going to be deleted, but we don't want the import manager to react to the deletion
GUnrealEd->AutoReimportManager->ReportExternalChange(Path, FFileChangeData::FCA_Removed);
if (ISourceControlModule::Get().IsEnabled())
{
const FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(Path, EStateCacheUsage::ForceUpdate);
const bool bIsSourceControlled = SourceControlState.IsValid() && SourceControlState->IsSourceControlled();
if (bIsSourceControlled)
{
// The file is managed by source control. Delete it through there.
TArray<FString> DeleteFilenames;
DeleteFilenames.Add(Path);
// Revert the file if it is checked out
const bool bIsAdded = SourceControlState->IsAdded();
if (SourceControlState->IsCheckedOut() || bIsAdded || SourceControlState->IsDeleted())
{
SourceControlProvider.Execute(ISourceControlOperation::Create<FRevert>(), DeleteFilenames);
}
// If it wasn't already marked as an add, we can ask the source control provider to delete the file
if (!bIsAdded)
{
// Open the file for delete
SourceControlProvider.Execute(ISourceControlOperation::Create<FDelete>(), DeleteFilenames);
continue;
}
}
}
// We'll just delete it ourself
FileManager.Delete(*Path, false /* RequireExists */, true /* Even if read only */, true /* Quiet */);
}
}
示例12: CacheCanExecuteSourceControlVars
void FLevelCollectionModel::CacheCanExecuteSourceControlVars() const
{
bCanExecuteSCCCheckOut = false;
bCanExecuteSCCOpenForAdd = false;
bCanExecuteSCCCheckIn = false;
bCanExecuteSCC = false;
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
for (auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
{
if (ISourceControlModule::Get().IsEnabled() && SourceControlProvider.IsAvailable())
{
bCanExecuteSCC = true;
ULevel* Level = (*It)->GetLevelObject();
if (Level)
{
// Check the SCC state for each package in the selected paths
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(Level->GetOutermost(), EStateCacheUsage::Use);
if (SourceControlState.IsValid())
{
if (SourceControlState->CanCheckout())
{
bCanExecuteSCCCheckOut = true;
}
else if (!SourceControlState->IsSourceControlled())
{
bCanExecuteSCCOpenForAdd = true;
}
else if (SourceControlState->IsCheckedOut() || SourceControlState->IsAdded())
{
bCanExecuteSCCCheckIn = true;
}
}
}
}
if (bCanExecuteSCCCheckOut &&
bCanExecuteSCCOpenForAdd &&
bCanExecuteSCCCheckIn)
{
// All options are available, no need to keep iterating
break;
}
}
}
示例13: RevertFile
bool FGatherTextSCC::RevertFile( const FString& InFile, FString& OutError )
{
if( InFile.IsEmpty() )
{
OutError = TEXT("Could not revert file.");
return false;
}
FString SCCError;
if( !IsReady( SCCError ) )
{
OutError = SCCError;
return false;
}
FString AbsoluteFilename = FPaths::ConvertRelativePathToFull(InFile);
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState( AbsoluteFilename, EStateCacheUsage::ForceUpdate );
bool bSuccessfullyReverted = false;
TArray<FString> FilesToRevert;
FilesToRevert.Add(AbsoluteFilename);
if( SourceControlState.IsValid() && !SourceControlState->IsCheckedOut() && !SourceControlState->IsAdded() )
{
bSuccessfullyReverted = true;
}
else
{
bSuccessfullyReverted = (SourceControlProvider.Execute(ISourceControlOperation::Create<FRevert>(), FilesToRevert) == ECommandResult::Succeeded);
}
if(!bSuccessfullyReverted)
{
OutError = TEXT("Could not revert file.");
}
else
{
CheckedOutFiles.Remove( AbsoluteFilename );
}
return bSuccessfullyReverted;
}
示例14: CacheCanExecuteVars
void FPathContextMenu::CacheCanExecuteVars()
{
// Cache whether we can execute any of the source control commands
bCanExecuteSCCCheckOut = false;
bCanExecuteSCCOpenForAdd = false;
bCanExecuteSCCCheckIn = false;
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
if ( SourceControlProvider.IsEnabled() && SourceControlProvider.IsAvailable() )
{
TArray<FString> PackageNames;
GetPackageNamesInSelectedPaths(PackageNames);
// Check the SCC state for each package in the selected paths
for ( auto PackageIt = PackageNames.CreateConstIterator(); PackageIt; ++PackageIt )
{
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(SourceControlHelpers::PackageFilename(*PackageIt), EStateCacheUsage::Use);
if(SourceControlState.IsValid())
{
if ( SourceControlState->CanCheckout() )
{
bCanExecuteSCCCheckOut = true;
}
else if ( !SourceControlState->IsSourceControlled() )
{
bCanExecuteSCCOpenForAdd = true;
}
else if ( SourceControlState->CanCheckIn() )
{
bCanExecuteSCCCheckIn = true;
}
}
if ( bCanExecuteSCCCheckOut && bCanExecuteSCCOpenForAdd && bCanExecuteSCCCheckIn )
{
// All SCC options are available, no need to keep iterating
break;
}
}
}
}
示例15: RevertCollection
bool FCollection::RevertCollection(FText& OutError)
{
if ( !ensure(SourceFilename.Len()) )
{
OutError = LOCTEXT("Error_Internal", "There was an internal error.");
return false;
}
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
if ( !ISourceControlModule::Get().IsEnabled() )
{
OutError = LOCTEXT("Error_SCCDisabled", "Source control is not enabled. Enable source control in the preferences menu.");
return false;
}
if ( !SourceControlProvider.IsAvailable() )
{
OutError = LOCTEXT("Error_SCCNotAvailable", "Source control is currently not available. Check your connection and try again.");
return false;
}
FString AbsoluteFilename = FPaths::ConvertRelativePathToFull(SourceFilename);
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(AbsoluteFilename, EStateCacheUsage::ForceUpdate);
if ( SourceControlState.IsValid() && !(SourceControlState->IsCheckedOut() || SourceControlState->IsAdded()) )
{
OutError = FText::Format(LOCTEXT("Error_SCCNotCheckedOut", "Collection '{0}' not checked out or open for add."), FText::FromName(CollectionName));
return false;
}
if ( SourceControlProvider.Execute(ISourceControlOperation::Create<FRevert>(), AbsoluteFilename) == ECommandResult::Succeeded)
{
return true;
}
else
{
OutError = FText::Format(LOCTEXT("Error_SCCRevert", "Could not revert collection '{0}'"), FText::FromName(CollectionName));
return false;
}
}