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

A container of AcLock objects that define the AccuRev locks that prevent certain users from making changes to streams. More...

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

Public Member Functions

bool hasLock (string stream)
 Determine if stream has a lock on it. More...
 
async Task< bool > lockAsync (string stream, string comment, LockKind kind=LockKind.all, AcPrincipal prncpl=null, OnlyExcept onlyexcept=OnlyExcept.Except)
 Put a lock on stream as per lock kind. More...
 
async Task< bool > unlockAsync (string stream, LockKind kind=LockKind.all)
 Remove lock kind on stream. More...
 
Two-part object construction:
 AcLocks ()
 A container of AcLock objects that define the AccuRev locks that prevent certain users from making changes to streams. More...
 
async Task< bool > initAsync (AcDepot depot=null)
 Populate this container with AcLock objects on streams in depot or all AcLock objects in the repository. More...
 
async Task< bool > initAsync (DepotsCollection depots)
 Populate this container with AcLock objects on streams in depots. More...
 
async Task< bool > initAsync (StreamsCollection streams)
 Populate this container with AcLock objects on streams. More...
 

Private Member Functions

bool initList (IEnumerable< XElement > query)
 Helper function that populates this container with AcLock objects as per query sent by an initAsync method. More...
 

Detailed Description

A container of AcLock objects that define the AccuRev locks that prevent certain users from making changes to streams.

Definition at line 314 of file AcLocks.cs.

Constructor & Destructor Documentation

AcUtils.AcLocks.AcLocks ( )
inline

A container of AcLock objects that define the AccuRev locks that prevent certain users from making changes to streams.

// get locks on all streams in the repository
AcLocks locks = new AcLocks();
if (!(await locks.initAsync())) return false;
// show DEV locks in NEPTUNE depot and MAINT locks in JUPITER depot
var arr = new[] { "NEPTUNE_DEV", "JUPITER_MAINT" }; // elements are string subsets of our targets
IEnumerable<AcLock> query = locks.Where(n => arr.Any(s => n.Name.Contains(s)));
// list in stream name order with "to" lock followed by "from" lock
foreach (AcLock lk in query.OrderBy(n => n.Name).ThenByDescending(n => n.Kind))
Console.WriteLine(lk);
...
Lock promotions to JUPITER_MAINT except for group LEADS. Authorized users only.
Lock promotions from JUPITER_MAINT for all.
Lock promotions to JUPITER_MAINT1 except for group REPORTING. Work on defect 1405.
Lock promotions from JUPITER_MAINT1 except for group LEADS.
Lock promotions to JUPITER_MAINT2 for all. On hold until further notice.
Lock promotions from JUPITER_MAINT2 for group SYSTEM_TEST only. UAT in progress.
Lock promotions to JUPITER_MAINT3 except for user robert. GUI defect 1345.
Lock promotions from JUPITER_MAINT3 except for group ADMIN.
Lock promotions to NEPTUNE_DEV1 except for group DEV. October ER.
Lock promotions from NEPTUNE_DEV1 except for group ENV_SUPPORT.
Lock promotions to NEPTUNE_DEV2 except for user thomas.
Lock promotions from NEPTUNE_DEV2 except for group LEADS. Authorized users only.
Lock promotions to and from NEPTUNE_DEV3 for all.
See also
initAsync(AcDepot), initAsync(DepotsCollection), initAsync(StreamsCollection), default comparer, LockStreams.cs, Locks.cs, PromoRights.cs

Definition at line 359 of file AcLocks.cs.

Member Function Documentation

bool AcUtils.AcLocks.hasLock ( string  stream)
inline

Determine if stream has a lock on it.

Parameters
streamName of stream to query.
Returns
true if stream has a lock on it, false otherwise.

Definition at line 545 of file AcLocks.cs.

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

Populate this container with AcLock objects on streams in depot or all AcLock objects in the repository.

Parameters
depotLimit the list of locks to those on depot only, otherwise null for all locks in the repository.
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
AcLocks constructor, initAsync(DepotsCollection), initAsync(StreamsCollection)
show command:
show -fx locks

Definition at line 372 of file AcLocks.cs.

async Task<bool> AcUtils.AcLocks.initAsync ( DepotsCollection  depots)
inline

Populate this container with AcLock objects on streams in depots.

Parameters
depotsLimit the list of locks to those on streams in depots only. Depot names in depots must match their respective AccuRev depot name exactly.
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
AcLocks constructor, initAsync(AcDepot), initAsync(StreamsCollection)
show command:
show -fx locks

Definition at line 417 of file AcLocks.cs.

async Task<bool> AcUtils.AcLocks.initAsync ( StreamsCollection  streams)
inline

Populate this container with AcLock objects on streams.

Parameters
streamsLimit the list of locks to those on streams only. Stream names in streams must match their respective AccuRev stream name exactly.
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
AcLocks constructor, initAsync(AcDepot), initAsync(DepotsCollection)
show command:
show -fx locks

Definition at line 467 of file AcLocks.cs.

bool AcUtils.AcLocks.initList ( IEnumerable< XElement >  query)
inlineprivate

Helper function that populates this container with AcLock objects as per query sent by an initAsync method.

Parameters
queryThe query to iterate.
Returns
true if no failure occurred and initialization was successful, false otherwise.
Exceptions
Exceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on failure to handle a range of exceptions.
Note
show -fx locks XML attributes for stream name and LockKind always exist. Other attributes exist only if they have values.

Definition at line 507 of file AcLocks.cs.

Referenced by AcUtils.AcLocks.initAsync().

async Task<bool> AcUtils.AcLocks.lockAsync ( string  stream,
string  comment,
LockKind  kind = LockKind.all,
AcPrincipal  prncpl = null,
OnlyExcept  onlyexcept = OnlyExcept.Except 
)
inline

Put a lock on stream as per lock kind.

Parameters
streamName of stream or workspace to lock.
commentComment to be used for the lock.
kindType of lock to apply: to, from, or all.
prncplAccuRev principal name of user or group in the case of to or from lock.
onlyexceptApply lock to prncpl only or to all except prncpl.
Returns
true if operation succeeded, false otherwise.
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on lock command failure.
lock command:
lock -c <comment> [-kf [-e|-o prncpl] | -kt [-e|-o prncpl]] <stream>
AccuNote:
The CLI lock command can be used on a workspace stream but the same cannot be done using the AccuRev GUI client. AccuRev defect 23850.

Definition at line 564 of file AcLocks.cs.

async Task<bool> AcUtils.AcLocks.unlockAsync ( string  stream,
LockKind  kind = LockKind.all 
)
inline

Remove lock kind on stream.

Parameters
streamName of stream or workspace to unlock.
kindType of lock to remove: to, from, or all.
Returns
true if stream was unlocked successfully, false otherwise.
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on unlock command failure.
unlock command:
unlock [-kf | -kt] <stream>

Definition at line 604 of file AcLocks.cs.