Previous Table of Contents Index Next
Perforce 2012.1: P4SCC User's Guide



Chapter 2
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.
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 versioning 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:
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 workspace you want associated with the version management operations you perform on the project. You must save the project in a folder under the workspace root. To choose from a list of workspaces defined for the specified server, click Browse.
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.
2.
Choose Project >Source Control >Get Latest Version... The Get Latest Version dialog is displayed.
3.
To retrieve revisions prior to the head (latest) revision, choose Project>Source Control>Show History or perform the following steps:
1.
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.
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.
5.
Click Get Revision.
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.
The Check in file(s) dialog is displayed.
2.
Click OK. The Submit Changelist form is displayed.
3.
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.
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:
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.
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.
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.
Source Control
menu appearance
Add to Source Control option is enabled
Files have been added to a changelist but not submitted to Perforce.
Check in and
Undo Check out
options are enabled
Files have been successfully submitted to Perforce.
Check out option is enabled
Which files do I put in the depot?
Put the following files in your Perforce depot:
.dsp files
.rc files
.cpp files
.h files
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.
 


Previous Table of Contents Index Next

Perforce 2012.1: P4SCC User's Guide
Copyright 2001-2012 Perforce Software.