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

Miscellaneous stuff that didn't fit in elsewhere. More...

Static Public Member Functions

static async Task< string > getPrincipalAsync ()
 Determines if the current user is logged into AccuRev and, if so, retrieves their principal name. More...
 
static async Task< string > getCatFileAsync (int eid, AcDepot depot, string ver_spec)
 Use to retrieve the contents of a text file under version control. More...
 
static async Task< int[]> getBackedVersionAsync (string realverspec, AcDepot depot, string depotrelpath)
 For the real version specified in the argument list, get the real stream/version for the version in the specified version's workspace backing stream. More...
 
static async Task< Tuple< string, int > > getElementNameAsync (string stream, int EID)
 Get the depot-relative path for the element in stream with EID. Also returns the element's parent folder EID (folder where the element resides). More...
 
static T getAppConfigSetting< T > (string key)
 Type safe way to retrieve values from <prog_name>.exe.config files. More...
 
static async Task< int[]> getAccuRevVersionAsync ()
 Retrieves the AccuRev program major, minor and patch version numbers. More...
 
static async Task< int > getUsersCountAsync (bool includeDeactivated=false)
 Get the number of active users. More...
 
static async Task< int > getDepotsCountAsync ()
 Get the number of active depots in the repository. More...
 
static async Task< int > getDynStreamsCountAsync ()
 Get the number of dynamic streams in the repository that have a default group. More...
 
static async Task< int > getTotalStreamsCountAsync ()
 Get the total number of streams (including workspace streams) in the repository including those that are hidden. More...
 
static async Task< int > getStreamsWithDefaultGroupCountAsync ()
 Get the number of streams (including workspace streams) in the repository that have a default group. More...
 
static async Task< int > getTotalWorkspaceCountAsync ()
 Get the total number of workspaces in the repository including those that are hidden. More...
 
static bool getAcGUIpath (out string path)
 Determine if acgui.exe is found in the Path and thus can be spawned. More...
 
static bool getServerFromAcClientCnf (out string server)
 Get the default AccuRev server from acclient.cnf. The default server is the first line in the file. More...
 
static async Task< List< string > > getDepotNameListAsync ()
 Get the list of depot names in sorted order. More...
 

Static Private Member Functions

static bool getAcClientCnfPath (out string path)
 Helper function for getServerFromAcClientCnf returns the full path to acclient.cnf on the host machine. More...
 

Detailed Description

Miscellaneous stuff that didn't fit in elsewhere.

Definition at line 32 of file AcQuery.cs.

Member Function Documentation

static bool AcUtils.AcQuery.getAcClientCnfPath ( out string  path)
inlinestaticprivate

Helper function for getServerFromAcClientCnf returns the full path to acclient.cnf on the host machine.

Parameters
pathFull path to acclient.cnf.
Returns
true if function ran successfully, false otherwise.

Definition at line 589 of file AcQuery.cs.

Referenced by AcUtils.AcQuery.getServerFromAcClientCnf().

static async Task<int[]> AcUtils.AcQuery.getAccuRevVersionAsync ( )
inlinestatic

Retrieves the AccuRev program major, minor and patch version numbers.

Returns
An array initialized as int[]={major, minor, patch} on success, otherwise null on error.
xml command:
xml -l <xmlfile>
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on xml command failure.
Exceptioncaught and logged in same on failure to handle a range of exceptions.
<?xml version="1.0" encoding="utf-8"?>
<serverInfo>
<serverVersion
major="5"
minor="6"
patch="0"/>
<serverHostPort>machine_name_omitted:5050</serverHostPort>
</serverInfo>

Definition at line 293 of file AcQuery.cs.

static bool AcUtils.AcQuery.getAcGUIpath ( out string  path)
inlinestatic

Determine if acgui.exe is found in the Path and thus can be spawned.

Parameters
pathThe full path to acgui.exe on the host machine if found, otherwise null.
Returns
true if function ran successfully, 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 551 of file AcQuery.cs.

Referenced by AcUtils.AcQuery.getAcClientCnfPath().

static T AcUtils.AcQuery.getAppConfigSetting< T > ( string  key)
inlinestatic

