tags:

views:

188

answers:

2

Hi,

Is it possible to checkout file of a specific revision using stcmd?

I want to checkout all (or some) history of a specific file.

+4  A: 
Is it possible to checkout file of a specific revision using stcmd?

You can checkout a specific revision using the label as follows

"C:\Program Files\Borland\StarTeam Cross-Platform Client 2005 R2\stcmd" co -p "user:pwd@host:port/MyProject/view_r1/" -is -eol on  -o  -rp "D:\LocalDir" -cfgl  "LABELNAME"

The history of a particular file in that label is gotten by

stcmd hist -p "user:pwd@host:port/MyProject/view_r1/" -cfgl "labelName" -is -rp "D:\LocalDir" FILENAME
JoseK
+2  A: 

stcmd.exe co has a -vn flag that allows you to specify a version number. This is the version number, not the DotNotation, so 1.15 would be version 16. This command:

stcmd.exe co -vn 1 -fp . -p "user:password@server:port/ProjectName/ViewName/FolderPath" file.ext

would get you the 1.0 of file.ext in the current directory. If you want to get the full history, you can parse the output of stcmd hist and figure out the current revision number, or you can just run the above stcmd co command with increasing version numbers from 1 until the result says "file.ext: skipped" instead of "file.ext: checked out" (the current version of stcmd does not error if the version number is too large to be valid). Remember to either delete the local file between calls or add the -o flag to overwrite it. I'd recommend deleting it - there have been issues with stcmd co and overwriting.

Note this will only get you the versions of the file on the current branch back to the 1.0 - you won't get any versions of the file from other branches. So if the current version is 1.5.2.1, you would be able to get 1.5.2.1, 1.5.2.0, 1.5, 1.4, 1.3, 1.2, 1.1, 1.0, but not 1.5.1.0.

Jeremy Murray