ScriptSubversion

class ScriptSubversion.Subversion

Bases: object

Scripting functionality for the “CODESYS SVN” plugin. An instance of this interface is injected into the default namespace under the name “svn”.

Note

Only available if the “CODESYS SVN” Plugin is installed!

property offline_mode

Gets a value indicating whether Subversion is in offline_mode.

Return type:

bool

Returns:

True if offline_mode; otherwise False.

set_offline_mode(mode: bool, revalidate_locks: bool = True)

Sets the offline mode.

Parameters:
  • mode (bool) – The offline mode to set.

  • revalidate_locks (bool) – if set to True, all locks in the primary project are revalidated. This parameter is optional, the default is True.

Note

Script should honor the offline mode set by the user, and maybe they should change it back at the end of the script.

checkout(url: Uri, project_path: str, project_name: str, revision: DateTime, as_library: bool, as_primary_project: bool = True, omit_externals: bool = True)

Checks out a project of the given repository url.

Parameters:
  • url (Uri) – The URL.

  • project_path (str) – The path to check out the new project.

  • project_name (str) – The name of the checked out project.

  • revision (DateTime) – The revision.

  • as_primary_project (bool) – If set to True, the project is checked out as primary project. This parameter is optional, the default is True.

  • omit_externals (bool) – if set to True, externals are omitted. This parameter is optional, the default is False.

  • as_library (bool) – if set to True, the project is checked out as library project.

Return type:

ScriptProject

Returns:

The created project.

get_log(remote_uri: object, revisions: Optional[object] = None, limit: int = 0, stop_on_copy: bool = True, retrieve_all_properties: bool = False)

Gets the log for a given Url.

Parameters:
  • remote_uri (object) – The remote Url. This can either be a string or an Uri object.

  • revisions (object) – The revisions we want to get the log for. If you pass None, no revision filtering happens at all. If you pass -1, the Head Revision is fetched. If you pass a single integer or DateTime, that revision is fetched. If you pass a python slice of integer or DateTime, that range is fetched. If you pass a sequence of revisions or slices, the combination of all the items is fetched.

  • limit (int) – The maximum number of revisions to fetch. Pass 0 for unlimited.

  • stop_on_copy (bool) – if set to True, stop on copies.

  • retrieve_all_properties (bool) – if set to True, retrieve all revision properties. If set to False, only revision properties considered standard by svn (log message, author, date…) are fetched.

Return type:

list[LogInfo]

Returns:

A sequence of loginfos.

Note

For revision slice objects, use the python builtin constructor: slice(start, stop). The order of start and stop is relevant in combination with limit, to determine whether the first or last {limit} entries of the slice are returned. Currently, steps for slices are not supported.

auth_username_password(eventargs: UsernamePasswordAuthenticationRequest)

[Delegate] Request a username and a password for authentication. Currently comes with an AuthenticationRequest.type of SvnAuthenticationType.UsernamePassword to request a username and a password.

Note

All event handlers will be unsubscribed on the end of script execution.

auth_username(eventargs: UserNameAuthenticationRequest)

[Delegate] Request a username for authentication. Comes with an AuthenticationRequest.type of SvnAuthenticationType.Username

Note

All event handlers will be unsubscribed on the end of script execution.

auth_password(eventargs: PasswordAuthenticationRequest)

[Delegate] Request a password for authentication. Currently comes with an AuthenticationRequest.type of SvnAuthenticationType.SslClientCertificatePassword to request the passphrase to unlock a client certificate.

Note

All event handlers will be unsubscribed on the end of script execution.

auth_certificate(eventargs: ClientCertificateRequest)

[Delegate] Request a client certificate for authentication. Currently comes with an AuthenticationRequest.type of SvnAuthenticationType.SslClientCertificate to request a certificate file name.

Note

All event handlers will be unsubscribed on the end of script execution.

auth_servertrust(eventargs: ServerTrustRequest)

[Delegate] Request verification of trust for the server certificate. Currently comes with an AuthenticationRequest.type of SvnAuthenticationType.SslServerTrust to request trust for a server certificate.

Note

All event handlers will be unsubscribed on the end of script execution.

working_set_modified(eventargs: SelectionModificationArgs)

[Delegate] Occurs when the working set of a Subversion operation was modifed due to consistency constraints between several objects. Such constraints can be enforced by plugins. One example is that, for renamed objects, the old and new location can be committed or reverted only together.

Note

Simple scripts can simply ingore this events. One possible use case is to abort the operation by throwing an exception when objects were suppressed by plugins, in other words, SelectionModificationArgs.objects_were_removed is true.

working_set_modification_conflict(eventargs: SelectionModificationConflictArgs)

[Delegate] Occurs when the attempts to modify the working set of a Subversion operation due to consistency constraints between several objects failed due to a conflict. In other words, one plugin wants to select an object which a different plugin wants to deselect at the same time.

Note

