Talk about Perforce

Source: Internet
Author: User
Tags perforce

Internship is coming to an end, and one of the gains is learning to use perforce!

The Perforce SCM system is a software configuration management tool built on a scalable client/server structure. only apply

TCP/IP, developers have access to multiple Perforce clients (GUI, WEB, or command line) of several platforms

Perforce server. Perforce can be quickly and easily deployed, even for large or distributed sites, requiring only minimal

Degree of management. Perforce can be used in more than 50 operating systems, including versioning, workspace management, change handling, and

A powerful branching model. The p4v described here is a perforce client that can be used across platforms.

Like other version control tools, Perforce is also based on the CS architecture, which has a central server that other clients connect to through the network, such as:

1. Server connection

Fill in the correct server name, port, user name, and workspace settings.

2. Client Main workspace



The main interface of Perforce is shown, and most of the operations are done under this interface. The interface is divided into three regions:

Zone 1: Displays the contents of deport and workspace, called the catalog area.

Zone 2: Lists some of the action properties of the file, called the operation area.

Zone 3: Provides a hint of the action being performed, called the information area.

Directory Area

The directory area consists of the Depot directory area and the workspace directory area.

--->depot directory area

Shows the structure of the visible directory on the server (different user rights settings, the visible directory is also different), which also with the workspace view map

File path, you can specify a file path to display. Here, the actions you can perform include: Check out, submit,

Get Latest Revision, Revert files and other operations.



--->workspace directory area

Shows the directory structure of the local workspace that is mapped to the files on the server, which is also related to Workspace view.

Operation Ibid.

Operating Area

The contents of the operation area are mainly composed of several workspaces.

---> Pending changelists work area

This shows the files that the current user is modifying and the files that other developers are modifying.

Of course, you just need to care about your own project. When you perform a: Mark for Add,check out operation, this information

is displayed in the Changlist list, and its status is displayed by a different icon. If you have modified it, execute the Submit

You can submit an update file, but you can also do revert discard the changes you made.

--->submitted changelists work area

Shows the actions that all recent project group members have made on the project.

It can be obtained such as: changlist number, modification time, modify the contents of the file, the reason for modification and the modification of the person and other information.

---> Workspace work area
In this workspace, you can display all client workspaces that are connected to the server.
In this workspace, you can perform actions such as create, edit modify, delete user workspaces, and so on. (Provided that there is permission to execute.) )

--->history work area
View the change history information for the specified file.

---> Labels work area
View all of the current label numbers.
In this workspace, you can complete the creation of a label, modify the content, and so on. (Provided that you have permission to perform this operation.) )

--->branchs work area
View all current branch numbers.
Complete the creation, modification, deletion, etc. of branch in this workspace. (Provided that you have permission to perform this operation.) )

In addition to the above-mentioned work areas, there are files, jobs and other workspaces. Including the above

Six types, these workspace windows can be switched from one interface to another, as shown in the tabs:



Information area
Consists of a window (Pane windows).
Pane windows
This is a very useful window, called the message window area, the bottom of the window is. Any information about your operation will be

Appear here, including success, warning, error and other information. In particular, after a failure to perform an operation, the information here is

Important. In general, it is possible to deal with unexpected situations or irregular operations based on the information here.
3. Daily operation of Perforce
3.1 Adding (Add) Folders and files
---> Right click on the folder/file selected to add in Workspace, select "Mark for Add" to add the file.



The Add file behavior is displayed in the pending Changelists workspace. After adding good folders and files to the workspace, the icon has

A red plus sign indicating that the folders and files that were added at this time are still in the client's workspace and have not been submitted to the service

In the warehouse on the service. So, right click on the folder or file you want to submit, select Submit, after submission, the file at this time

are actually submitted to the repository on the server.

---> Submission (submit) Add files/folders
It is important to write down the description of the change during the submit process. Describe the details of the information, will greatly facilitate the file

Queries and traces. And at the beginning of the description, the type of operation behavior is explained in English. If add is added; modify indicates that

Modify; build means compile and so on.

After clicking Submit, you can see that the red plus sign in front of the file has been removed and the file has been shown in the reversion bar

The version number. At this point, the file has a green ID in the lower-right corner, indicating that the file currently displays the latest version.

3.2 File Modification
If you need to modify the file, first will need to modify the file check out to the local, can be modified.
---> Right click on the file you want to modify, select the Check Out command.

