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

A depot object that defines the attributes of an AccuRev depot. More...

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

Public Member Functions

AcStream getStream (string name)
 Get the AcStream object for stream name. More...
 
AcStream getStream (int ID)
 Get the AcStream object with stream ID number. More...
 
AcStream getBasis (string name)
 Get the basis (parent) stream for stream name. More...
 
AcStream getBasis (int ID)
 Get the basis (parent) stream for stream ID number. More...
 
async Task< bool > forStreamAndAllChildrenAsync (AcStream stream, Action< AcStream > cb, bool includeWSpaces=false)
 Run the specified action cb for stream and all child streams in its hierarchy. More...
 
async Task< Tuple< bool?, IList< AcStream > > > getChildrenAsync (AcStream stream, bool includeWSpaces=false)
 Get the list of child streams that have stream as their immediate parent (basis) stream. More...
 
string ToString (string format, IFormatProvider provider)
 The ToString implementation. More...
 
Equality comparison
bool Equals (AcDepot other)
 IEquatable implementation to determine the equality of instances of type AcDepot. Uses the depot ID number to compare instances. More...
 
override bool Equals (object other)
 Overridden to determine equality. More...
 
override int GetHashCode ()
 Override appropriate for type AcDepot. More...
 

Internal Functions

string listFile ()
 When this file exists (created manually), it is used as the list-file to populate the depot with select streams. This function is called internally and not by user code. More...
 

Properties

int ID [get, set]
 Depot ID number. More...
 
string Name [get, set]
 Depot name. More...
 
int Slice [get, set]
 Depot's slice number. More...
 
bool ExclusiveLocking [get, set]
 Whether or not all workspaces created for this depot use exclusive file locking. More...
 
CaseSensitivity Case [get, set]
 Whether the depot is case sensitive or insensitive. More...
 
IEnumerable< AcStreamStreams [get]
 The list of streams in this depot. More...
 

Private Member Functions

async Task< MultiValueDictionary< int, int > > getHierarchyAsync (bool includeWSpaces=false)
 Get the depot's stream and workspace (optional) hierarchy relationship data from AccuRev. This method is called internally and not by user code. More...
 

Object construction:

 AcDepot (bool dynamicOnly, bool includeHidden)
 Constructor used during AcDepots list construction. It is called internally and not by user code. More...
 
 AcDepot (string name, bool dynamicOnly=false, bool includeHidden=false)
 Constructor for specifying the depot name. More...
 
 AcDepot (int id, bool dynamicOnly=false, bool includeHidden=false)
 Constructor for specifying the depot ID number. More...
 
async Task< bool > initAsync ()
 Initialize this AcDepot object with data from AccuRev as per constructor parameter's depot name or ID number. More...
 

Order comparison

int CompareTo (AcDepot other)
 Generic IComparable implementation (default) for comparing AcDepot objects to sort by depot name. More...
 
int IComparable. CompareTo (object other)
 Pre-generic interface implementation for code using reflection. More...
 

Detailed Description

A depot object that defines the attributes of an AccuRev depot.

Definition at line 49 of file AcDepots.cs.

Constructor & Destructor Documentation

AcUtils.AcDepot.AcDepot ( bool  dynamicOnly,
bool  includeHidden 
)
inlinepackage

Constructor used during AcDepots list construction. It is called internally and not by user code.

Parameters
dynamicOnlytrue for dynamic streams only, false for all stream types.
includeHiddentrue to include hidden (removed) streams, otherwise do not include hidden streams.

Definition at line 73 of file AcDepots.cs.

Referenced by AcUtils.AcDepot.CompareTo().

AcUtils.AcDepot.AcDepot ( string  name,
bool  dynamicOnly = false,
bool  includeHidden = false 
)
inline

Constructor for specifying the depot name.

Parameters
nameDepot name.
dynamicOnlytrue for dynamic streams only, false for all stream types.
includeHiddentrue to include hidden (removed) streams, otherwise do not include hidden streams.
See also
AcDepot.listFile

