plasticscm

In this section plasticscm module has been described with its classes.

plasticscm.Plastic

class plasticscm.Plastic(url: str = 'http://localhost:9090', *, http_username: str | None = None, http_password: str | None = None, ssl_verify: bool | str | None = True, timeout: int | float | None = None, api_version: str | int | float = '1')

PlasticSCM client API.

Instantiates a new PlasticSCM API wrapper.

Parameters:
  • url – The endpoint of API, in format http://host:port (default: “http://localhost:9090”).

  • timeout – Timeout to use for requests to the PlasticSCM server.

  • api_version – PlasticSCM API version to use (support for 1 only).

classmethod from_config(plastic_id=None, config_files=None)

Create a new PlasticSCM API wrapper from configuration files.

Parameters:
  • plastic_id (str | None) – ID of the configuration section.

  • config_files (list[Path | str] | None) – List of paths to configuration files.

Return type:

Self

Returns:

A PlasticSCM API wrapper.

Raises:

plasticscm.config.PlasticDataError – If the configuration is not correct.

property api_version: str

The API version used (1 only).

property model: ModuleType

Classes of objects provided by the API.

get_cm_location()

Get the path of cm.

Raises:

FileNotFoundError – If cm executable was not found.

Return type:

Path

get_repositories()

Gets all available repositories of a server, along with their information.

Return type:

tuple[Repository, ...]

Returns:

A list of the available repositories.

create_repository(repo_name, *, server=None)

Create a repository in a server.

Parameters:
  • repo_name (str) – The name of the new repository.

  • server (str | None) – The target server where the repository is to be created. If it is omitted or if it is None, the repository will be created in configured API server.

Return type:

Repository

Returns:

The newly created repository will be returned once the operation is completed.

get_repository(repo_name)

Gets the information concerning a single repository.

Parameters:

repo_name (str) – The name of the repository.

Return type:

Repository

Returns:

The desired repository will be returned once the operation is completed.

rename_repository(repo_name, repo_new_name)

Rename a repository.

Parameters:
  • repo_name (str) – The name of the repository to be renamed.

  • repo_new_name (str) – The new name of the repository.

Return type:

Repository

Returns:

The updated repository will be returned once the operation is completed.

delete_repository(repo_name)

Remove a repository from a server.

Parameters:

repo_name (str) – The name of the repository to be removed.

Return type:

None

get_workspaces()

Gets all registered workspaces, along with their information.

Return type:

tuple[Workspace, ...]

Returns:

A list of the all registered workspaces.

create_workspace(wkspace_name, wkspace_path, *, repo_name=None)

Create a new workspace.

Parameters:
  • wkspace_name (str) – The name of the new workspace.

  • wkspace_path (Path) – The absolute path of the new workspace.

  • repo_name (str | None) – The repository of the new workspace.

Return type:

Workspace

Returns:

The newly created workspace will be returned once the operation is completed.

get_workspace(wkspace_name)

Gets the information concerning a single workspace.

Parameters:

wkspace_name (str) – The name of the workspace.

Return type:

Workspace

Returns:

The desired workspace will be returned once the operation is completed.

rename_workspace(wkspace_name, wkspace_new_name)

Rename a workspace.

Parameters:
  • wkspace_name (str) – The name of the workspace to be renamed.

  • wkspace_new_name (str) – The new name of the workspace.

Return type:

Workspace

Returns:

The updated workspace will be returned once the operation is completed.

delete_workspace(wkspace_name)

Remove a workspace.

Parameters:

wkspace_name (str) – The name of the workspace to be removed.

Return type:

None

get_branches(repo_name, *, query=None)

Gets branches in a repository, along with their information.

Parameters:
  • repo_name (str) – The name of the branches’s host repository.

  • query (str | None) – An optional constraints string using the ‘cm find’ command syntax.

Return type:

tuple[Branch, ...]

Returns:

A list of all branches in a repository.

create_branch(repo_name, branch_name, origin_type, origin, *, top_level=False)

Create a new branch.

