Workspace

Wraps a Plastic SCM workspace with operations for branching, changeset switching, source control (checkout, check-in, add, undo), change detection, and link management (xlinks and symlinks).

Definition

Namespace: Paragon.Editor.ModuleManager.Plastic Assembly: Paragon.Editor.dll

internal class Workspace : IEquatable<Workspace>

Implements: IEquatable<Workspace>

Remarks

Workspace is the most feature-rich class in the PlasticSCM subsystem. It wraps Plastic SCM's WorkspaceInfo and provides two categories of operations:

  1. Standard source control — checkout, check-in, add, branch switching, change detection, undo

  2. Link management — creating/modifying/removing xlinks and symlinks (used by the module mounting system)

Command Execution

Some operations (xlink creation/modification, symlink creation) are not available through the Plastic SCM API and are instead executed via the cm CLI using CmdRunner.ExecuteCommandWithResult. On macOS/Unix, the cm binary is resolved to /usr/local/bin/cm as a platform workaround.

Change Detection

GetChanges() uses WorkspaceStatusOptions flags to control what types of changes are detected. The default options (default_change_options) include:

  • FindAllControlledChanges — modified tracked files

  • FindAllLocalChanges — locally changed files

  • FindPrivates — untracked private files

Changes can be filtered by a base path, which checks if each change's path is a subdirectory of the specified path.

Equality

Two workspaces are equal if their WorkspaceInfo instances are equal. GetHashCode() is based on the Path string.

Quick Lookup

Goal
How

Get workspace name

workspace.Name

Get workspace path

workspace.Path

Get parent repository

workspace.Repository

Get current branch

workspace.GetCurrentBranch()

Switch branch

workspace.SwitchBranch("/main/dev")

Get current changeset

workspace.GetCurrentChangeset()

Switch changeset

workspace.SwitchChangeset(changesetId)

Checkout files

workspace.Checkout("file1.cs", "file2.cs")

Check in files

workspace.CheckIn("Fix bug", "file1.cs")

Add files

workspace.Add("newfile.cs")

Check for changes

workspace.HasChanges()

Get all changes

workspace.GetChanges()

Undo all changes

workspace.UndoAllChanges()

Create xlink

workspace.CreateXlink(path, relPath, changeset, repo)

Modify xlink

workspace.ModifyXlink(path, relPath, changeset, repo)

Create symlink

workspace.CreateSymlink(source, mount)

Remove any link

workspace.RemoveLink(linkPath)

Check for xlink

workspace.HasXlink(path)

Try get xlink

workspace.TryGetXlink(path, out xlink)

List all xlinks

workspace.GetAllXlinks()

Properties

Property
Type
Access
Description

Info

WorkspaceInfo

public

Raw Plastic SCM workspace info

Repository

Repository

public

The parent repository

Name

string

public

Workspace name

Path

string

public

Workspace client path (filesystem root)

Constructors

Workspace(Repository, WorkspaceInfo)

Creates a workspace wrapper linked to its parent repository.

Methods

Branch Operations

GetCurrentBranch

Returns the current working branch for this workspace.

SwitchBranch

Switches the workspace to the specified branch (by name).

Changeset Operations

GetCurrentChangeset

Returns the changeset currently loaded in the workspace.

SwitchChangeset

Updates the loaded changeset ID for the workspace.

Source Control Operations

Checkout

Checks out the specified paths for editing.

CheckIn

Checks in the specified paths with a comment. Uses CheckinFlags.Full | CheckinFlags.ProcessSymlinks.

Add

Adds untracked paths to source control. Automatically adds private parent directories.

Change Detection

HasChanges

Returns true if the workspace has any changes matching the specified options.

GetChanges

Returns all changes matching the specified options, optionally filtered to a base path.

UndoAllChanges

Reverts all changes matching the specified options.

Creates a Plastic SCM cross-repository link. If a deleted xlink exists at the path, undoes the deletion instead.

Modifies an existing xlink. Throws InvalidOperationException if no xlink exists at the path.

Creates a filesystem symbolic link via the ln -s command.

Removes an xlink or symlink at the specified path. For xlinks, uses Plastic API's DeleteControlled. For symlinks, deletes the directory. Also cleans up .meta files.

Query xlinks in the workspace.

Constants

Constant
Type
Description

default_change_options

WorkspaceStatusOptions

FindAllControlledChanges | FindAllLocalChanges | FindPrivates

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation
circle-exclamation
circle-exclamation

See Also

Last updated