Subscribing a handler to this event normally suppresses the dialog shown in such occasions (and all other handlers installed by other plugins) if the handler does not set the ISelectionModificationConflictArgs.handled flag to false. So subscribing an empty function to this event is a simple method to suppress the user dialog. After this handler is called, a System.InvalidOperationException is thrown if the handler does not throw its own exception.

property default_conflict_resolution_mode

Gets or sets the global default conflict resolution mode.

Note

Setting this value to SvnConflictResolutionMode.Default will restore the implementation default settings of the current version.

Return type:

SvnConflictResolutionMode

Returns:

The resolution mode.

property default_auto_locking_mode

Gets or sets the global default auto locking mode.

Note

Setting this value to SvnAutoLockingMode.Default will restore the implementation default settings of the current version.

Return type:

SvnAutoLockingMode

property default_conflict_resolution_use_markers

Gets or sets the default whether conflict resolution allows conflict markers.

Note

Some mergers allow the insertion of “conflict markers” into the merged objects. If this option is set, and the object contains some unmergeable conflicts, those conflicts are then represented by those conflict markers int the source code, and the object itsself is marked as successfully merged. Example:

Return type:

SvnConflictUseMarkerMode

Returns:

The default conflict resolution markers setting.

force_credentials(username: Optional[str] = None, password: Optional[str] = None)

Forces a specific userName and password for all future operations, overriding the cache.

Note

Instead of consulting the password cache / storage, the given username and password are tried. If those fail, interactive prompting is used. This is a global option, it influences all SVN operations, including background checks, repository browser etc. To prevent unintended side effects, overriding should be enabled only for very short timeframes. At the end of the script execution, the forcing of credentials will be automatically reset back.

auth_sshtrust(eventargs: SshTrustRequest)

[Delegate] Request verification of trust for the server certificate. Currently comes with an AuthenticationRequest.type of SvnAuthenticationType.SshServerTrust to request trust for a server certificate.

Note

All event handlers will be unsubscribed on the end of script execution.

class ScriptSubversion.LogInfo

Bases: object

Svn log info.

Note

Only available if the CODESYS SVN Plugin is installed!

property url

Gets the URL.

Return type:

Uri

property author

Gets the author.

Return type:

str

property message

Gets the commit message.

Return type:

str

property revision

Gets the revision.

Return type:

int

property time

Gets the time.

Return type:

DateTime

property changes

Gets the changes.

Return type:

list[ChangeItem]

property properties

Gets the revision properties. The keys are strings, the values are either strings (for text properties) or bytes (for binary properties).

Return type:

Dictionary(object, object)

class ScriptSubversion.ChangeItem

Bases: object

Item describing a single change in a svn log info instance.

Note

Only available if the CODESYS SVN Plugin is installed!

property path

Gets the path (relative to the repo root)

Return type:

str

property url

Gets the URL (absolute).

Return type:

Uri

property action

Gets the action.

Return type:

SvnChangeAction

property copy_from_path

Gets the copy_from_path or None if no copy.

Return type:

str

property copy_from_revision

Gets the copy_from_revision or None if no copy.

Return type:

int

class ScriptSubversion.SelectionModificationArgs

Bases: object

The exact description of the modifiation of the selection in the ISubversion4.working_set_modified event.

property action

Gets the action whose working set was modified.

Return type:

SvnSelectionVerificationAction

property objects_were_removed

Gets a value indicating whether objects were removed from the working set.

Note

Using this boolean to check whether objects were removed is more efficient than checking the length of removed_objects.

Return type:

bool

Returns:

True if objects were removed; otherwise, False.

property objects_were_added

Gets a value indicating whether objects were added to the working set.

Note

Using this boolean to check whether objects were added is more efficient than checking the length of added_objects.

Return type:

bool

Returns:

True if objects were added; otherwise, False.

property result

Gets the final list of objects, the result of the hooks operation.

Return type:

list[object]

property original_objects

Gets the original list of objects.

Return type:

list[object]

property removed_objects

Gets the removed objects.

Return type:

list[object]

property added_objects

Gets the added objects.

Return type:

list[object]

class ScriptSubversion.SelectionModificationConflictArgs

Bases: object

property action

The action which caused the conflict.

Return type:

SvnSelectionVerificationAction

property conflicting_candidate

Gets the conflicting candidate, this is the object which the first hook wants to select, and the second hook wants to deselect.

Return type:

object

property reason_for_selection

This is the reason why the first hook wants to select the conflicting_candidate.

Return type:

str

property object_causing_selection

This is the object causing the first hook to select the conflicting_candidate.

Return type:

object

property reason_for_deselection

This is the reason why the second hook wants to deselect the conflicting_candidate.

Return type:

str

property object_causing_deselection

This is the object causing the second hook to deselect the conflicting_candidate.

Return type:

object

property handled

Gets or sets a value indicating whether this SelectionModificationConflictArgs is handled. This is set to true by default, which suppresses all other handlers installed by the system for this event (including the UI popup). You can set it to false to let the system call those other handlers.

Return type:

bool

Returns:

True if handled; otherwise, False.