Parameters:
  • repo_name (str) – The name of the host repository of the new branch.

  • branch_name (str) – The name of the new branch. Do NOT use a hierarchical name.

  • origin_type (ObjectType) – The type of the origin of the branch. It should be ObjectType.CHANGESET, ObjectType.LABEL or ObjectType.BRANCH.

  • origin (str | int) – The point of origin from which the branch will be created.

  • top_level (bool) – Whether or not the branch will be top-level - i.e. it will have no parent (default: False).

Return type:

Branch

Returns:

The newly created branch will be returned once the operation is completed.

get_branch(repo_name, branch_name)

Gets information about a single branch in a repository.

Parameters:
  • repo_name (str) – The repository hosting the desired branch.

  • branch_name (str) – The name of the desired branch. Please note that branch names are hierarchical (e.g. “main/task001/task002”).

Return type:

Branch

Returns:

The desired branch will be returned once the operation is completed.

rename_branch(repo_name, branch_name, branch_new_name)

Rename a branch.

Parameters:
  • repo_name (str) – The name of the host repository of the branch.

  • branch_name (str) – The hierarchical name of the branch to be renamed. Please note that branch names are hierarchical (e.g. “main/task001/task002”).

  • branch_new_name (str) – The new name of the branch. Please have in mind that the hierarchy name can not be changed.

Return type:

Branch

Returns:

The updated branch will be returned once the operation is completed.

delete_branch(repo_name, branch_name)

Remove a branch.

Parameters:
  • repo_name (str) – The name of the host repository of the branch

  • branch_name (str) – The name of the branch to be removed. Please note that branch names are hierarchical (e.g. “main/task001/task002”).

Return type:

None

get_labels(repo_name, *, query=None)

Gets labels in a repository, along with their information.

Parameters:
  • repo_name (str) – The name of the host repository of the labels.

  • query (str | None) – An optional constraints string using the ‘cm find’ command syntax.

Return type:

tuple[Label, ...]

Returns:

A list of all labels in a repository.

create_label(repo_name, label_name, changeset_id, *, comment=None, apply_to_xlinks=False)

Create a new label and applies it to a given changeset.

Parameters:
  • repo_name (str) – The name of the future host repository.

  • label_name (str) – The name of the new label.

  • changeset_id (int) – The changeset to label.

  • comment (str | None) – The comment to add to the label.

  • apply_to_xlinks (bool) – If True, all xlinked changesets present in the specified changeset tree will be labelled as well (default: False).

Return type:

Label

Returns:

The newly created label will be returned once the operation is completed.

get_label(repo_name, label_name)

Gets information about a single label.

Parameters:
  • repo_name (str) – The name of the host repository of the label.

  • label_name (str) – The name of the label.

Return type:

Label

Returns:

The desired label will be returned once the operation is completed.

rename_label(repo_name, label_name, label_new_name)

Rename a label.

Parameters:
  • repo_name (str) – The name of the host repository of the label.

  • label_name (str) – The name of the label to be renamed.

  • label_new_name (str) – The new name of the label.

Return type:

Label

Returns:

The updated label will be returned once the operation is completed.

delete_label(repo_name, label_name)

Remove a label.

Parameters:
  • repo_name (str) – The name of the host repository of the label.

  • label_name (str) – The name of the label to be removed.

Return type:

None

get_changesets(repo_name, *, query=None)

Gets changesets in a repository, along with their information.

Parameters:
  • repo_name (str) – The name of the host repository of the changesets.

  • query (str | None) – An optional constraints string using the ‘cm find’ command syntax.

Return type:

tuple[Changeset, ...]

Returns:

A list of all changesets in a repository.

get_changesets_in_branch(repo_name, branch_name, *, query=None)

Gets changesets in a given branch, along with their information.

Parameters:
  • repo_name (str) – The name of the host repository of the branch.

  • branch_name (str) – The hierarchical name of the host branch. Please note that branch names are hierarchical (e.g. “main/task001/task002”).

  • query (str | None) – An optional constraints string using the ‘cm find’ command syntax.

Return type:

tuple[Changeset, ...]

Returns:

A list of all changesets in a given branch.

get_changeset(repo_name, changeset_id)

Gets information about a single changeset.