Definition at line 86 of file AcDepots.cs.

AcUtils.AcDepot.AcDepot ( int  id,
bool  dynamicOnly = false,
bool  includeHidden = false 
)
inline

Constructor for specifying the depot ID number.

Parameters
idDepot ID number.
dynamicOnlytrue for dynamic streams only, false for all stream types.
includeHiddentrue to include hidden (removed) streams, otherwise do not include hidden streams.
See also
AcDepot.listFile

Definition at line 99 of file AcDepots.cs.

Member Function Documentation

int AcUtils.AcDepot.CompareTo ( AcDepot  other)
inline

Generic IComparable implementation (default) for comparing AcDepot objects to sort by depot name.

Parameters
otherAn AcDepot object to compare with this instance.
Returns
Value indicating the relative order of the AcDepot objects being compared.
See also
AcDepots constructor, ListDynStreams.cs

Definition at line 211 of file AcDepots.cs.

Referenced by AcUtils.AcProperty.CompareTo(), AcUtils.AcWorkspace.CompareTo(), and AcUtils.AcDepot.CompareTo().

int IComparable. AcUtils.AcDepot.CompareTo ( object  other)
inlineprivate

Pre-generic interface implementation for code using reflection.

Parameters
otherAn AcDepot object to compare with this instance.
Returns
Return value of generic CompareTo(AcDepot) version.
Exceptions
ArgumentExceptionthrown if argument is not an AcDepot object.

Definition at line 228 of file AcDepots.cs.

bool AcUtils.AcDepot.Equals ( AcDepot  other)
inline

IEquatable implementation to determine the equality of instances of type AcDepot. Uses the depot ID number to compare instances.

Parameters
otherThe AcDepot object being compared to this instance.
Returns
true if AcDepot other is the same, false otherwise.

Definition at line 172 of file AcDepots.cs.

Referenced by AcUtils.AcDepot.Equals().

override bool AcUtils.AcDepot.Equals ( object  other)
inline

Overridden to determine equality.

Returns
Return value of generic Equals(AcDepot) version.

Definition at line 183 of file AcDepots.cs.

async Task<bool> AcUtils.AcDepot.forStreamAndAllChildrenAsync ( AcStream  stream,
Action< AcStream cb,
bool  includeWSpaces = false 
)
inline

Run the specified action cb for stream and all child streams in its hierarchy.

Parameters
streamTop-level stream to begin the operation with.
cbDelegate to invoke for each stream.
includeWSpacestrue to include workspaces in the list.
Returns
true if operation succeeded with no errors, false on error.
Precondition
Using includeWSpaces to include workspaces requires that all stream types be specified at AcDepot object creation as per the dynamicOnly=false (default) constructor parameter.
AcDepot depot = new AcDepot("NEPTUNE", dynamicOnly: true);
if (!(await depot.initAsync())) return false; // error occurred, check log file
// list streams beginning with NEPTUNE_DEV2 and its hierarchy
AcStream stream = depot.getStream("NEPTUNE_DEV2");
if (!(await depot.forStreamAndAllChildrenAsync(stream, n => Console.WriteLine(n))))
return false; // ..
See also
AcDepot.getChildrenAsync
Attention
To use forStreamAndAllChildrenAsync you must deploy Microsoft.Experimental.Collections.dll with your application.

Definition at line 366 of file AcDepots.cs.

AcStream AcUtils.AcDepot.getBasis ( string  name)
inline

Get the basis (parent) stream for stream name.

Parameters
nameStream name to query.
Returns
Basis AcStream object for stream name or null if not found.

Definition at line 318 of file AcDepots.cs.

Referenced by AcUtils.AcStream.getBasis(), and AcUtils.AcWorkspace.getBasis().

AcStream AcUtils.AcDepot.getBasis ( int  ID)
inline

Get the basis (parent) stream for stream ID number.

