SourceControl.RevertUnsaved.Enable

SourceControl.RevertUnsaved.Enable

#Overview

name: SourceControl.RevertUnsaved.Enable

This variable is created as a Console Variable (cvar).

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of SourceControl.RevertUnsaved.Enable is to allow a Source Control ‘Revert’ operation to be triggered on an unsaved asset. This setting variable is primarily used in the source control system of Unreal Engine 5.

Based on the callsites, this variable is utilized in several Unreal Engine subsystems and modules:

  1. The AssetManagerEditor plugin
  2. The SceneOutliner module
  3. The SourceControlWindows module

The value of this variable is set in the SourceControlCVars.cpp file, where it’s initialized as a console variable with a default value of false.

The variable interacts with its associated variable CVarSourceControlEnableRevertUnsaved, which is defined in the SourceControlCVars namespace. They share the same value and purpose.

Developers must be aware that this variable controls whether unsaved assets can be reverted through source control operations. When enabled, it allows potentially destructive actions on assets that haven’t been saved, which could lead to loss of work if not used carefully.

Best practices when using this variable include:

  1. Keep it disabled by default to prevent accidental loss of unsaved work.
  2. Enable it only when necessary and ensure all team members are aware of its implications.
  3. Use it in conjunction with proper backup and version control practices.
  4. Consider implementing additional safeguards or confirmation dialogs when this feature is enabled.

Regarding the associated variable CVarSourceControlEnableRevertUnsaved:

The purpose of CVarSourceControlEnableRevertUnsaved is the same as SourceControl.RevertUnsaved.Enable. It’s a C++ representation of the console variable in the engine’s source code.

This variable is defined in the SourceControlCVars namespace and is used internally by the engine to control the behavior of the ‘Revert’ operation on unsaved assets.

The value of this variable is set when the console variable SourceControl.RevertUnsaved.Enable is initialized or changed.

Developers should be aware that modifying this variable directly in C++ code will affect the behavior of the source control system for unsaved assets.

Best practices for using CVarSourceControlEnableRevertUnsaved include:

  1. Avoid modifying it directly in code unless absolutely necessary.
  2. Use the console variable SourceControl.RevertUnsaved.Enable to control its value instead.
  3. If used in code, ensure proper synchronization with the console variable to maintain consistency.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Developer/SourceControl/Private/SourceControlCVars.cpp:17

Scope (from outer to inner):

file
namespace    SourceControlCVars

Source code excerpt:


	TAutoConsoleVariable<bool> CVarSourceControlEnableRevertUnsaved(
		TEXT("SourceControl.RevertUnsaved.Enable"),
		false,
		TEXT("Allows a SourceControl 'Revert' operation to be triggered on an unsaved asset."),
		ECVF_Default);

	TAutoConsoleVariable<bool> CVarSourceControlEnableLoginDialogModal(
		TEXT("SourceControl.LoginDialog.ForceModal"),

#Loc: <Workspace>/Engine/Plugins/Editor/AssetManagerEditor/Source/AssetManagerEditor/Private/AssetSourceControlContextMenu.cpp:986

Scope (from outer to inner):

file
function     bool FAssetSourceControlContextMenuState::AllowExecuteSCCRevertUnsaved

Source code excerpt:

bool FAssetSourceControlContextMenuState::AllowExecuteSCCRevertUnsaved() const
{
	if (IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("SourceControl.RevertUnsaved.Enable")))
	{
		return CVar->GetBool();
	}
	else
	{
		return false;

#Loc: <Workspace>/Engine/Source/Editor/SceneOutliner/Private/SceneOutlinerSCCHandler.cpp:107

Scope (from outer to inner):

file
function     bool FSceneOutlinerSCCHandler::AllowExecuteSourceControlRevertUnsaved

Source code excerpt:

bool FSceneOutlinerSCCHandler::AllowExecuteSourceControlRevertUnsaved() const
{
	if (IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("SourceControl.RevertUnsaved.Enable")))
	{
		return CVar->GetBool();
	}
	else
	{
		return false;

#Loc: <Workspace>/Engine/Source/Editor/SourceControlWindows/Private/SSourceControlRevert.cpp:87

Scope (from outer to inner):

file
function     static bool IsRevertUnsavedEnabled

Source code excerpt:

static bool IsRevertUnsavedEnabled()
{
	if (IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("SourceControl.RevertUnsaved.Enable")))
	{
		return CVar->GetBool();
	}
	else
	{
		return false;

#Associated Variable and Callsites

This variable is associated with another variable named CVarSourceControlEnableRevertUnsaved. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Developer/SourceControl/Private/SourceControlCVars.cpp:16

Scope (from outer to inner):

file
namespace    SourceControlCVars

Source code excerpt:

		ECVF_Default);

	TAutoConsoleVariable<bool> CVarSourceControlEnableRevertUnsaved(
		TEXT("SourceControl.RevertUnsaved.Enable"),
		false,
		TEXT("Allows a SourceControl 'Revert' operation to be triggered on an unsaved asset."),
		ECVF_Default);

	TAutoConsoleVariable<bool> CVarSourceControlEnableLoginDialogModal(

#Loc: <Workspace>/Engine/Source/Developer/SourceControl/Private/SourceControlCVars.h:9

Scope (from outer to inner):

file
namespace    SourceControlCVars

Source code excerpt:

	extern TAutoConsoleVariable<bool> CVarSourceControlEnableRevertFromSceneOutliner;
	extern TAutoConsoleVariable<bool> CVarSourceControlEnableRevertFromSubmitWidget;
	extern TAutoConsoleVariable<bool> CVarSourceControlEnableRevertUnsaved;
	extern TAutoConsoleVariable<bool> CVarSourceControlEnableLoginDialogModal;
}