Setting Perforce preferences

To set Perforce preferences in Visual Studio, go to Tools > Options. You can specify preferences on the following nodes in the Options dialog under Source Control:

You can specify keyboard shortcuts for P4VS commands under Tools > Options > Environment > Keyboard.

Perforce - Connections

Set the following preferences to determine how you connect to the shared Perforce service in Visual Studio:

When opening a project under source control

  • Show the Perforce Connection dialog: Prompt for connection settings whenever you open a project that is under Perforce source control.
  • Connect to the server using my most recent settings: Without prompting for connection settings, reconnect to the Perforce service you were connected to during your last session.
  • Connect to the server using solution-specific settings: Without prompting for connection settings, connect to the Perforce service you last used for the solution or project that you are opening.
  • Connect to the server using my Perforce environment settings: Connect using Windows environment variables for Perforce connections, which you set using the Perforce Command-Line Client or P4V, the Perforce Visual Client. For more information, see the P4 User Guide or the P4V help.

Opening and closing connections

  • Use IP-specific tickets when logging in: Specifies whether your login ticket is restricted to the IP address from which you are connecting.
  • Automatically log off when closing a connection: Specifies whether your ticket is invalidated when you log out.

Perforce - Data Retrieval

Set the following preferences to determine how P4VS retrieves data from the shared Perforce service:

Data retrieval:

  • Check server for updates every: Specifies how often P4VS checks the Perforce service for updated file information. Frequent checks enable P4VS to display current file status but increase the workload on the Perforce service.
  • Maximum number of files displayed per changelist: Specifies the maximum number of files displayed in a changelist, to help minimize the time required to handle and submit very large changelists. This setting affects only the display of changelists, and does not limit the number of files that a changelist can contain.
  • Maximum size of files to preview: Limits the size of image files displayed in the Preview tab, to limit the amount of image data sent from the Perforce service to P4VS.
  • Number of changelists, jobs, or labels to fetch at a time: Specifies the number of specifications read in each batch fetched, to minimize server load and maximize P4VS performance. To retrieve all entries, specify 0.
  • Automatically update file status when selection changes: Select to enable the Perforce status badges in Solution Explorer to update automatically when you click or hover over the file icon, without having to click Refresh. Deselect to improve performance.

Optimize file status retrieval:

Note

The Treat Solution/Projects as directories when selected, Preload file state, and Lazy load file state options are used to tune the performance of P4VS for your environment. If none of these options are selected, P4VS will load the metadata for each file individually. Unless you have a small project you should look to use one of these options.

  • Optimize file state retrieval: Select to apply optimizations on retrieving file state. Subordinate optimization options include:

    • Treat Solution/Projects as directories when selected: Select to treat solutions and projects as directories when P4VS runs Perforce commands.

      Use this option to improve performance when working with solutions that contain a large number of projects or files. Do not use this option if the directories in the solution contain a large number of other Perforce controlled files that are not included in the solution.

      This option does not require that all the files and directories referenced by the solution are under the solution directory.

    • Preload file state: Select to preload the metadata for all of the files in the perforce depot in or under the directory containing the solution file.

      Use this option to improve performance when loading small to medium sized solutions where all the files that make up the solution are under the solution root. Only use this when there are few if any files under the solution root that are Perforce controlled that are not part of the solution.

      This option tends to work best with solutions and projects created and managed by Visual Studio. Do not use this option if the files for the solution are intermixed in directories with large numbers of other Perforce controlled files. This option will provide little improvement in performance if most of the files composing the solution are outside of the solution root.

  • Lazy load file state: Select to only load the Perforce metadata files in the solution as they are operated on using P4VS.

    With this option, Perforce metadata for a file is only retreived from the server when you select a P4VS operation on a file. At that point, the Perforce metadata will be obtained from the server, the operation performed, and the Perforce metadata updated to reflect the results of the operation. When this option is selected, the file will by badged in the solution explorer to indicate that its status is unknown (in Visual Studio 2010, this will be a blank badge). After a Perforce operation is performed on a file it will be badged to indicate its current state.

    Use this option to improve performance loading large to very large sized solutions where you are interested in only working on a few select files. This is best for solutions and projects which include large amounts of code from libraries or frameworks, large numbers of asset files such as graphical elements for a game, or large numbers of files that are generated by another development system or plugin. This option is also useful in situations where the connection to the Perforce server is over a slow network or VPN.

    • Full menu: Select to allow the full P4VS menu to be displayed on files that have not had their metadata loaded.

      This option is displayed if the Lazy load file state option is enabled. This allows you to perform an operation on a file before P4VS loads its state. If this option is not selected, you are given the option to refresh the file which will load the metadata of the file from the server and then enable the appropriate P4VS operations on that file. Please note that if you choose this option and perform P4VS operations on a file that are not valid based on its current state, you are very likely to get error messages back from those operations.

  • Do not optimize: Select this to disable all optimizations related to file state retrieval.

Perforce - Diff/Merge

To set the default diff application, select one of the following:

  • P4Merge: Perforce’s companion diff tool.
  • Other application: Browse to your preferred diff tool.

To specify arguments for third-party diff applications, enter %1 for the name of the first file and %2 for the name of the second file in the Arguments field. Perforce replaces these placeholders with the actual filenames when calling the diff application.

