Linux P4 command line

Source: Internet
Author: User
Tags perforce xms

Environment variable:
Export p4passwd = abcdefg
Export p4client = dyoldfish.com // This can be set
Export p4user = dyoldfish
Export p4port = 192.168.1.198: 1666

Command:
1. P4 Client # configure local information, where to configure the file download, root item
2. P4 sync # download files from perforce
3. P4 login # log on to perforce
4. P4 help # display Command help
5. P4-h # Show the help for p4
6. P4 labels... # display the labels related to this directory
7. P4 sync @ dyoldfish_label # synchronize all files in the dyoldfish_label label
8. P4 files @ dyoldfish_label # view the list of files contained in the dyoldfish_label label.
9. P4 revert # reply to all open files
10. P4 revert-n... # reply to all files opened but not submitted
11. P4 branch dyoldfish_brach # create a branch
12. P4 integrate-B dyoldfish_brach # merge the files described in the dyoldfish_brach branch.
13. P4 opened # view open files
14. P4 help commands # view the help of all P4 commands
15. 4 dirs-H. # display the current directory
16. P4 branches # Show All Branches
17. P4 Delete filename # delete files from P4
18. P4 changelists-L... # display the modification notes for all files in the current directory
19. P4 label dyoldfish_label # create the label dyoldfish_label and edit the label
20. P4 tag-l dyoldfish_label... # add all files in the current directory to the label dyoldfish_label
21. P4 changes... # changelist in the current directory
22. P4 sync @ 10931 # Sync file @ changelist
23. P4 sync ..... @ 10929 # Only sync localfile @ changelist
24. P4 help revisions # view help on the file range

After the export variable is ready and configured with 1, you can use P4 sync for code download, such as P4 sync // depot/proj1/... @ 21

./P4 sync // XMS/ss7_mainline/hmcallanalyzer/Java/COM/empirix/hm/realtime/commandbar/... (directory)

./P4 sync // XMS/ss7_mainline/hmcallanalyzer/Java/COM/empirix/hm/realtime/commandbar (file)

If commandbar is a directory, add/... to it. If it is a file, no need

Use P4 on a VM

There are several steps:

1. To use P4 on Linux, the virtual machine must be able to access the Internet.

2. install and configure p4

3. Configure the source code Environment

 

The following describes the steps: (I call our work machine itself a "host ")

1. Configure the virtual machine to access the external network. The procedure is as follows:

1) shared host Nic

Choose "Local Connection"> "properties"> "advanced" to allow other networks to pass through this file... and select "Home Network Connection" as VMware network adapter vmnet1.

 

2) Set Virtual Machine IP address information

Select traditional ....

3) set static IP

IP 192.168.0. xxx

Subnet Mask limit 255.0

DNS 192.168.0.1 (edit/etc/reslove. conf)

Default Gateway 192.168.0.1

2. install and configure p4

1) download client http://www.perforce.com/perforce/downloads/index.html I'm using the perforce command-line client (P4)

2) Place the client in the folder/usr/local/bin. In this way, you can directly use the P4 command in any directory.

3) There are many ways to configure the client for online help. I use the configuration file. The procedure is as follows:

A. Create a folder p4config (which can be customized) under/USR and create the file p4.configfile in the folder.

B. Use VI to punch in p4.configfile and enter the following Configuration:

 

P4client = (define your workspace, such as ygxu_xms)

P4passwd = (your password)

P4port = 10.12.33.small: 1700

P4user = (your user name)

 

Save and exit.

C. Configure environment variables. The modification takes effect only after the modification is restarted.

Open/etc/profile with VI, and add at the end

 

#

# PV4 config file path

#

If test-z "$ p4config"; then

Export p4config =/usr/p4config/p4.configfile

Fi

 

D. test whether the environment configuration is successful.

Command P4 info. If the connection information is displayed, OK. Otherwise, the system prompts that the connection fails.

 

3. Configure the source code Environment

The command P4 client displays the following information:

 

Client: The workspace configured above

Update: 2010/01/19 20:38:36

Access: 2010/01/21 02:57:38

Owner: your user name

HOST: Linux

Description:

Created by ygxu.

Root:/home/Hammer

Options: noallwrite noclobber nocompress unlocked nomodtime normdir

Submitoptions: submitunchanged

Lineend: Local

View:

....

// XMS/ss7_mainline/... // Arthur ur_xms/XMS/ss7_mainline /...

....

 

