Ana səhifə

Using Perforce under the Microsoft Source Code Control api


Yüklə 11.19 Kb.
tarix18.07.2016
ölçüsü11.19 Kb.

Using Perforce under the Microsoft Source Code Control API


Introduction:

The “Microsoft Common Source Code Control” implementation contained in p4scc.dll allows users to select perforce as their “source code control” provider in development environments which use Microsoft’s Common Source Code Control. These environments include Microsoft Visual C++ 4.0 and 5.0, Microsoft Access Developer Edition, Visual Basic, CodeWright 5.0, Visual J++, and possibly others. (The DLL currently has only been extensively tested with Visual Studio and Microsoft Developer Studio.) Installing the DLL enables direct access from the development environment to basic version control operations like checking out files and submitting changes. Both the development environment and Perforce’s DLL display dialogs guiding the user through the various operations. The exact process varies from tool to tool because the tool itself is largely responsible for the dialogs and menus through which the user interacts with perforce. Since Microsoft Visual Studio 97 includes Visual C++ 5.0, Visual J++, and others this document focuses on how the integration works in this environment. (The behavior differs only slightly from MSDEV and VC 4.x.)



Installation:

To install the Perforce SCC integration, place the files p4scc.dll and sc.exe in the directory where you want the files to reside and run p4reg.exe. You must execute p4reg.exe from the directory containing p4scc.dll. p4reg.exe creates the registry entries that inform Visual Studio that Perforce can be used as a version control system and that allow Visual Studio to find p4scc.dll. If you wish to change the location of the DLL, you must run p4reg.exe again to update the registry entries. If it is installed correctly, the “Source Control” item on the “Project” menu in Visual Studio should be enabled when you run Visual Studio.



Using Perforce as the Source Code Control Provider:

After installing the Perforce SCC integration, you can perform version control operations on any files in your projects that are under your Perforce client’s root directory. For this to work, the P4CLIENT and P4PORT environment variables must be set correctly so Visual Studio is aware of them. To insure that Visual Studio finds the variables in your environment, add them to your environment in the “Environment” tab in your “System” control panel. You may want to open a new Command Prompt and run “set” to verify that the variables are set correctly. Alternatively, you may set the environment variables at a command prompt and invoke Visual Studio from the same command prompt by running msdev.exe. In the current version, it is not possible to change the client and port from within Visual Studio; however, we may include this capability in a future release.

To access perforce from Visual Studio, you must open a project workspace or create a new one. At this point, Visual Studio enables various options under the Source Control menu item depending upon the files in your project. Visual Studio places “Source Control Menu” under the “Project” menu. For example if your project contains files under your client’s root directory that have not been added to the depot, the “Add to Source Control” appears enabled. (The “Remove form Source Control” option will also be enabled for unknown reasons. Choosing it does nothing.) Remember the files must be under your client’s root directory. If the file is in the depot but not opened, Visual Studio enables the “Check Out” item on the “Source Control” menu.

Most of the options under the source control menu are self-explanatory. Choosing one causes Visual Studio to display a dialog with a list of files for which the chosen operation can be performed. The user selects the files for which he or she wishes to perform the operation, enters a comment if applicable, and clicks OK. Any errors, warnings, or status messages appear in the Source Control Tab in the Output pane.


Version Control Command Available from Visual Studio


  • Get Latest Version: When the user selects this option, Visual Studio displays a list of files in the project. Currently, Visual Studio displays files even if you already have the latest version.

  • Check Out…: The “Check Out” menu item displays a list of files in the project that can be opened. Selecting files and clicking “OK” causes the selected files to be opened for edit

  • Check In…: This option displays a list of files to check in, and allows for a comment. If multiple files are selected they are submitted as a single change. The comment field may be left blank, and a default comment will be provided. If the “Keep checked out” box is selected, the files are checked out again after Visual Studio submits the change. The dialog contains a difference button, which displays the difference between the client’s version of the file and the depot’s version using windiff. (By default the files are compared with windiff; however, this may be changed by setting the “DIFF” environment variable to an alternative diff program.)

  • Undo Check Out…: This option issues a “p4 revert” for the selected files, replacing the client’s version with the depot version of the file. No output appears in the “Source Control” window.

  • Add to Source Control…: Adds files to depot, and submits the change. Selecting the “Keep checked out” box opens the file after submitting it to the depot. Visual Studio provides a default comment when the comment field is blank.

  • Remove from Source Control…: This command issues a “delete” followed by a “submit”. It removes the selected files from the depot, but it does not delete them from the user’s hard disk. Note that invoking “p4 delete” from the command line deletes the file from the user’s hard disk when the user submits the change.

  • Show History…: Displays the output from “p4 filelog” in the Source Control output pane. This operation currently only works when a single file is selected.

  • Show Difference…: Displays the differences between the file on the client and the file in the depot using windiff or the program specified by the “DIFF” environment variable.

  • Perforce Properties: Prints some information regarding the currently selected file in the output window.

  • Refresh Status: Queries the depot for status information for the files in the project. Although Visual Studio usually gets this information automatically, it may be necessary in some cases when the depot is changed outside of the environment or by another client.

Context Menus:

Many of the source control operations are also available through context menus that appear when the right mouse button is held down when selecting an object. Holding the right mouse button down over a file, which you are currently editing, displays a menu containing the valid source control options for that file. Experimentation reveals that source control operations are available through the right mouse button in many contexts.



Source Control Tab on the Options Control Panel:

The options control panel in Visual Studio currently allows the user to changes a variety of properties that affect source control. Currently all of these properties are controlled by Visual Studio. Analogous options may not exist in other environments. The one item that warrants further explanation is “Include only selected files in dialogs.” When this option is disabled, choosing an action from the “Source Control” menu displays all the files for which the action is valid in the operation’s dialog box. With this option enabled, Visual Studio lists only the currently selected files for which the action is valid. A variety of factors appear to determine the files that are currently selected. For example if the focus is in a file which you are currently editing, that file will be the currently selected file; however if you have a file or files selected in the file browser pane, those files will be the currently selected files. Selecting a class in the class browser pane selects the files associated with that class. If you do not see all of the files that you wish to manipulate in a dialog, you may want to disable this option.


Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©atelim.com 2016
rəhbərliyinə müraciət