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

Chapter 4
Microsoft Visual Studio .NET

This chapter describes how to perform Perforce source code control tasks in the Visual Studio .NET 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.

This screen illustrations in this chapter shows Visual C++, but the same dialogs are displayed regardless of which Visual Studio IDE you use.

Note

The version control dialogs displayed for check in, check out, and undo checkout include comment fields, but these comment fields are not stored by the Perforce SCC Plug-in. To avoid displaying the check in dialog, choose Check-in Now.

Configuring Visual Studio .NET with Perforce

When you configure VS .NET with the Perforce SCC Plug-in, the settings are specific to the project you are working on, so no overall Perforce configuration is required for Visual Studio. The Perforce SCC Plug-in retains project settings from session to session and it is not necessary to re-enter them.

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

Basic SCM tasks

This section tells you how to perform the following tasks.

Also note that the Exclude from source control option is intended for files that, by nature, do not belong under source code control (such as build outputs).

Adding a project to the depot

Make sure your Visual Studio .NET projects reside within your Perforce client workspace.

If you are adding a solution that contains a large number of projects, you can avoid specifying settings manually for every project by choosing the Options > Connection tab setting Bind to the workspace that matches your Perforce environment settings and setting P4CLIENT and P4PORT to the desired server and workspace.

To add a Visual Studio .NET project to your depot, perform the following steps:

  1. In the Solution Explorer, right-click the project and choose Source Control>Add Solution to Source Control. If you enabled the Show the Perforce Connections option on the Preferences > Connection tab, the Open Connection dialog is displayed, as shown in the following figure.

  2. On the Open Connection dialog, enter the required settings as follows:

  3. Click OK to dismiss the dialog.

  4. In the Solution Explorer, right-click the solution and choose Check In.

  5. The Submit Changelist dialog, listing files, is displayed.

  6. Enter a description in the description field and click Submit. Your files are added to the depot. (Using Perforce, you can verify that the default changelist has been submitted and the files are now in the depot.)

Checked-in files are displayed with a lock icon. If you attempt to edit a file that is not checked out, a check-out dialog is displayed.

Checking files out

To check out files:

  1. In the Solution Explorer pane, right-click the desired file (or the project, if you want to check out all its files) and choose Check Out... The Check Out dialog is displayed.

  2. Click OK. In the Solution Explorer pane, files are displayed with a check mark, as shown in the following figure.

The checked-out files are listed in the Pending Checkins pane.

If you branch a project using Perforce, the Visual Studio bindings must be corrected to correspond to the project's new location. To correct bindings for a branched solution, you must perform the following steps the first time you check out the branched project.

To check out a newly-branched project (first time only):

  1. Choose File> Source Control > Open from Source Control.... The Open Connection dialog is displayed.

  2. Specify connection settings for the server that contains the project you want to check out and click OK. The Open Project dialog is displayed.

  3. Browse to the branched project you want to open and double-click its .sln file.

  4. If the newly-branched files are present in your workspace, Visual Studio displays the following dialog:

  5. Click Overwrite. Visual Studio displays the Open Solution dialog.

  6. Double-click the .sln file. Visual Studio displays the following dialog.

  7. Click OK.

The project now contains correct binding information.

Retrieving files from the depot

To get the most recent revision of a file from the depot, right-click the file in the Solution Explorer pane 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. In the Solution Explorer pane, click the file.

  2. Choose File > Source Control > History. The History dialog is displayed, listing the revisions in the depot.

  3. Right-click the desired revision and choose 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 requires you to resolve the file, to ensure that you don't inadvertently overwrite other users' changes.

To sync all files for a project that resides in the depot:

  1. Choose File > Source Control > Open from Source Control... The Open Connection dialog is displayed.

  2. Enter the settings that specify the server where the project is stored and the client workspace and user with which you want to check the project files out, and click OK. The Perforce Open Project dialog is displayed.

  3. Browse to the .sln file for the project you want to sync and click OK. The project files are synced to your workspace.

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 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:

  1. In the Solution Explorer pane, right-click the file and choose Check In Now. The Submit Changelist dialog is displayed.

  2. Enter a description of your changes and click Submit.

In the Solution Explorer pane, the check marks are replaced by locks, indicating that the submitted files were checked in.

Note

To produce meaningful change history, check in related files together. For example, if you changed two different files to fix a bug, check them both in at the same time. The files are submitted in the same changelist.

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 Pending 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."

  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 Compare Versions....

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

  1. In the Solution Explorer pane, right-click the file and choose File > History. The History dialog is displayed, listing the revisions in the depot.

  2. To diff two revisions drag one revision to the other.

The diff utility 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:

  1. In the Solution Explorer pane, right-click the file and choose Undo Check Out... The Undo Check Out dialog is displayed, listing the files to be reverted.

  2. Check the files you want to revert and click Undo Checkout.

In the Solution Explorer pane, the reverted files are displayed with a lock icon, indicating that they are no longer checked out. The head revision is copied from the depot to your workspace, overwriting any changes you made to the workspace file.

You can also revert unchanged files from the Pending Changelist dialog.

Which files do I put in the depot?

Visual Studio .NET adds all appropriate files when the project is first added to source control, so, in general, don't change the contents of the changelist that is created when you choose Add to Source Control.

Put .sln files in the depot. Do not put the following files in the depot. .

These files are managed by Visual Studio .NET separately for each client computer

Miscellaneous tasks

To view the Perforce commands issued by the plug-in, choose View>Other Windows>Output and display the Source Control pane.


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