You need to modify the following two items:

A. Root. This determines where your code will be stored. As shown above, my options are/home/hammer.

B. view. this decides what code you need to get, because it generally does not take all the code down. in Linux, we generally only need the ss7_mainline of XMS, So we delete the other code and change it to the above.

Note: Make sure that the space is sufficient. We recommend that you delete the original ss7_mainline and use the shrink tool to recycle the space before getting the code.

Okay. Use the P4 sync command to continue working!

The command for using p4 is as follows:

Http://www.perforce.com/perforce/technical.html

For more detailed command formats refer to http://www.perforce.com/perforce/products/p4.html

P4 client download http://www.perforce.com/perforce/downloads/index.html

**************************************** **************************************** **************************************** *

Quick Start With perforce

What is perforce? Reference http://www.perforce.com

[Concept]
Let's talk about the concept first. Generally, version control software is divided into client and server. server is responsible for managing code and document repositories, controlling permissions of various users, recording version upgrade history and other things, the client uses a client to connect to the server to complete code, Document Modification, submission, and other work. Perforce is no exception. On the server side, perforce is very simple and does not have many dependencies. It is easy to configure with a p4d. Its main task is to manage a file warehouse depot. The client has two concepts: user and workspace. As the name suggests, a user is a user registered on the server. Each user can have zero or multiple workspace, you can even switch to another workspace, as long as you have the permission. In short, workspace is a deing from the depot to the local machine. For example, write // depot/Foo /... // MySpace/BAR /... map everything under the foo directory in the depot to the local bar directory. MySpace is related to a specific workspace. You can set its absolute path when setting the workspace.

[Configuration before connection]
First, we need a user. Assume that a user named test already exists and there is no password.
$ P4config = p4conf. conf; export p4config
Use in Windows
P4 set p4config = p4conf. conf
This command sets an environment variable p4config. The file name can be defined by yourself, which can store client configurations. In Unix systems, configuration information can be written into environment variables, while in Windows, it can be written to the Registry. However, I prefer to create a configuration file under a directory, in this way, you can easily switch between different workspaces. Then we can start to edit the p4conf. conf configuration file. The format is very simple in the form of setting = value.
Create a workspace directory and create a p4conf. conf file in it. The content is as follows:
P4port = 192.168.0.1: 1666
P4user = test
P4client = test-Client
This is the simplest configuration file. p4port indicates the IP address and port of the server. The IP address can also be replaced by the computer name, for example
P4port = p4server: 1666
If p4port = 1666 is left blank, the local server is connected by default, just like p4port = 127.0.0.1: 1666.
P4user is the user name, And p4client is the name of the workspace currently in use. This name can be used as an identifier.
At this time, you can run CD in this directory.
$ P4 info
See what the output is. If the following content is displayed:
User name: Test
Client name: Test-Client
Client HOST: computername
Client unknown.
Current Directory:/home/test/workspace
Client address: 127.0.0.1: 1508
Address: 192.168.0.1: 1666
Server Root :.
Server Date: 2006/07/26 00:28:12 + 0800 China Standard Time
Server version: p4d/ntx86/2006.1/102189)
Server license: None
It indicates that the server is connected successfully. If an error like this occurs, check whether the p4port is correctly set.
Perforce client error:
Connect to server failed; check $ p4port.
TCP connect to 1666 failed.
Connect: 1666: wsaeconnrefused
At this point, the most basic client configuration has been completed, which is very simple:-) some other settings can be stored in the configuration file, such
P4editor specifies that the vim editor is used by default during editing. p4diff specifies the tool used to compare files,
P4passwd provides a default password when a user needs a password. For more information, see the official document P4 user's guide.

