Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using an existing Label to create a new label

Status
Not open for further replies.

Klyn610

MIS
Jan 8, 2007
11
US
Hello again!

I know other source control systems have a way of doing this, and I'm wondering if there is any way from the command line to label a project or set of files by using another label. For instance, I have project 1 labeled "MyLabel 1". Changes were made and a new label was applied called "MyLabel 2". After creating "MyLabel2", a need to rollback a subproject to "MyLabel1" arises, which we do (right click on sub-project, do a "get" on "MyLabel1".

Now, this all ends up going out the door, but I want the entire source under the parent project to have the same label. I don't want to relabel the entire project, because I will pick up versions of code I don't yet need.

Is there a way to say "hey, take everything in this subproject with the label "MyLabel1" and call it "MyLabel2"?

Thanks!!
Keri-Lyn
 
Hi Keri-Lyn,

I am not aware of any way in which you can do this from a command line. Any label from command line that I know labels the most recent version. Again some VB6 code that might do the job. I have only done minimal testing on this as I do not want to mess with my SS database here.
'================================================
Option Explicit
Dim objVSSDatabase As New VSSDatabase
Dim intFreeFile As Integer

Private Sub cmdOK_Click()
'
'Open database using login and password
objVSSDatabase.Open "\\192.0.0.3\vss\srcsafe.ini", "user", "password"

'process initial source folder
Call ProcessFolder("$\Source\Branch1", "old Label", "new label")

'
End Sub

Private Sub ProcessFolder(ByVal StrSource As String, ByVal strOldLabel As String, ByVal strNewLabel As String)

Dim objVSSRoot As VSSItem
Dim objItems As VSSItem
Dim objItem As VSSItem
Dim intMaxVersion As Integer

Dim objVSSVersion As VSSVersion

'open up the paths
Set objVSSRoot = objVSSDatabase.VSSItem(StrSource, False)
'
'Grab all the items from the Path
For Each objItems In objVSSRoot.Items
'Get the latest version number
intMaxVersion = objItems.VersionNumber
'Open file
Set objItem = objItems.Version(intMaxVersion)

'If folder then call this routine again with new path to process folder
If objItem.Type = 0 Then
Call ProcessFolder(StrSource & "\" & objItem.Name, strOldLabel, strNewLabel)
End If

For Each objVSSVersion In objItem.Versions
If Left(objVSSVersion.Action, 5) = "Label" Then
If objVSSVersion.Label = strOldLabel Then
objVSSVersion.VSSItem.Label strNewLabel, ""
End If
End If
Next

Next

Set objVSSRoot = Nothing

End Sub
'=====================================================

If you want to continue down this automation route take a look at this link.


It lets you know how to use the API Interface for VSS using VB6.

Regards,


Hammy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top