Chapter 3
Microsoft Visual Basic
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" on page 12.
The Perforce submenu lists the SCM 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 support@perforce.com.
Configuring Visual Basic with Perforce
Before you can put Visual Projects under Perforce control, verify that source code control is enabled, as follows:
- In Visual Basic, choose Add-Ins>Add-In Manager... The Add-In Manager dialog is displayed.
- If Source Code Control is not listed, close Visual Basic, edit your vbaddin.ini file (located by default in the Program Files folder), add the following entry under [Add-Ins32]
- Save the file.
Basic SCM tasks
This section tells you how to perform the following tasks.
Adding a project to the depot
When you save your project, you are prompted "Add this project to Perforce?"
- Click Yes. If you enabled the Show the Perforce Connections option on the Preferences > Connection tab, the Open Connection dialog is displayed. 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 SCM 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.
- Client: the Perforce client specification you want associated with the SCM operations you perform on the project. To choose from a list of client specifications defined for the specified server, click Browse.
- Click OK to save settings and dismiss the dialog.
- Right-click the project and choose Check In... The Check In Files to Perforce dialog is displayed.
- Check the files you want to add and click OK. The Pending Changelist form is displayed.
- Enter a comment and choose Submit. The files are added to the depot.
Checked-in files are displayed with a lock icon, as shown in the following figure.
Checking files out
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.
Checked out files are displayed with a red check mark, indicating that the files are writable.
Retrieving files from the depot
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:
- Choose Tools > Perforce >Get Latest Version... The Get Latest Version dialog is displayed.
- 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.
- 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 User's Guide.
- To preview the results of the operation with actually retrieving files, click Preview.
- 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.
- Click Sync.
Note
|
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.
|
.
Note
|
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.
|
Checking files in
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.)
To check in files, perform the following steps:
- Right-click and choose Check in... from the pop-up menu.
The Check in files to Perforce dialog is displayed, listing the selected files.
- Check the files you want to checked in and click OK.
The P4 Submit form is displayed.
- Enter your comments and click OK.
Checked-in files are indicated with lock icons.
Resolving file conflicts
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:
To resolve file conflicts:
- Click Sync and select the files to be resolved. The button text changes to Resolve.
- Click Resolve and choose All Files... The Resolve Files dialog is displayed, describing the extent of the file differences and listing the following options:
- Enter a description of your changes and click Submit. Your changes are checked in.
Diffing files
To diff a file you are editing with the head revision in the depot, right-click the file and choose Tools > Perforce > Show Differences.
To diff two revisions of a file, perform the following steps:
- Select the file and choose Tools > Perforce > Show History... The Revision History dialog is displayed.
- Click and drag one of the revisions you want to diff, and drop it on the other revision.
P4Diff is launched, displaying file differences.
Reverting files
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. You can also revert unchanged files from the Pending Changelist dialog.
Working with Visual Basic files
Which files do I put in the depot?
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 file
You can exclude them using Perforce protections or client views to prevent them from being inadvertently added to the depot.
Location of project files
The FileView 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:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconformprojectfileformats.asp
Visual Basic file pairs
The following table lists associated files that must be checked out together.
File Type
|
Check out in IDE
|
Check out using Perforce
|
---|
Forms
|
.frm
|
.frx
|
UserDocument objects
|
.dob
|
.dox
|
UserControls
|
.ctl
|
.ctx
|
Property pages
|
.pag
|
.pgx
|
For example, if you check out a .frm file, be sure to check out its associated .frx file.
Recommended Perforce file types
Following are recommended Perforce file types for Visual Basic files. For details about Perforce file types and attributes, refer to the Perforce User's Guide.
File type
|
Perforce file type
|
Description
|
---|
.bas
|
text
|
Basic file
|
.cls
|
text
|
class file
|
.ctl
|
text
|
control file
|
.ctx
|
binary
|
control binary file
|
.dsr
|
text+w
|
designer file
|
.dsx
|
binary
|
active designer binary file
|
.frm
|
text
|
form file
|
.frx
|
binary
|
form binary file
|
.vbg
|
text+w
|
group project
|
.vbp
|
text
|
project
|
.vbw
|
text+w
|
workspace
|
Checking out the project file
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.
Please send comments and questions about this manual to
manual@perforce.com.
Copyright 2001-2004 Perforce Software. All rights reserved.
Last updated: 08/19/04