Type safe way to retrieve values from <prog_name>.exe.config files.

Template Parameters
TData type for <prog_name>.exe.config file entry.
Parameters
keyKey name from <prog_name>.exe.config file entry.
Returns
<prog_name>.exe.config value for key.
See also
Convert.ChangeType Method (Object, Type)

Definition at line 268 of file AcQuery.cs.

static async Task<int[]> AcUtils.AcQuery.getBackedVersionAsync ( string  realverspec,
AcDepot  depot,
string  depotrelpath 
)
inlinestatic

For the real version specified in the argument list, get the real stream/version for the version in the specified version's workspace backing stream.

diff used here with the -i option, not to run a diff but to get the EID's only.

Parameters
realverspecReal version specification in text format, for example PG_MAINT1_barnyrd\4 (numeric format won't work).
depotThe depot.
depotrelpathDepot relative path, for example .\Bin\foo.java
Returns
An array initialized as int[]={realStreamNumber, realVersionNumber} if available, otherwise null.
diff command:
The diff command returns zero (0) for no differences found, one (1) for differences found, or two (2) on diff program error.
diff -fx -v <realverspec> -b -i -p <depot> <depotrelpath>

-v -b Compare the specified version (X) with the version in X's stream's backing stream. (Use -v -V instead if comparing elements of type text that are active in a time-based stream.)

-i Information only: Report the IDs of the two versions, but don't actually compare them. This option is valid only in a command that uses a -v/-V combination or a -v/-b combination. If an element appears only in the workspace stream, not in the workspace's backing stream, this option does not list it.

Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on diff command failure.
Exceptioncaught and logged in same on failure to handle a range of exceptions.

Definition at line 167 of file AcQuery.cs.

static async Task<string> AcUtils.AcQuery.getCatFileAsync ( int  eid,
AcDepot  depot,
string  ver_spec 
)
inlinestatic

Use to retrieve the contents of a text file under version control.

Puts the content of the specified file in a temporary file. The caller is responsible for deleting the file.

Parameters
eidThe file's element ID.
depotThe depot.
ver_specThe version specification in the numeric or text format, e.g. 32/1 or PG_MAINT1_barnyrd\4.
Returns
A string initialized to the name of the temporary file with the contents from the AccuRev cat -v <ver_spec> -p <depot> -e <eid> command on success, otherwise null on error.
cat command:
cat -v <ver_spec> -p <depot> -e <eid>
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on cat command failure.
Exceptioncaught and logged in same on failure to handle a range of exceptions.
AccuNote:
The CLI cat command fails on Windows for ptext files larger than 62,733 bytes. Fixed in 6.0. AccuRev defect 28177.
AccuNote:
For the name, anc and cat commands, the validity of the results is guaranteed only if the commands are issued outside a workspace, or in a workspace whose backing stream is in the same depot for both workspace and the -v <ver_spec> option used. If issued from a workspace that has a different backing stream than the -v <ver_spec>, provided both workspace and ver_spec share the same depot, the command results can be deemed valid. However, if issued from a workspace whose backing stream is in a different depot than the -v <ver_spec>, the command results are invalid. Applications should set the default directory to a non-workspace location prior to issuing these commands. AccuRev defects 18080, 21469, 1097778.

Definition at line 119 of file AcQuery.cs.

static async Task<List<string> > AcUtils.AcQuery.getDepotNameListAsync ( )
inlinestatic

Get the list of depot names in sorted order.

Returns
The list of depot names on success, otherwise null on error.
show command:
show -fx depots
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on show command failure.

Definition at line 652 of file AcQuery.cs.

static async Task<int> AcUtils.AcQuery.getDepotsCountAsync ( )
inlinestatic

Get the number of active depots in the repository.

Returns
Number of depots or minus one (-1) on error.
show command:
show -fx depots
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.

Definition at line 382 of file AcQuery.cs.

static async Task<int> AcUtils.AcQuery.getDynStreamsCountAsync ( )
inlinestatic

Get the number of dynamic streams in the repository that have a default group.

Returns
Number of dynamic streams with a default group or minus one (-1) on error.
show command:
show -fx -d streams
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.

Definition at line 416 of file AcQuery.cs.

static async Task<Tuple<string, int> > AcUtils.AcQuery.getElementNameAsync ( string  stream,
int  EID 
)
inlinestatic

Get the depot-relative path for the element in stream with EID. Also returns the element's parent folder EID (folder where the element resides).

Parameters
streamName of the stream where the element resides.
EIDThe element ID of the element on which to query.
Returns
An tuple initialized as {depot-relative path, parent EID} on success, otherwise null.
name command:
name -v <stream> -fx -e <EID>
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on name command failure.
Exceptioncaught and logged in same on failure to handle a range of exceptions.
accurev name -v MARS_MAINT2 -fx -e 13763
<?xml version="1.0" encoding="utf-8"?>
<AcResponse
Command="name"
TaskId="51498">
<element
location="\.\scripts\build.xml"
parent_id="12269"/>
</AcResponse>
AccuNote:
For the name, anc and cat commands, the validity of the results is guaranteed only if the commands are issued outside a workspace, or in a workspace whose backing stream is in the same depot for both workspace and the -v <ver_spec> option used. If issued from a workspace that has a different backing stream than the -v <ver_spec>, provided both workspace and ver_spec share the same depot, the command results can be deemed valid. However, if issued from a workspace whose backing stream is in a different depot than the -v <ver_spec>, the command results are invalid. Applications should set the default directory to a non-workspace location prior to issuing these commands. AccuRev defects 18080, 21469, 1097778.

Definition at line 233 of file AcQuery.cs.

static async Task<string> AcUtils.AcQuery.getPrincipalAsync ( )
inlinestatic

Determines if the current user is logged into AccuRev and, if so, retrieves their principal name.

Implemented by extracting the user's principal name or string "(not logged in)" from the info command results.

Returns
A string initialized to the name of the principal logged into AccuRev or null if not logged in.
info command:
info
AccuNote:
To support GUIs logging into replicas, get host and port from info command (instead of from XML <serverInfo> results, which are not correct for replica) to use in titlebar, preferences.xml, and MQTT messages. 35934/17776122 (35921/17776020)
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on info command failure.
Exceptioncaught and logged in same on failure to handle a range of exceptions.
Note
The user must have AccuRev\bin in their Path environment variable to run AccuRev commands issued by the AcUtils library. Since this method is often the first function called by a client application (in this case info), a failure here usually means this entry is missing.

Definition at line 49 of file AcQuery.cs.

static bool AcUtils.AcQuery.getServerFromAcClientCnf ( out string  server)
inlinestatic

Get the default AccuRev server from acclient.cnf. The default server is the first line in the file.

Parameters
serverThe AccuRev server in the format hostname:port, otherwise null.
Returns
true if function ran successfully, 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 611 of file AcQuery.cs.

static async Task<int> AcUtils.AcQuery.getStreamsWithDefaultGroupCountAsync ( )
inlinestatic

Get the number of streams (including workspace streams) in the repository that have a default group.

Returns
Number of streams with a default group or minus one (-1) on error.
show command:
show -fx -d streams
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.

Definition at line 484 of file AcQuery.cs.

static async Task<int> AcUtils.AcQuery.getTotalStreamsCountAsync ( )
inlinestatic

Get the total number of streams (including workspace streams) in the repository including those that are hidden.

Returns
Total number of streams or minus one (-1) on error.
show command:
show -fix streams
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.

Definition at line 450 of file AcQuery.cs.

static async Task<int> AcUtils.AcQuery.getTotalWorkspaceCountAsync ( )
inlinestatic

Get the total number of workspaces in the repository including those that are hidden.

Returns
Total number of workspaces or minus one (-1) on error.
show command:
show -fix -a wspaces
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.

Definition at line 518 of file AcQuery.cs.

static async Task<int> AcUtils.AcQuery.getUsersCountAsync ( bool  includeDeactivated = false)
inlinestatic

Get the number of active users.

Parameters
includeDeactivatedtrue to include deactivated (removed) users, otherwise false.
Returns
Number of active users or minus one (-1) on error.
show command:
show -fx users
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.

Definition at line 348 of file AcQuery.cs.