Perforce 2007.2 Using IDE Plug-ins
<< Previous Chapter
Basic Concepts
Table of Contents
Index
Perforce on the Web
Next Chapter >>
Microsoft Visual Basic

Chapter 2
Microsoft Visual C++

This chapter describes how to perform Perforce source code control tasks in the Visual C++ 6.0 environment. It assumes the Perforce SCC Plug-in is installed and that your client machine can communicate with the Perforce server.

When you configure Visual C++ with the Perforce SCC Plug-in, the settings are specific to the project you are working on, so no overall Perforce configuration is required. The Perforce SCC Plug-in retains project settings from session to session and it is not necessary to re-enter them. For details about configuring settings, see "Configuring IDEs with plug-ins" on page 12.

Visual C++ has a Source Code Control toolbar: to enable it, right-click the toolbar and check Source Code Control on the pop-up menu. To specify source control options, choose Tools> Options... and

Basic SCM tasks

This section tells you how to perform the following tasks:

Adding a project to the depot

When you create a project you intend to manage with Perforce, specify a location that resides within the root folder of the Perforce workspace you intend to use as illustrated in the following figure.

After you save your project, perform the following steps:

  1. Right-click the project and choose Add to Source Control... The Open Connection dialog is displayed.

  2. On the Open Connection dialog, specify Perforce settings as follows:

  3. Click OK to save settings and dismiss the dialog. The Add to Source Control dialog is displayed, listing the files to be added.

  4. Click OK to dismiss the dialog.

  5. Right-click the project and choose Check In... The Check in Files dialog is displayed.

  6. Click to dismiss the dialog. The Submit Changelist dialog is displayed.

  7. Check the files you want to add, enter a description and click Submit. The files are checked into the depot.

When you open a project that you have placed under Perforce control, Visual C++ attempts to connect to the Perforce server that you configured. If Visual C++ can not connect to Perforce, it asks you whether it should try to connect in future sessions. Choose Yes. If you choose No, Visual C++ assumes the project is no longer under version control, requiring you to add it again. If you try to add the project again, Perforce returns an error indicating that the project is already under source control, and you must retrieve the project from the depot.

Retrieving files from the depot

To get the most recent file revisions from the depot:

  1. In the File View pane, select the files you want to retrieve.

  2. Choose Project >Source Control >Get Latest Version... The Get Latest Version dialog is displayed.

  3. Check the files you want to retrieve and click OK.

To retrieve revisions prior to the head (latest) revision, choose Project>Source Control>Show History or perform the following steps:

  1. In the File View pane, select the files you want to retrieve.

  2. Choose Project >Source Control > Get Latest Version... The Get Latest Version dialog is displayed.

  3. Click Advanced... Dismiss the "Advanced sync dialog..." prompt by clicking OK, then click OK on the Get Latest Version dialog. The Get Revision dialog is displayed as shown in the following figure.

  4. 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.

  5. Click Get Revision.

    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 out

Before you check a file out, be sure you have retrieved the latest revision of the file. (If you check out a file for which the depot contains later revisions, you will be required to resolve it when you check it in.)

To check out a file for edit, right-click the file and choose Check out filename.

Checking files in

After editing the open files, you can save them to your local directory and check the files into the depot. To save the files on your local directory, choose File>Save. Note that saving does not update the depot.

To make your changes available to others working on the project, you must check your edited files into the depot. If the changes are accepted, your files become the most recent (or head) revisions in the depot. If any of the changes conflict with changes previously submitted by another user, the check-in fails and the differences must be resolved using Perforce. To minimize the complexity of merges, check in small sets of changes frequently.

To check in a file:

  1. Right-click the file and choose Check in...

    The Check in file(s) dialog is displayed.

  2. Click OK. The Submit Changelist form is displayed.

  3. Enter description and click Submit.

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.

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 Submit Changelist dialog:

To resolve file conflicts:

  1. 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." (Your workspace version is not overwritten.)

  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:

  3. 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 Project > Source Control > Show Differences.

To diff two revisions of a file, perform the following steps:

  1. Select the file and choose Project > Source Control > Show History... The History dialog is displayed.

  2. Click and drag one of the revisions you want to diff, and drop it on the other revision.

The diff utility is launched, displaying file differences.

Reverting files

To discard any changes you have made to a file after checking it out, right-click the file and choose Undo Check-out. The head revision from the depot is copied to your client workspace, overwriting any changes you have made. Using Perforce, you can verify that the file is removed from the pending default changelist.

Working with Visual C++ files

Visual C++ displays a file status icon next to each file in the project window. In addition, the Source Control menu is context-sensitive: if you highlight a file, the menu selections are enabled or disabled depending on file status. You can use the icon or Source Control menu appearance to identify file status.

File status
Icon appearance
Source Control
menu appearance

Files are not under Perforce source code control

Original VC++ icon

Add to Source Control option is enabled

Files have been added to a changelist but not submitted to Perforce.

Icon is gray with red check mark

Check in and
Undo Check out
options are enabled

Files have been successfully submitted to Perforce.

Icon is gray

Check out option is enabled

Which files do I put in the depot?

Put the following files in your Perforce depot:

Do not put IDE-generated files (such as .ncb, .clw and .opt files) in your Perforce depot. If you put the .ncb file under Perforce control, it is marked read-only when it's not checked out. If the .ncb file is read-only, class view information in VC++ is disabled.

If you intend to put the workspace file (.dsw) under Perforce control and multiple developers work on the same project, use relative paths to specify file locations to ensure that the entries in the workspace file work correctly on different client computers.

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 C++, it differs from the actual file structure as follows:

For some source control tasks, you need to specify the names and locations of these files. To view this information, right-click on the file and choose Properties. The Source File Properties dialog is displayed. The General properties option displays the complete file name and path.


Perforce 2007.2 Using IDE Plug-ins
<< Previous Chapter
Basic Concepts
Table of Contents
Index
Perforce on the Web
Next Chapter >>
Microsoft Visual Basic
Please send comments and questions about this manual to [email protected].
Copyright 2001-2007 Perforce Software. All rights reserved.
Last updated: 09/07/07