Parameters
IDStream ID number to query.
Returns
Basis AcStream object for stream ID number, otherwise null if not found.

Definition at line 334 of file AcDepots.cs.

async Task<Tuple<bool?, IList<AcStream> > > AcUtils.AcDepot.getChildrenAsync ( AcStream  stream,
bool  includeWSpaces = false 
)
inline

Get the list of child streams that have stream as their immediate parent (basis) stream.

Parameters
streamStream to query for child streams.
includeWSpacestrue to include workspaces in the list that have stream as their backing stream.
Returns
true if children found and the list of child streams, false if no children found, or null on error.
Precondition
Using includeWSpaces to include workspaces in the list requires that all stream types be specified at AcDepot object creation as per the dynamicOnly=false (default) constructor parameter.
AcDepot depot = new AcDepot("MARS"); // includes workspace streams
if (!(await depot.initAsync())) return false; // operation failed, check log file
AcStream stage = depot.getStream("MARS_STAGE");
var children = await depot.getChildrenAsync(stage, includeWSpaces: true);
bool? res = children.Item1;
if (res == null) return false; // operation failed, check log file
if (res == false)
Console.WriteLine("No children!");
else
{
IList<AcStream> list = children.Item2;
foreach (AcStream child in list)
Console.WriteLine(child);
}
See also
AcDepot.forStreamAndAllChildrenAsync
Attention
To use getChildrenAsync you must deploy Microsoft.Experimental.Collections.dll with your application.

Definition at line 408 of file AcDepots.cs.

Referenced by AcUtils.AcDepot.forStreamAndAllChildrenAsync().

override int AcUtils.AcDepot.GetHashCode ( )
inline

Override appropriate for type AcDepot.

Returns
Depot ID number since it's immutable and unique in the repository.

Definition at line 195 of file AcDepots.cs.

async Task<MultiValueDictionary<int, int> > AcUtils.AcDepot.getHierarchyAsync ( bool  includeWSpaces = false)
inlineprivate

Get the depot's stream and workspace (optional) hierarchy relationship data from AccuRev. This method is called internally and not by user code.

Parameters
includeWSpacestrue to include workspaces in the list.
Returns
Fully initialized MultiValueDictionary object for the depot with [parent(key),children(values)] basis/stream ID's if no exception was thrown and the operation succeeded, otherwise null on error.
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on show command failure.
Exceptioncaught and logged in same on failure to handle a range of exceptions.
Precondition
Using includeWSpaces to include workspaces in the list requires that all stream types be specified at AcDepot object creation as per the dynamicOnly=false (default) constructor parameter.
show command:
show -p <depot> [-fix | -fx] -s 1 -r streams
Attention
This method requires that you deploy Microsoft.Experimental.Collections.dll with your application.

Definition at line 453 of file AcDepots.cs.

Referenced by AcUtils.AcDepot.getChildrenAsync().

AcStream AcUtils.AcDepot.getStream ( string  name)
inline

Get the AcStream object for stream name.

Parameters
nameStream name to query.
Returns
AcStream object for stream name or null if not found.

Definition at line 296 of file AcDepots.cs.

Referenced by AcUtils.AcDepot.getBasis(), and AcUtils.AcDepot.getChildrenAsync().

AcStream AcUtils.AcDepot.getStream ( int  ID)
inline

Get the AcStream object with stream ID number.

Parameters
IDStream ID number to query.
Returns
AcStream object for stream ID number or null if not found.

Definition at line 307 of file AcDepots.cs.

async Task<bool> AcUtils.AcDepot.initAsync ( )
inline

Initialize this AcDepot object with data from AccuRev as per constructor parameter's depot name or ID number.

Returns
true if initialization succeeded, false otherwise.
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on show command failure.
Exceptioncaught and logged in same on failure to handle a range of exceptions.
See also
AcDepot(string, bool, bool), AcDepot(int, bool, bool), AcDepots constructor
show command:
show -fx depots

