unreal.SourceControl

class unreal.SourceControl(outer: Object | None = None, name: Name | str = 'None')

Bases: Object

Editor source control common functionality. note: Many of these source control methods use smart file strings which can be one of: - fully qualified path - relative path - long package name - asset path - export text path (often stored on clipboard) For example: - D:EpicDev-EntProjectsPython3rdBPContentMannequinAnimationsThirdPersonIdle.uasset - ContentMannequinAnimationsThirdPersonIdle.uasset - /Game/Mannequin/Animations/ThirdPersonIdle - /Game/Mannequin/Animations/ThirdPersonIdle.ThirdPersonIdle - AnimSequence’/Game/Mannequin/Animations/ThirdPersonIdle.ThirdPersonIdle’

C++ Source:

  • Module: SourceControl

  • File: SourceControlHelpers.h

classmethod async_query_file_state(file_state_callback, file, silent=False) None

Query the source control state of the specified file, asynchronously.

Parameters:
  • file_state_callback (QueryFileStateDelegate) – Source control state - see USourceControlState. It will have bIsValid set to false if it could not have its values set.

  • file (str) – The file to query - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

classmethod check_in_file(file, description, silent=False, keep_checked_out=False) bool

Use currently set source control provider to check in a file. note: Blocks until action is complete.

Parameters:
  • file (str) – The file to check in - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • description (str) – Description for check in

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

  • keep_checked_out (bool) – Keep files checked-out after checking in. This is helpful for maintaining “ownership” of files if further operations are needed.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod check_in_files(files, description, silent=False, keep_checked_out=False) bool

Use currently set source control provider to check in specified files. note: Blocks until action is complete.

Parameters:
  • files (Array[str]) – Files to check out - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • description (str) – Description for check in

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

  • keep_checked_out (bool) – Keep files checked-out after checking in. This is helpful for maintaining “ownership” of files if further operations are needed.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod check_out_file(file, silent=False) bool

Use currently set source control provider to check out a file. note: Blocks until action is complete.

Parameters:
  • file (str) – The file to check out - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod check_out_files(files, silent=False) bool

Use currently set source control provider to check out specified files. note: Blocks until action is complete.

Parameters:
  • files (Array[str]) – Files to check out - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod check_out_or_add_file(file, silent=False) bool

Use currently set source control provider to check out file or mark it for add. note: Blocks until action is complete.

Parameters:
  • file (str) – The file to check out/add - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod check_out_or_add_files(files, silent=False) bool

Use currently set source control provider to check out files or mark them for add. note: Blocks until action is complete.

Parameters:
  • files (Array[str]) – The files to check out/add - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod copy_file(source_file, dest_file, silent=False) bool

Use currently set source control provider to copy a file. note: Blocks until action is complete.

Parameters:
  • source_file (str) – Source file string to copy from - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • dest_file (str) – Source file string to copy to - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard). If package, then uses same extension as source file.

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod current_provider() str

Determine the name of the current source control provider.

Returns:

the name of the current source control provider. If one is not set then “None” is returned.

Return type:

str

classmethod is_available() bool

Quick check if currently set source control provider is enabled and available for use (server-based providers can use this to return whether the server is available or not)

Returns:

true if source control is available, false if it is not

Return type:

bool

classmethod is_enabled() bool

Determine if there is a source control system enabled

Returns:

true if enabled, false if not

Return type:

bool

classmethod last_error_msg() Text

Get status text set by SourceControl system if an error occurs regardless whether bSilent is set or not. Only set if there was an error.

Return type:

Text

classmethod mark_file_for_add(file, silent=False) bool

Use currently set source control provider to mark a file for add. Does nothing (and returns true) if the file is already under SC note: Blocks until action is complete.

Parameters:
  • file (str) – The file to add - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod mark_file_for_delete(file, silent=False) bool

Use currently set source control provider to remove file from source control and delete the file. note: Blocks until action is complete.

Parameters:
  • file (str) – The file to delete - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod mark_files_for_add(files, silent=False) bool

Use currently set source control provider to mark files for add. Does nothing (and returns true) for any file that is already under SC note: Blocks until action is complete.

Parameters:
  • files (Array[str]) – Files to check out - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod mark_files_for_delete(files, silent=False) bool

Use currently set source control provider to remove files from source control and delete the files. note: Blocks until action is complete.

Parameters:
  • files (Array[str]) –

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod query_file_state(file, silent=False) SourceControlState

Use currently set source control provider to query a file’s source control state. note: Blocks until action is complete.

Parameters:
  • file (str) – The file to query - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

Source control state - see USourceControlState. It will have bIsValid set to false if it could not have its values set.

Return type:

SourceControlState

classmethod revert_and_reload_packages(packages_to_revert, revert_all=False, reload_world=False) bool

Reverts the provided files then reloads packages.

Parameters:
  • packages_to_revert (Array[str]) – The packages to revert

  • revert_all (bool) – Whether to revert all files

  • reload_world (bool) – Reload the world

Returns:

true if succeeded.

Return type:

bool

classmethod revert_file(file, silent=False) bool

Use currently set source control provider to revert a file regardless whether any changes will be lost or not. note: Blocks until action is complete.

Parameters:
  • file (str) – The file to revert - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod revert_files(files, silent=False) bool

Use currently set source control provider to revert files regardless whether any changes will be lost or not. note: Blocks until action is complete.

Parameters:
  • files (Array[str]) – Files to revert - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod revert_unchanged_file(file, silent=False) bool

Use currently set source control provider to revert a file provided no changes have been made. note: Blocks until action is complete.

Parameters:
  • file (str) – File to check out - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod revert_unchanged_files(files, silent=False) bool

Use currently set source control provider to revert files provided no changes have been made. note: Blocks until action is complete.

Parameters:
  • files (Array[str]) – Files to check out - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod sync_file(file, silent=False) bool

Use currently set source control provider to sync a file or directory to the head revision. note: Blocks until action is complete.

Parameters:
  • file (str) – The file or directory to sync - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool

classmethod sync_files(files, silent=False) bool

Use currently set source control provider to sync files or directories to the head revision. note: Blocks until action is complete.

Parameters:
  • files (Array[str]) – Files or directories to sync - can be either fully qualified path, relative path, long package name, asset path or export text path (often stored on clipboard)

  • silent (bool) – if false (default) then write out any error info to the Log. Any error text can be retrieved by LastErrorMsg() regardless.

Returns:

true if succeeded, false if failed and can call LastErrorMsg() for more info.

Return type:

bool