At this time the check out of the file has a red Hook mark on the top left, indicating that the file has been successfully removed by your check out

。 If there is a blue hook mark on the top right of the file, the file has been check out by someone else. Since the Perforce branch

Parallel operation, you can still check out the files that others have checked out again to your local computer for modification.

---> Double-click to open a file that has been checked out and modify it.
After the modification, right click on the file, select Submit, write down the description of the change list.

After that, select Save and then send code review:

After the peer reviews the approve, submit again.

PS: Collaborator is the most comprehensive code review tool built on Codecollaborator, collaborator can easily and effectively complete code reviews for development teams,

This makes the actual code review application much larger and naturally gets better code. The key factor is the user experience, which allows other members of the team to easily and collaboratively provide feedback to the author, track each comment and take action.


3. Click Submit and the file is submitted to the server, adding a new version.
Here we need to remind you that if a file check out, and did not make any changes, then please do not do

Submit operation, but right-click to select revert If unchanged, so that after the submission will not increase the number of versions of the file,

Otherwise, the server will add a version to a file that does not have any modifications.
It is recommended to think after each change: Why do you make these changes? If the changes made are meaningless, it is recommended that you do not

This file is submitted (submit), but revert the changes you have made.
3.3 Merging files
The merge operation is primarily used to resolve conflicts arising from changes in the parallel development process.
For example, when multiple people need to perform a check out operation on the same file at the same time, when the file is submit, perforce may

Error. Here are some examples: A, b Two people need to perform a check out operation on the CallKeep.cpp file at the same time.

You can see that there are hooks in the upper-left and upper-right corner of the file CallKeep.cpp, indicating that the file is being executed by at least two people

Check out operation. Because Perforce supports parallel operations, a and B do not conflict when performing check out, but

The file may be subject to an error when it is submit. The first person to perform a submit operation does not have a problem, such as a can be submitted normally,

However, if B modifies the content to conflict with a modification, then B executes the submit-times error and prompts the server to have the latest

Version (that is, a just submitted version)

At this point B get the latest version and then submit, still error.

And put a question mark on the file, stating that the server does not know what to do, because B needs to commit the version content and a conflict, need

b give the solution.

At this point, select the file, right-click, select the Resolve action.

Perforce offers three automated solutions, namely "Accept merged", "Accept Yours" and "accept theirs". When

However, you can also view where the conflict with others is, and manually resolve the conflict. Click the Run Merge Tool to display the following

The interface shown in the figure.


Zone 1: The content in the a commit version is displayed, which is the latest version on the current server.
Zone 2: Displays a and b simultaneous check out file CallKeep.cpp when the latest version of the content on the server, that is, a,

b Modify the base version.
Zone 3: Displays the contents of the file modified by B itself.
Zone 4: Shows the three versions where all the conflicts are, B can modify the files on this basis and give a solution.
Select the button in the Red Line box to decide what code to keep. After resolving the conflict, submit again.




3.4 Querying File History versions
1. If you want to query any historical version of a file, right click on the file and select Get Revision.
2. Write down the historical version number you want to view, then click Get Revision.




At this point Perforce takes out any version of the history you want.




3.5 Compare the differences between two files
The comparison operation is primarily used to see what changes have been made to a file: from which you can see what has been added, what has been removed, etc.

such as
---> Compare the differences between two different files or different versions of a file. Right click on the file you want to compare, select diff

Files command.

---> Set the file name or version of the file that you want to compare, as shown.



---> click diff to see all the different places shown, including actions to add, subtract, or modify.




It is important to note that Perforce does not support multiple file comparisons for the time being.

3.6 Synchronizing files on the server
If you find the files you need on the server and want to synchronize them to this machine, you need to select the first

Workspace Workspace, then right-click on the folder you want to download and select the Get lastest revision command to complete

The synchronization of the folder is in action.

Sometimes you cannot sync to the latest version, and you can choose the force action:


3.7 Get the label identity version file
Extracts a file that is labeled under a specific label.
---> Find the identity on the toolbar, locate the desired label number in the labels workspace in the upper right.

---> Gets the specific file under the specified label. Right-click the specified label and select "Get Revision ..." in the menu.

---> In the following dialog box that pops up, select the file you want to check out.

---> Click the "Add" button to select the file that marks the label.

Talk about Perforce

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.