Definition at line 114 of file AcDepots.cs.

string AcUtils.AcDepot.listFile ( )
inlinepackage

When this file exists (created manually), it is used as the list-file to populate the depot with select streams. This function is called internally and not by user code.

Implemented with show -l <list-file> streams

-l <list-file> Process the streams listed in the specified file. The file must be text only, containing one stream name or number per line. Extra whitespace is not allowed; make sure there are no empty lines and no leading or trailing whitespace around the filenames. There is no provision for comment lines in a list-file. This option can also be used with one of -1 ("dash-one"), -r, or -R. You cannot also specify streams using the -s option.

Returns
Full path of the list file %APPDATA%\AcTools\<prog_name>\<depot_name>.streams if found, otherwise null.
Example: "C:\Users\barnyrd\AppData\Roaming\AcTools\FooApp\NEPTUNE.streams"
Exceptions
Exceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on failure to handle a range of exceptions.
list-file content:
NEPTUNE_DEV3
NEPTUNE_MAINT2
...
AcDepot depot = new AcDepot("NEPTUNE"); // two-part object construction
if (!(await depot.initAsync())) return false; // operation failed, check log file
foreach (AcStream stream in depot.Streams.OrderBy(n => n))
Console.WriteLine(stream.ToString("lv") + Environment.NewLine);
...
NEPTUNE_DEV3 (10) {normal}
Basis: NEPTUNE_UAT (8)
Depot: NEPTUNE, Hidden: False, HasDefaultGroup: True
NEPTUNE_MAINT2 (6) {normal}
Basis: NEPTUNE_MAINT (4)
Depot: NEPTUNE, Hidden: False, HasDefaultGroup: False

Definition at line 529 of file AcDepots.cs.

Referenced by AcUtils.AcDepot.initAsync(), and AcUtils.AcDepots.initAsync().

string AcUtils.AcDepot.ToString ( string  format,
IFormatProvider  provider 
)
inline

The ToString implementation.

Parameters
formatThe format specifier to use, e.g. Console.WriteLine(depot.ToString("c"));
providerAllow clients to format output for their own types using ICustomFormatter.
Returns
The formatted string.
Exceptions
FormatExceptionthrown if an invalid format string is specified.
Format specifiers:
  • G Depot name. Default when not using a format specifier.
  • LV Long version (verbose).
  • I Depot ID number.
  • S Depot's slice number.
  • E Exclusive locking status: true or false.
  • C Case sensitivity: Sensitive or Insensitive.

Definition at line 573 of file AcDepots.cs.

Property Documentation

CaseSensitivity AcUtils.AcDepot.Case
getset

Whether the depot is case sensitive or insensitive.

Definition at line 278 of file AcDepots.cs.

Referenced by AcUtils.AcDepot.initAsync(), and AcUtils.AcDepots.initAsync().

bool AcUtils.AcDepot.ExclusiveLocking
getset

Whether or not all workspaces created for this depot use exclusive file locking.

Definition at line 269 of file AcDepots.cs.

Referenced by AcUtils.AcDepot.initAsync(), and AcUtils.AcDepots.initAsync().

int AcUtils.AcDepot.ID
getset

Depot ID number.

Definition at line 242 of file AcDepots.cs.

Referenced by AcUtils.AcDepot.GetHashCode(), AcUtils.AcDepot.initAsync(), and AcUtils.AcDepots.initAsync().

string AcUtils.AcDepot.Name
getset
int AcUtils.AcDepot.Slice
getset

Depot's slice number.

Definition at line 260 of file AcDepots.cs.

Referenced by AcUtils.AcDepot.initAsync(), and AcUtils.AcDepots.initAsync().

IEnumerable<AcStream> AcUtils.AcDepot.Streams
get

The list of streams in this depot.

Definition at line 287 of file AcDepots.cs.

Referenced by AcUtils.AcRules.initAsync(), and AcUtils.AcLocks.initAsync().