Kwscm

kwscm loads revisions from your SCM system into Klocwork Code Review, enabling post-checkin code reviews. kwscm is installed as part of the Klocwork Servers package.

kwscm is designed to mimic the functionality of your native SCM client. You can assume it works the same way as your SCM unless noted otherwise below.

Prerequisites

  • For ClearCase, CVS, and Team Foundation, the SCM executables must be in your path.
  • For TFS, you should use kwscm from a Visual Studio command prompt.

First usage

kwscm --url http(s)://<klocwork_server_host>:<klocwork_server_port>/<project> <scm> [scm_options] <scm_path>

where

  • <project> is a project on the Klocwork Server
  • <scm> is your SCM
  • [scm_options] are additional options you may want to set (listed below for each SCM)
  • <scm_path> is:
    • the path to your SCM repository, or
    • a local path, if the command is run from your local SCM repository

You can also specify an arguments file for kwscm. For example:

kwscm --url http://server01:8080/myproject/ svn http://devserver/svn/myproject

Troubleshooting

If kwscm fails, it prints out the command that was used, the output of the command and the return code. If you need more information, add the --verbose option to your original command line. If the error message indicates a problem that you're unable to troubleshoot, contact Customer Support.

Subsequent usage

After integrating with your SCM, you need to load new revisions into your system on a regular basis to maintain a sequential history. Typically, this process is scripted using a continuous integration system or can be set up to run automatically using a Unix command such as crond.

When you specify the necessary revision options, kwscm automatically determines and loads the appropriate versions of all files that are related to the new revision you are loading into the history.

If no date or revision range is specified, kwscm sticks to a predefined date/revision range (depending on your choice of SCM) as opposed to loading the full history. Loading the entire database each time may cause it to load very slowly.

The scripted command looks as follows:

kwscm --url http://<klocwork_server_host>:<klocwork_server_port>/<project> <scm> [scm_options] <revision_options> <scm_path> 

where

  • <revision_options> specifies new revisions that you are loading into your history.

Specify revisions with the options and syntax required by your SCM.

For example:

kwscm --url http://server01:8080/myproject/ svn --revision rev4:rev8 http://devserver/svn/myproject

Options that apply to all subcommands

Name Short name Description
--encoding <string>   encoding of the source files used in the project. The default is your system encoding. Use the --list option of kwconv to find the list of acceptable values. For more information, see the --encoding option of kwbuildproject.
--force -f force execution if command-line tools exit with non-zero exit code; if something fails but you want to bypass it, specifying force will ignore the error and execute the command
--help -h display this help and exit
--tags -t specify tag(s) that you want to assign to your code review. These tags can be used to organize your feed and also to control whether or not other users can see code reviews with particular tags.
--url http://<host>:<port>/<project>   URL for a project on the Klocwork Server, of the form http://<server_host>:<server_port>/<project> Use https:// if a secure Klocwork Server connection has been configured.
--verbose -v print verbose information about program execution, which can help to troubleshoot errors.
--version   display version

kwscm cc

Prerequisites

  • The cleartool executable must be specified in your path.

Example

kwscm --url http://server01:8080/myproject cc --since 22-November-2010 -R .

Options

Name Short name Description
--all -a list all checkouts in the VOB containing pname
--avobs   similar to --all, but includes checkouts in all VOBs active (mounted) on the local host
--branch <branch> -b specify branch
--recurse -R list checkouts of elements in the entire subtree below any directory encountered in the current view
--since <date-time>   list events recorded since (that is, at or after) the specified date-time. ex. 14-March-2011.11:21:33
Use the date-time syntax required by ClearCase. If this option is not specified, kwscm issues a warning and proceeds with loading the last two weeks.

kwscm cvs

Prerequisites

  • The cvs executable must be specified in your path.

Example

kwscm --url http://server01:8080/myproject cvs -d :pserver:dev01@workserver:/home/cvs -r rev1:rev2 zlib

Options

Name Short name Description
-d <cvs_root>   specify $CVSROOT as the root of the CVS tree
-dates <date_range>   specify date range(s); follow the proper syntax used by CVS
--revision <revision_number(s)> -r specify revision(s); follow the proper syntax used by CVS
If --dates or --revision is not specified, kwscm issues a warning and proceeds with loading revisions from the last two weeks.

kwscm git

Example

kwscm --url http://server01:8080/myproject git --last=10 .

Options

Name Description
--git-dir <path> set the path to the repository
--last <last> load the last N number of revisions. For example, if N is set to 3, the last three revisions are loaded into your history.
Revision ranges are supported, use git <since>..<until>. If --last or revision ranges is not specified, kwscm issues a warning and proceeds with --last=100.
--work-tree <path> set the path to the working tree

kwscm p4

Example

kwscm --url http://server01:8080/myproject p4 --last 5 //pyunit/...

Options

Name Short name Description
--last <last>  

load the last N number of revisions. For example, if N is set to 3, the last three revisions are loaded into your history.

You can also use version specifiers. If --last or revision ranges is not specified, kwscm issues a warning and proceeds with loading revisions from the last two weeks.

--password <password> -P specifies the password (overrides the value of $P4PASSWD in the environment).
--user <user>   specifies the user name (which overrides the value of $P4USER, $USER AND $USERNAME in the environment).

Important: If a file under source control is larger than 20 MB in size, it will be treated as a binary by Kwscm. This means that you cannot view diffs for a revision for any file that is larger than 20 MB.

kwscm svn

Example

kwscm --url http://server01:8080/myproject/ svn -r BASE:rev2659 http://devserver/svn/myproject

Options

Name Short name Description
--limit <integer> -l specify the number of latest revisions to be loaded.
--revision <revision_number(s)> -r specify revision(s). Can be a single revision (rev1) or a range (rev1:rev5). 'HEAD' can also be used when specifying a revision range.
If --revision or --limit is not specified, kwscm issues a warning and proceeds with loading revisions from the last two weeks.

kwscm tf

Prerequisites

  • You should use kwscm from a Visual Studio command prompt.

Example

kwscm --url http://server01:8080/myproject tf --vspec C23~C62 $/zlib

Options

Name Description
--server <server> identify the Team Foundation Server. Required if kwscm is invoked from a directory that is not mapped to a workspace.
--stopafter <integer> load the history for the latest number of changesets that you specify
--vspec <version> specify versionspec. To specify a range of changesets, use a Team Foundation itemspec.
If --stopafter, --vspec or revision ranges is not specified, kwscm issues a warning and proceeds with --stopafter=100.