To set the default merge application, select one of the following:

  • P4Merge: Perforce’s companion merge tool.
  • Other application: Browse to your preferred merge tool.

To specify arguments for third-party merge applications, enter the following replaceable parameters in the Arguments field:

  • Base file: %b
  • Their/Source file: %1
  • Your/Target file: %2
  • Result file: %r

Perforce replaces these placeholders with the actual filenames when calling the merge application.

Perforce - General

Set the following display and file behavior preferences:

Display:

  • Use OS format for dates: Use the date format that the operating system uses.
  • Format dates using Perforce standard (yyyy/mm/dd hh:mm:ss): Use the Perforce format.

Files and folders:

  • Warn before reverting files: Specifies whether P4VS displays a prompt before reverting files.
  • Lock files on checkout: Select to lock files every time you check them out. Locks prevent other users from checking in changes while you work on a file.
  • Prompt for changelist when checking out or adding files: Specifies whether P4VS prompts you to choose a changelist when you add or check out files.
  • Automatically add new files to Perforce: Select if you want P4VS to mark new files for add in a pending changelist.

    This option works together with the Prompt for changelist when checking out or adding files option to determine prompting behavior when you add new files to a project or solution that is under Perforce control:

    • If both this option and the Prompt for changelist option are enabled, P4VS prompts you to mark new files for add.
    • If this option is enabled and the Prompt for changelist option is disabled, new files are automatically added to the default changelist without any prompt.
    • If this option is disabled and the Prompt for changelist option is enabled, no prompts will appear; you must manually mark new files for add.
  • Update related projects when reverting moved files: Select to revert file renames or moves in Visual Studio when you revert a Perforce rename/move operation.

    If you do not select this option, Visual Studio continues to show the new file name or location despite the fact that Perforce has reverted the file to its original name or location.

    Note

    If you revert a folder rename/move in P4VS, you must manually revert the name or location in Visual Studio, regardless of your preference selection.

  • Use Visual Studio to view file versions: Select to view previous revisions of a file (from the File History dialog, for example) in a Visual Studio editor window.

    You can use this option to view file revisions or shelved files the same way that you would view an editable file in the Visual Studio IDE.

Project and solution files:

  • Tag project and solution files as controlled by P4VS: Select to enable P4VS to write tags to the solution and project files that are under Perforce control. The default is not to tag project and solution files; P4VS does not need to tag these files to know that they are under Perforce control.
  • Set the location of new projects to the current workspace root directory: Select to put new projects in the current workspace root directory. The Location field in the New Project dialog will be populated by default with the current workspace directory.

Perforce - Ignoring Files

To avoid adding and checking in files that do not belong in the repository, you can exclude individual files or file types (for example, build or release artifacts) from source control using Ignore Lists. For more information, see Excluding Files from Perforce Control.

You can set the following preferences:

  • Enable Ignore Lists for specifying files to ignore when marking for add: Select to enable P4VS to use Ignore Lists to keep individual files or file types from being added to the Perforce repository.

    If you have already set an Ignore List file as the P4IGNORE environment variable on your local machine, that file name appears by default in the Name field. If not, enter a file name or accept the standard default, .p4ignore.txt. The first time you select Edit Ignore List or Add to Ignore List for a file in a folder in Solution Explorer, P4VS adds an Ignore List file with this file name to that folder.

    Note

    Your local P4IGNORE environment variable will be updated with the file name that you enter here. If other Perforce clients (such as p4 or P4V) on your local machine use Ignore List files, be sure to use the same file name as you use with those clients.

  • Automatically add new Ignore Lists to solution or project: Select to have new Ignore Lists appear in the Solution Explorer.

    If you do not select this option, the Ignore List file will be hidden in Solution Explorer.

  • Prompt when creating a new Ignore List: Select to have P4VS prompt you when you select Add to Ignore List in Solution Explorer to add an Ignore List to a folder that does not yet have one.

    If you do not select this option, the system creates the Ignore List without prompting.

  • Automatically ignore new Ignore Lists (add Ignore Lists to themselves): Select to have P4VS automatically add the Ignore List file to itself to prevent the Ignore List from being added to the Perforce depot.
  • Automatically add new Ignore Lists to Perforce: Select to have P4VS automatically add new Ignore Lists to the Perforce depot.

    This option works only when the Automatically ignore new Ignore Lists (add Ignore Lists to themselves) option is not selected. If that option is not selected, and you do not select the Automatically add new Ignore Lists to Perforce option, then you must manually mark the Ignore List file for add to add it to the repository.

Perforce - Logging

Set the following logging preferences. You can view P4VS log messages in the Output window in Visual Studio if you select Perforce Source Control in the Show output from drop-down list in the Output window.

  • Show p4 reporting commands: Specifies whether the Output window in Visual Studio displays all commands issued by P4VS, including commands issued by P4VS to obtain status information from the Perforce service.
  • Show p4 command output for file operations: For verbose log messages, enable this option.
  • Enable logging to file: Logs P4VS activity to the specified file.

    • Name: Specifies the name and location of the log file.
    • Size: Specifies the maximum size of the log file.

Keyboard shortcuts

Go to Tools > Options > Environment > Keyboard. You can find P4VS commands by entering P4VS in the Show commands containing field.

For more information about creating keyboard shortcuts in Visual Studio, see the Microsoft Visual Studio help.