RenameAssets() and FixupReferencers() hard coded source control checkout

Firstly, I am calling this rename function to update a list of uasset names. Here’s the order of operations:

AssetToolsModule.Get().RenameAssets(AssetsToRename);

FAssetRenameManager::RenameAssetsAndVariants()

FAssetRenameManager::FixReferencesAndRename()

const bool bUserAcceptedCheckout = CheckOutPackages(AssetsToRename, ReferencingPackagesToSave, bAutoCheckout);

Inside CheckOutPackages()

// If the checkout was declined (or failed), then fail the entire rename request

if (!bUserAcceptedCheckout)

{

for (FAssetRenameDataWithReferencers& AssetToRename : AssetsToRename)

{

if (!AssetToRename.bRenameFailed)

{

AssetToRename.bRenameFailed = true;

AssetToRename.FailureReason = LOCTEXT(“RenameFailedNotCheckedOutOrWritable”, “Not checked-out or writable.”);

}

}

}

Why does this function force the process to fail if it cannot checkout packages?

We have our own source control pipeline using python scripting and this hard-coded behavior is breaking our workflow.

After I call the rename function, I cleanup redirectors to delete the old uasset names. This also fails if it cannot checkout.

AssetToolsModule.Get().FixupReferencers(Redirectors, false, ERedirectFixupMode::DeleteFixedUpRedirectors);

FAssetFixUpRedirectors::ExecuteFixUp()

Inside ExecuteFixUp()

// Check out all referencing packages, leave redirectors for assets referenced by packages that are not checked out and remove those packages from the save list.

bool bUserAcceptedCheckout = true; // If source control is disabled, assume checkout was selected

if (ISourceControlModule::Get().IsEnabled() && ReferencingPackagesToSave.Num() > 0)

{

TArray<UPackage*> PackagesCheckedOutOrMadeWritable;

TArray<UPackage*> PackagesNotNeedingCheckout;

if (bCheckoutDialogPrompt)

{

bUserAcceptedCheckout = FEditorFileUtils::PromptToCheckoutPackages(false, ReferencingPackagesToSave.Array(), &PackagesCheckedOutOrMadeWritable, &PackagesNotNeedingCheckout);

}

else

{

const bool bErrorIfAlreadyCheckedOut = false;

const bool bConfirmPackageBranchCheckOutStatus = false;

FEditorFileUtils::CheckoutPackages(ReferencingPackagesToSave.Array(), &PackagesCheckedOutOrMadeWritable, bErrorIfAlreadyCheckedOut, bConfirmPackageBranchCheckOutStatus);

}

For both of these operations - RenameAssets() and FixupReferencers() - Could this behavior be sidestepped by an optional function parameter that allows us to perform the rename without the forced checkout?

Steps to Reproduce

Call AssetToolsModule.Get().RenameAssets(AssetsToRename) and

AssetToolsModule.Get().FixupReferencers(Redirectors, false, ERedirectFixupMode::DeleteFixedUpRedirectors)

If any applicable assets are checked out, the operation fails.

Hi Steven,

Sorry for the delayed answer.

We won’t add an argument to sidestep those. Most source controls system put the file in a read only mode by default. We have to poke that system to tell us that we can write to those files. Also most source control implementation are setup in a way to require a exclusive checkout on the binaries files like the assets because they don’t know how to merge those files.

Turning off the dialog still require us to do check out the files because we are going modify them. We just assume you have the user permission or the caller is some sort of automation.

If we can’t modify some of the files during a rename (to leave a redirector or to fixup the dependencies in a call to FixupReferencers) we have to fail because the operation can’t do what it’s ask to do.

From the API stand point, we don’t want to give the impression that is something you should do or is well supported. Outside of that, you can temporary disable the source control on the editor instance if needed which will make your call not fail but you will need to deal with the source control setup by yourself later (see FScopedDisableSourceControl in Engine\Source\Developer\SourceControl\Public\ISourceControlModule.h).

The other option is to implement your own ISourceControlProvider interface to customize the behavior of the one your project is using.

I hope this can unblock you.