Parameters:
  • repo_name (str) – The name of the host repository of the changeset.

  • changeset_id (int) – The id of the changeset.

Return type:

Changeset

Returns:

The desired changeset will be returned once the operation is completed.

get_pending_changes(wkspace_name, *, change_types=None)

Gets pending changes in a workspace, along with their information.

Parameters:
  • wkspace_name (str) – The name of the workspace.

  • change_types (list[Type] | None) – A list detailing the desired change types. It should be a list of Change.Type’s values (default: all change types).

Return type:

tuple[Change, ...]

Returns:

A list of all penging changes of the desired change types.

undo_pending_changes(wkspace_name, paths)

Deletes the pending changes in a workspace.

Paths must be a list of paths representing files with pending changes to be undone.

Parameters:
  • wkspace_name (str) – The name of the workspace.

  • paths (list[str | Path]) – A list of file paths with pending changes to be undone. They can be either full paths or workspace-relative paths.

Return type:

AffectedPaths

Returns:

The paths that were affected by the undo operation.

get_workspace_update_status(wkspace_name)

Gets the status of the last workspace update operation.

Parameters:

wkspace_name (str) – The name of the workspace.

Return type:

OperationStatus

Returns:

The status of the last workspace update operation.

update_workspace(wkspace_name)

Update the workspace and download latest changes.

Parameters:

wkspace_name (str) – The name of the workspace.

Return type:

OperationStatus

Returns:

The status of the workspace update operation.

get_workspace_switch_status(wkspace_name)

Gets the status of the last workspace switch operation.

Parameters:

wkspace_name (str) – The name of the workspace.

Return type:

OperationStatus

Returns:

The status of the last workspace switch operation.

switch_workspace(wkspace_name, object_type, object)

Switch the workspace to a branch, changeset or label.

Parameters:
  • wkspace_name (str) – The name of the workspace.

  • object_type (ObjectType) – The type of switch destination. It should be ObjectType.CHANGESET, ObjectType.LABEL or ObjectType.BRANCH.

  • object (str | int) – The target point the workspace will be set to. It should be (according to object_type) the changeset id, the label name or the branch name.

Return type:

OperationStatus

Returns:

The status of the workspace switch operation.

get_workspace_checkin_status(wkspace_name)

Gets the status of the last workspace checkin operation.

Parameters:

wkspace_name (str) – The name of the workspace.

Return type:

CheckinStatus

Returns:

The status of the last workspace checkin operation.

checkin_workspace(wkspace_name, *, paths=None, comment=None, recurse=True)

Stores changes in the repository.

Parameters:
  • wkspace_name (str) – The name of the workspace.

  • paths (list[str] | None) – The list of target paths to be checked in. Set to the workspace root if empty or not present.

  • comment (str | None) – The checkin comment.

  • recurse (bool) – If set to True, directories present in the paths parameter will have their children recursively checked in. If paths is empty or not present, its value is overridden to True (default: True).

Return type:

CheckinStatus

Returns:

The status of the workspace checkin operation.

get_item(repo_name, item_path)

Gets information about a single item in a repository.

Parameters:
  • repo_name (str) – The name of the repository.

  • item_path (str) – The path of selected item.

Return type:

Item

Returns:

The desired item will be returned once the operation is completed.

get_item_in_branch(repo_name, branch_name, item_path)

Gets information about a single item in the desired branch.

Parameters:
  • repo_name (str) – The name of the host repository of the branch.

  • branch_name (str) – The name of the branch. Please note that branch names are hierarchical (e.g. “main/task001/task002”).

  • item_path (str) – The path of selected item.

Return type:

Item

Returns:

The desired item will be returned once the operation is completed.

get_item_in_changeset(repo_name, changeset_id, item_path)

Gets information about a single item in the desired changeset.

Parameters:
  • repo_name (str) – The name of the host repository of the changeset.

  • changeset_id (int) – The id of the changeset.

  • item_path (str) – The path of selected item.

Return type:

Item

Returns:

The desired item will be returned once the operation is completed.

get_item_in_label(repo_name, label_name, item_path)

Gets information about a single item in the desired label.

Parameters:
  • repo_name (str) – The name of the host repository of the label.

  • label_name (str) – The name of the label.

  • item_path (str) – The path of selected item.

