AcUtils
A high performance abstraction layer for AccuRev
Public Member Functions | Private Member Functions | List of all members
AcUtils.AcWorkspaces Class Reference

A container of AcWorkspace objects that define AccuRev workspaces in the repository. More...

Collaboration diagram for AcUtils.AcWorkspaces:
Collaboration graph
[legend]

Public Member Functions

AcDepot getDepot (string name)
 Get the AcDepot object that workspace name is located in. More...
 
AcWorkspace getWorkspace (AcDepot depot, int ID)
 Get the AcWorkspace object in depot with workspace ID number. More...
 
AcWorkspace getWorkspace (string name)
 Get the AcWorkspace object for workspace name. More...
 
Two-part object construction:
 AcWorkspaces (AcDepots depots, bool allWSpaces, bool includeHidden, bool includeRefTrees=false)
 A container of AcWorkspace objects that define AccuRev workspaces in the repository. More...
 
async Task< bool > initAsync (AcDepot depot=null)
 Populate this container with AcWorkspace objects as per constructor parameters. More...
 

Private Member Functions

async Task< AcResultgetWorkspacesXMLAsync ()
 Get the list of workspaces in XML for all or the current user and optionally include inactive workspaces as per AcWorkspaces constructor includeHidden parameter. More...
 
async Task< AcResultgetReferenceTreesXMLAsync ()
 Get the list of reference trees in XML and optionally include those that are inactive as per AcWorkspaces constructor includeHidden parameter. More...
 
bool storeWSpaces (AcResult result, AcDepot depot=null)
 Convert AcResult.CmdResult XML from result into AcWorkspace objects and add them to our container. Filters out workspace/ref trees that are not in the user's default list of depots they can view based on ACL permissions. More...
 

Detailed Description

A container of AcWorkspace objects that define AccuRev workspaces in the repository.

Definition at line 438 of file AcWorkspaces.cs.

Constructor & Destructor Documentation

AcUtils.AcWorkspaces.AcWorkspaces ( AcDepots  depots,
bool  allWSpaces,
bool  includeHidden,
bool  includeRefTrees = false 
)
inline

A container of AcWorkspace objects that define AccuRev workspaces in the repository.

Parameters
depotsAcDepots creation defaults to the list of depots the script user has access rights to view based on their ACL permissions.
allWSpacestrue to include all workspaces, not just those that belong to the principal.
includeHiddentrue to include deactivated (removed) workspaces/reference trees.
includeRefTreestrue to include reference trees.
public static async Task<bool> showWorkspacesAsync()
{
var progress = new Progress<int>(n =>
{
if ((n % 10) == 0) Console.WriteLine("Initializing: " + n);
});
// depots list is required for workspace list construction
// defaults to those the script user can view based on ACL permissions
AcDepots depots = new AcDepots();
if (!(await depots.initAsync(null, progress))) return false;
// false to include only the script user's workspaces (not all)
// true to include their deactivated (hidden) workspaces
AcWorkspaces wspaces = new AcWorkspaces(depots, allWSpaces: false, includeHidden: true);
if (!(await wspaces.initAsync())) return false;
foreach (AcWorkspace wspace in wspaces.OrderBy(n => n.Hidden).ThenBy(n => n.Name))
Console.WriteLine(wspace.ToString("lv") + Environment.NewLine);
return true;
}
See also
initAsync, default comparer
Precondition
depots cannot be initialized in parallel with AcWorkspaces initialization; it must be a fully initialized list.

Definition at line 484 of file AcWorkspaces.cs.

Member Function Documentation

AcDepot AcUtils.AcWorkspaces.getDepot ( string  name)
inline

Get the AcDepot object that workspace name is located in.

Parameters
nameWorkspace name to query.
Returns
AcDepot object this workspace is located in, otherwise null if not found.

Definition at line 678 of file AcWorkspaces.cs.

async Task<AcResult> AcUtils.AcWorkspaces.getReferenceTreesXMLAsync ( )
inlineprivate

Get the list of reference trees in XML and optionally include those that are inactive as per AcWorkspaces constructor includeHidden parameter.

Returns
AcResult initialized with the show command results, or null on error.
show command:
show <-fvx | -fvix> refs
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on show refs command failure.
Exceptioncaught and logged in same on failure to handle a range of exceptions.
See also
AcWorkspaces.getWorkspacesXMLAsync

Definition at line 587 of file AcWorkspaces.cs.

Referenced by AcUtils.AcWorkspaces.initAsync().

AcWorkspace AcUtils.AcWorkspaces.getWorkspace ( AcDepot  depot,
int  ID 
)
inline

Get the AcWorkspace object in depot with workspace ID number.

Parameters
depotDepot where the workspace resides.
IDWorkspace ID number to query.
Returns
AcWorkspace object otherwise null if not found.

Definition at line 690 of file AcWorkspaces.cs.

AcWorkspace AcUtils.AcWorkspaces.getWorkspace ( string  name)
inline

Get the AcWorkspace object for workspace name.

Parameters
nameWorkspace name to query.
Returns
AcWorkspace object otherwise null if not found.

Definition at line 700 of file AcWorkspaces.cs.

async Task<AcResult> AcUtils.AcWorkspaces.getWorkspacesXMLAsync ( )
inlineprivate

Get the list of workspaces in XML for all or the current user and optionally include inactive workspaces as per AcWorkspaces constructor includeHidden parameter.

Returns
AcResult initialized with the show command results, otherwise null on error.
show command:
show <-fvx | -fvix> <-a | > wspaces
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on show wspaces command failure.
Exceptioncaught and logged in same on failure to handle a range of exceptions.
See also
AcWorkspaces.getReferenceTreesXMLAsync

Definition at line 542 of file AcWorkspaces.cs.

Referenced by AcUtils.AcWorkspaces.initAsync().

async Task<bool> AcUtils.AcWorkspaces.initAsync ( AcDepot  depot = null)
inline

Populate this container with AcWorkspace objects as per constructor parameters.

The resultant list includes only workspaces from depots the user has permission to access.

Parameters
depotSpecify a depot to limit the query to workspaces in depot only, not all depots in the repository.
Returns
true if initialization succeeded, false otherwise.
See also
AcWorkspaces constructor

Definition at line 499 of file AcWorkspaces.cs.

bool AcUtils.AcWorkspaces.storeWSpaces ( AcResult  result,
AcDepot  depot = null 
)
inlineprivate

Convert AcResult.CmdResult XML from result into AcWorkspace objects and add them to our container. Filters out workspace/ref trees that are not in the user's default list of depots they can view based on ACL permissions.

Parameters
resultPreviously initialized AcResult object from AcWorkspaces.getWorkspacesXMLAsync and AcWorkspaces.getReferenceTreesXMLAsync.
depotSpecify a depot to limit the query to workspaces and ref trees in depot only, not the users default list of depots.
Returns
true if object initialization succeeded, false otherwise.
Exceptions
Exceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on failure to handle a range of exceptions.

Definition at line 619 of file AcWorkspaces.cs.

Referenced by AcUtils.AcWorkspaces.initAsync().