Chapter 3 This chapter describes how to perform Perforce source code control tasks in the Visual Basic 6.0 environment. It assumes the Perforce SCC Plug-in is installed and that your client machine can communicate with the Perforce server. For details about configuring settings, see Configuring IDEs with plug-ins.The Perforce submenu lists the version management operations you can perform. Note that the Tools>Perforce>Create Project from Perforce... option is not supported.If the Add-Ins > Add-In Manager... menu item does not contain Source Code Control in the list box, you do not have the VB Source Code Add-In. For help getting it from Microsoft, contact [email protected].Before you can put Visual Projects under Perforce control, verify that source code control is enabled, as follows:
1.
2. If Source Code Control is not listed, close Visual Basic, edit your vbaddin.ini file (located by default in the %windir% folder), add the following entry under [Add-Ins32]
1. Choose Tools>Perforce>Add Project to Perforce.
2. Click Yes. If you enabled the Show the Perforce Connections option on the Preferences > Connection tab, the Open Connection dialog is displayed.
3. On the Open Connection dialog, specify Perforce settings as follows:
• Server: the name of the host computer running the Perforce server in which you want to store the project.
• Port: the port number on which the specified Perforce Server accepts commands.
• User: the Perforce user name you want associated with the version management operations you perform on the project. To choose from a list of users defined for the specified server, click Browse.
• Password: the user's password, if any.
• Workspace: the Perforce workspace you want associated with the version management operations you perform on the project. To choose from a list of workspaces defined for the specified server, click Browse.
4. Click OK to save settings and dismiss the dialog. The Add Files to Perforce dialog is displayed, listing the files to be added.
5. Click OK to dismiss the dialog.
6. Right-click the project and choose Check In.... The Check in Files to Perforce dialog is displayed, listing files to be checked in.
7.
8. Check the files you want to add, enter a comment and choose Submit. The files are added to the depot.To check out a file for edit, right-click the project file in the Project window and choose Check Out from the pop-up menu.To get the most recent revision of a file from the depot, right-click the file and choose Get Latest Version.To retrieve revisions prior to the head (latest) revision, you can sync from the Revision History dialog or perform the following steps:
1.
2. Check the files you want to retrieve and click Advanced... Dismiss the "Advanced sync dialog..." prompt by clicking OK, then click OK on the Get Latest Version dialog. The Sync dialog is displayed as shown in the following figure.
3. Specify the revision you want to retrieve, using a Perforce changelist number, label, version number, or date. For details about specifying revisions, refer to the Perforce Command Reference.
• To retrieve a file from the depot if you've deleted your local copy manually, check Force Sync. By default, Perforce assumes you still have your copy and doesn't retrieve it again.
4. Click Sync..
If you retrieve a file that you already have checked out, for example, to obtain changes checked in by another user, Perforce will require you to resolve the file, to enable you to merge your changes with changes made by other users and to ensure that you don't inadvertently overwrite other changes.After editing checked-out files, you must check them into the depot. Your edited files become the head revision in the depot. (If any of your changes conflict with changes previously submitted by another user, the check-in fails and the differences must be resolved using Perforce.)
1. Right-click and choose Check in... from the pop-up menu.The Check In Files to Perforce dialog is displayed, listing the selected files.The Submit Changelist form is displayed.To view all your pending changelists, click the Manage Changelists button on the Submit Changelist form. P4SCC displays a dialog listing your pending changelists. In this dialog, you can move files among changelists by dragging and dropping them.If you encounter conflicts when checking in files, (for example, from multiple users working on the same files,) you must resolve the conflicts before you can submit the files. For example, if you and another user have changed the same file and the other user checked in changes before you, when you attempt to check in your changes, Perforce notifies you that resolution is required by displaying the following message in the Pending Changelist dialog:
1. In the Submit Changelist dialog, Right-click the file that has conflicts and choose Get Latest Revision.The file is now scheduled for resolve, indicated by the message "Resolve this file before submitting."
2. Right-click the file and choose Resolve Files... The resolve dialog is displayed, describing the extent of the file differences and listing the following options:
• Accept Merge: merge both files and accept the result, including both the changes you made and the changes made by other users.
• Accept Yours: check your changes in, overwriting the most recently checked-in version.
• Accept Theirs: discard your changes and preserve the other user's changes.
• Run Merge Tool: launch the merge utility so you can view the differences between your version and the most recently checked-in version. Using the merge utility, you can select individual passages or enter new changes to create the final version that you check in.
• Other choices: you can view either file (Open File...), diff your file with the conflicting file, display the file's revision history either textually or graphically.After you choose how the files are resolved, the Submit Changelist dialog is redisplayed.
3. Enter a description of your changes and click Submit. Your changes are checked in.To diff a file you are editing with the head revision in the depot, right-click the file and choose Tools > Perforce > Show Differences...
1. To discard changes you've made to a checked-out file and reload the head revision from the depot, right-click the file and choose Undo Check Out.In general, add the project file (such as .vbp files) but not the workspace file (.vbw files), especially if multiple developers are working on the same project. For example, if a developer has a workspace file checked out for edit and another developer adds a file to the project, the change is not reflected in the workspace file. Exclude the following Visual Basic file types from Perforce control; Visual Basic caches and recreates them as required.
• .dca: active designer cache
• .oca: control typelib cache
• .vbg: group fileYou can exclude them using Perforce protections or client views to prevent them from being inadvertently added to the depot.The Project window displays source file names and their location on your local directory, but is only an approximate representation. Although the display simplifies project development in Visual Basic, it differs from the actual file structure in the following ways:
• The Project window groups source files by file type, such as Forms and Designers, but the local directory does not.
• The Project window does not display the workspace file (.vbw file) and some other files.For some source control tasks, you need to identify the actual names and locations of these files. For detailed information about Visual Basic project files, see:Following are recommended Perforce file types for Visual Basic files. For details about Perforce file types and attributes, refer to Introducing Perforce.
In Visual Basic 6.0 it is necessary to check out the project file (.vbp file) for edit to save any changes, including changes that affect only .frm files. If you do not want to submit an unchanged project file, right- click the project and choose Undo checkout. If multiple developers are working on the same project, keep the project file writable by setting its Perforce file type to +w when you add it to the depot.