Return type:

Item

Returns:

The desired item will be returned once the operation is completed.

get_item_revision(repo_name, revision_spec)

Load a single item’s revision in the workspace and gets information about it.

Parameters:
  • repo_name (str) – The name of the repository.

  • revision_spec (str) – Specification of the selected revision.

Return type:

Item

Returns:

The desired item’s revision will be returned once the operation is completed.

get_item_revision_history_in_branch(repo_name, branch_name, item_path)

Gets the item’s revision history for a given branch.

Parameters:
  • repo_name (str) – The name of the host repository of the branch.

  • branch_name (str) – The name of the branch. Please note that branch names are hierarchical (e.g. “main/task001/task002”).

  • item_path (str) – The path of selected item.

Return type:

tuple[RevisionHistoryItem, ...]

Returns:

A list of all item’s revision history items for a given branch.

get_item_revision_history_in_changeset(repo_name, changeset_id, item_path)

Gets the item’s revision history for a given changeset.

Parameters:
  • repo_name (str) – The name of the host repository of the changeset.

  • changeset_id (int) – The id of the changeset.

  • item_path (str) – The path of selected item.

Return type:

tuple[RevisionHistoryItem, ...]

Returns:

A list of all item’s revision history items for a given changeset.

get_item_revision_history_in_label(repo_name, label_name, item_path)

Gets the item’s revision history for a given label.

Parameters:
  • repo_name (str) – The name of the host repository of the label.

  • label_name (str) – The name of the label.

  • item_path (str) – The path of selected item.

Return type:

tuple[RevisionHistoryItem, ...]

Returns:

A list of all item’s revision history items for a given label.

diff_changesets(repo_name, changeset_id, source_changeset_id)

Gets the differences between the source changeset and the desired changeset.

Parameters:
  • repo_name (str) – The name of the host repository of the changesets.

  • changeset_id (int) – The id of the changeset.

  • source_changeset_id (int) – The id of the source changeset.

Return type:

tuple[Diff, ...]

Returns:

A list of all differences between the source changeset and the desired changeset.

diff_changeset(repo_name, changeset_id)

Gets the differences between the parent changeset and the desired changeset.

Parameters:
  • repo_name (str) – The name of the host repository of the changeset.

  • changeset_id (int) – The id of the changeset.

Return type:

tuple[Diff, ...]

Returns:

A list of all differences between the parent changeset and the desired changeset.

diff_branch(repo_name, branch_name)

Gets the differences between the current branch and the desired branch.

Parameters:
  • repo_name (str) – The name of the host repository of the branch.

  • branch_name (str) – The name of the branch. Please note that branch names are hierarchical (e.g. “main/task001/task002”).

Return type:

tuple[Diff, ...]

Returns:

A list of all differences between the current branch and the desired branch.

add_workspace_item(wkspace_name, item_path, *, add_parents=True, checkout_parent=True, recurse=True)

Add an item to version control.

Parameters:
  • wkspace_name (str) – The name of the workspace.

  • item_path (str) – The path of the item to be added.

  • add_parents (bool) – If True, the command will add any parent directories which are not under version control yet (default: True).

  • checkout_parent (bool) – If True, the parent node of the selected item will be checked out as a result (default: True).

  • recurse (bool) – If True, causes all the children items to be recursively added (default: True).

Return type:

AffectedPaths

Returns:

The paths that were affected by the addition operation.

checkout_workspace_item(wkspace_name, item_path)

Mark workspace item as ready to modify.

Parameters:
  • wkspace_name (str) – The name of the workspace.

  • item_path (str) – The path of selected item.

Return type:

AffectedPaths

Returns:

The paths that were affected by the checkout operation.

move_workspace_item(wkspace_name, item_path, dest_item_path)

Move or rename a file or directory in the workspace.

Parameters:
  • wkspace_name (str) – The name of the workspace.

  • item_path (str) – Source path of selected item.

  • dest_item_path (str) – Destination path to move the selected item (e.g. “src/bar.c”).

Return type:

AffectedPaths

Returns:

The paths that were affected by the movement operation.