Command line get changeset  
Author Message
Kim Carlsen





PostPosted: Team Foundation Server - Version Control, Command line get changeset Top

HI

How do I get the latest changesetnumber for a specific file and parse that number to a get command

I know I can get the number with 'tf history...' but how do I parse that to the get command 'tf get /version:C[changesetnumber]...'

Regards

Kim



Visual Studio Team System7  
 
 
Michal Malecki - MSFT





PostPosted: Team Foundation Server - Version Control, Command line get changeset Top

Afaik specifying latest changeset number for a file doesn't make sense - "tf get file_name" works exactly the same way. Could you describe what you want to achive

 
 
Kim Carlsen





PostPosted: Team Foundation Server - Version Control, Command line get changeset Top

Hi

What I want is to build my solution, using scripts, until we convert it all to tfsbuild.

I have a include file called version.rc that contains the versionnumber. Before the build starts I check out and edit this number, and do a checkin. To be sure no one do a checkin in the same second, I would like to get the latest changenumber on version.rc and then use that changeset number to get the rest, to be sure I have a correct and wellknown build.

This way is descibed in an old whitepaper for automatic build using Sourcesafe and batch scripts.

Regards

Kim


 
 
Richard Berg MSFT





PostPosted: Team Foundation Server - Version Control, Command line get changeset Top

A better way would be to use locks. Just specify LockType.CheckOut in your call to PendEdit().
 
 
James Manning - MSFT





PostPosted: Team Foundation Server - Version Control, Command line get changeset Top

for /f %i in ('tf history /stopafter:1 foo.cs /i /format:brief') do set CHANGESET=%i

(change %i to %%i if in a .cmd or .bat file)

With PowerShell, it would be:

$tfs = get-tfs http://server:8080/

$changeset = $tfs.vcs.QueryHistory('D:\some\path\foo.cs', [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::Latest, 0, 'None', $null, $null, $null, 1, $false, $false)

$changesetid = $changeset | %{ $_.ChangesetId }

http://blogs.msdn.com/jmanning/archive/2006/09/28/776141.aspx



 
 
Kim Carlsen





PostPosted: Team Foundation Server - Version Control, Command line get changeset Top

Hi

Thanks it works perfectly.

Regards

Kim