[Configuration after connection]
All previous settings are stored in environment variables, configuration files, or registries, which only defines the behavior of a client, A large part of things, such as tracking user changes, opening, and submitting files, are recorded by the server. Therefore, we need to use some commands to configure the user information at the end of the server.
$ P4 user
The result of this command is that P4 uses a default editor to open a temporary file, which stores some user information, such as the user name, email, fullname, and so on. you can modify some of the settings on your own, once saved, it is automatically submitted to the server to update user settings. The editor used in this process can be specified in the environment variable or configuration file (p4editor ).
$ P4 Client
Like above, this command edits a client configuration file. Root corresponds to the absolute path of the workspace on the local machine. Options defines some client attributes. For example, the unlocked value allows other users to switch to your workspace, for other definitions, refer to the official document. View configuration is important. It defines the workspace ing between files on the server and the workspace. For example
// Depot/... // test-Client /...
The left and right represent the source address and the destination address, separated by spaces in the middle, it means to map all files in the depot server to my working directory (use the absolute path specified by the Root parameter before that ). Ing can have multiple rows:
// Depot/src/... // test-Client/Local-src /...
// Depot/doc/... // test-Client/Local-DOC /...
In this way, the code and documents are mapped to the local machine separately, and they do not have to use the same name as the server. In this case, there may be some files or directories to be exported. In this case, you only need to add a minus sign before the ing:
-// Depot/doc/file1.txt // test-Client/Local-DOC/file1.txt
In this way, a file is excluded. In this process, pay attention to conflicts as follows:
// Depot/src/... // test-Client/src /...
// Depot/doc/... // test-Client/src /...
Map both directories on the server to the same local directory.
The above process uses a wildcard "... it recursively matches the Directory and all the files under the subdirectory, and the other one does not match the files under a single directory, for example, // test-Client/src /*. c matches all the strings in the src directory. c.
As mentioned above, if the two directories on the server are mapped to a local directory, a conflict will occur, and the latter will overwrite the former, but if it is written as follows:
// Depot/src/... // test-Client/Local-src /...
+ // Depot/doc/... // test-Client/Local-src /...
Different results will be generated. Files in both directories will appear in the local-src directory. However, if there are still files with duplicate names, the latter will overwrite the former.
At this point, the client configuration is basically complete. You can sync $ P4 to capture the items on the server and check them :-)
In addition, if you want to delete this cient, It's easy $ P4 client-d test-client.

[File management]
After being configured for so long, we are now starting to get started. File Management is our core task of using perforce. To put it simply, file operations can be divided into three types: adding files to the depot, modifying, submitting files, and deleting files.
Before that, it is best to ensure that files in the workspace are synchronized with the latest version on the server. Run the following command:
$ P4 sync...
If you want to synchronize to a specific version, add #1 to the end to indicate the version number. If you want to force synchronize all files, add the-F parameter. For the specific usage of sync, you can use the command
$ P4 help sync
BTW: Try $ P4 help.

Add file:
$ P4 add *. txt
Add all files with the txt extension in the current directory to the corresponding directory of depot. Note that wildcards cannot be used when adding files... because... A server is responsible for parsing. At this time, the server does not know what files need to be added, but it can be used *. Shell is responsible for parsing.
In addition, all modifications are not submitted to the server before the submit.

Modify file:
$ P4 edit // depot/src/a. c
After the file is executed, it will be recorded on the server that the current client is editing the file. There is only one local action, that is, set. delete the read-only attribute of the C file. In this case, you can use an editor to edit the file. Before that, all files are read-only and do not manually remove the read-only attribute to edit the file, because the server cannot track the client's modification records.

Delete an object:
$ P4 Delete // depot/doc/a.pdf
Note that the file will not be deleted on the server before the submit.

Undo modification:
$ P4 revert *. txt
This will remove all previously added or modified files with the txt extension to the original state, and the previously added files will be deleted, the modified file is restored to the version when P4 sync is executed.
Finally, we can submit all the above modifications:
$ P4 submit
At this time, P4 will call the default editor or the editor specified by p4editor to edit a configuration file, which contains the information of the submitter, the description of this submission, and list the files involved, generally, you can fill in the description item and save it. Then we will see a bunch of output items on the screen, and finally show change XXXX submitted. It indicates that the submission was successful. If an error occurs, there may be a conflict or another situation. For the conflict issue, please refer to it later ~~ _~~
Diff between files:
$ P4 diff File
$ P4 diff2 file1 file2
The former is compared on the client side and uses the client-side configuration tool. Compared with the diff that comes with perforce, I prefer vimdiff :-) the latter is compared on the server side, returns the comparison results between two files (or many files.
Offline work:
During online work, all file modifications are recorded by the server. The file read/write permission settings are also synchronized with the server, however, once offline, you need to use another method to manage files in the workspace.
First, you need to manually remove the read-only attributes of the files waiting for modification, and then you can start to modify them. When establishing a connection with the server, you need to do two things:
1. Find all the modified files, open for Edit
$ P4 diff-se | P4-X-Edit
2. Find all deleted files. Open For Delete
$ P4 diff-SD | P4-X-delete
The final submit is enough.

Related Article

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.