Perforce (p4) use

Source: Internet
Author: User
Tags compare binary files diff documentation perforce xms

P4 submit the proposed process:

1. P4 Sync

2. Overwrite or change the local file

3. P4 Delete or direct delete obsolete files

4. P4 add: Add new files to Depot

5. P4 diff-se: View edited files

6. P4 Diff-se | P4-x-Edit: Put all the changed files as open for submit, and for files that are overwritten or not with P4 edit, this command is required to make the file open for easy submission

7. P4 diff-sd: View deleted files (not deleted with P4 delete)

8. P4 DIFF-SD | P4-x-Delete: The deleted file is a opened state for easy submission

9. P4 submit-d ' xxx ': Submit

P4 can be submitted, as long as other people's submissions do not affect your submission, can be submitted at any time, this, and svn the same, and git different.

You can use P4 edit-k file to set file to a opened state.

Recovery:

P4 revert-a (file optional): Revert all open files that already exist

P4 revert file:revrt an existing file or new add file that has been opened

P4 sync-f: Forced sync to head changelist, if there are open files, need to first revert

Here is the information on the web, generic but not practical:

Environment variables:
Export P4PASSWD=ABCDEFG
Export P4CLIENT=XXX//This can not be set
Export P4USER=YYY
Export P4port=ip:port

1. P4 client #配置本地信息, where file downloads are configured in this area, root
2, p4 sync #从perforce download files
3, P4 login #登陆perforce
4. P4 Help #显示关于命令的帮助
5, P4-h #显示关于p4的帮助
6, P4 labels ... #显示和这个目录相关的标签
7, P4 sync @label #同步标签label中的所有文件
8, P4 files @label #查看标签label所包含的文件列表
9, P4 revert #恢复所有打开的文件
10, p4 revert-n ... #恢复所有打开却没提交的文件
11, P4 branch Brach #新建分支
12, p4 Integrate-b Brach #合并分支brach中描述的文件
13, P4 opened #查看打开的文件
14, p4 help commands #查看p4所有命令的帮助
15, 4 dirs-h. #显示当前目录
16, p4 branches #显示所有的分支
17. P4 Delete filename #从p4删除文件
18, p4 changelists-l ... #显示当前目录下面所有文件的修改注释
19, P4 label label #新建标签 label, edit label
20, P4 tag-l label ... #把当前目录下面的所有文件添加到标签 label
21, p4 changes ... #当前目录的changelist
22. P4 Sync @10931 #sync file @changelist
23, P4 sync ... @10929 #only sync localfile@changelist
24, p4 help revisions #查看关于文件范围的帮助

Export a good variable, and then configured with 1, you can use P4 sync for code download

If CommandBar is a directory then add/..., if it's a file, don't

Using P4 on a virtual machine

It is divided into the following steps:

1. To use P4 on Linux, you need the virtual machine to be able to access the extranet

2. Installation and Configuration P4

3. Configure the source code environment

Here is a detailed description of each step: (I call our work machine itself "host")

1. Configure the virtual machine to access the external network. Set the steps as follows

1) Shared host network card

Local connection-"Properties-" advanced-"choose to allow other networks to pass this ... and select Home Network connections for VMware network Adapter VMnet1

2 Set up virtual machine IP information

Choose traditional ....


3) Set static IP

IP 192.168.0. Xxx

Subnet Mask 255.255.255.0

DNS 192.168.0.1 (Edit/etc/reslove.conf)

Default Gateway 192.168.0.1

2. Installation and Configuration P4

1 Download Client http://www.perforce.com/perforce/downloads/index.html I am using the Perforce command-line client (P4)

2 Put the client in the folder/usr/local/bin. This allows you to use the P4 command directly in any directory

3 Configure the client, there are many ways to help online, I use the configuration file method. Steps are as follows

A. Create a new folder P4config (customizable) under/usr, and create a new file P4.configfile inside the folder.

B. With VI clocking P4.configfile, enter the following configuration

p4client= (define your work space, such as YGXU_XMS)

p4passwd= (Your password)

p4port=10.12.33.133:1700

P4user= (your username)

Save exit.

C. Configure environment variables. You need to reboot this before it takes effect.

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

#

# Pv4 config file path

#

If Test-z "$P 4CONFIG"; Then

Export P4config=/usr/p4config/p4.configfile

Fi

D. Test environment configuration success

Command P4 info, if the connection information is displayed, OK, otherwise you will be prompted not to connect

3. Configure the source code environment

Using the command P4 client will have the following information displayed

Client: The workspace you configured above

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

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

Owner: Your username

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_xms/xms/ss7_mainline/...

....

Two places need to be modified:

A. Root. This determines where your code will be placed, as above, mine is/home/hammer

B. View. This decision you need to take the code down, because the general will not take all the code down, on Linux we generally only need XMS ss7_mainline, so the other deleted, modified to the above appearance

Notice, must ensure that the space is sufficient, suggest first delete the original ss7_mainline, use the Shrink tool to reclaim space and then take the code.

Well, use the P4 Sync command, and you can go on working.

For instructions on P4 use, the documentation is as follows:

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

More detailed command Format reference http://www.perforce.com/perforce/products/p4.html

P4 Client Download http://www.perforce.com/perforce/downloads/index.html

*************************************************************************************************************** Quick Start Perforce

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

Concept
First talk about the concept, generally speaking, version control software will be divided into the client and Server,server responsible for some management code and document warehouse, control the permissions of each user, record version upgrade history, and so on, client use some kind of client connected to the server to complete the code, Document modification, submission and other work, Perforce is no exception. On the server side perforce done very streamlined, not too much reliance, a p4d, configuration is also very simple, its main task is to manage a file warehouse depot. In the client side has the user and workspace two concepts, user name is a user registered on the server, each user can have 0 or more workspace, can even switch to someone else's workspace up, As long as you have permission. Simply put, Workspace is a depot to the local map, such as writing//depot/foo/...//myspace/bar/... The depot inside the Foo directory to map all the things below to the local bar directory, MySpace is related to the specific workspace, in the setting of workspace can set its absolute path.

[Configuration prior to connection]
First we need a user, assuming there is a user test, no password.
$p4config=p4conf.conf; Export P4config
Used under Windows
P4 set p4config=p4conf.conf
This command sets an environment variable p4config, the filename can be defined by itself, which can store the configuration of the client. Configuration information in Unix systems can be written in the environment variables, Windows can all write to the registry, but I prefer to create a configuration file under a certain directory, so that it is convenient to switch different workspace. Then we can start editing this p4conf.conf configuration file, and the format is very simple setting=value form.
Create a workspace directory in which to create a new p4conf.conf file that reads as follows:
p4port=192.168.0.1:1666
P4user=test
P4client=test-client
This is the simplest configuration file, P4port named the server's IP and port, IP can also be replaced with the computer name, such as
p4port=p4server:1666
If left blank p4port=1666 this represents the default connection to the local server, as in p4port=127.0.0.1:1666.
P4user is the username, P4client is the current workspace name, the name can be arbitrarily taken, just a logo.
This is the time to run the CD to this directory
$P4 Info
Look at what the output is, if it shows the following
User Name:test
Client name:test-client
Client Host:computername
Client unknown.
Current directory:/home/test/workspace
Client address:127.0.0.1:1508
Server address:192.168.0.1:1666
Server root:.
Server date:2006/07/26 00:28:12 +0800 Standard time
Server version:p4d/ntx86/2006.1/102189 (2006/06/27)
Server License:none
means that the successful connection to the server, if there are errors like this, it is necessary to check the P4port is not set up correctly
Perforce Client Error:
Connect to server failed; Check $p4port.
TCP Connect to 1666 failed.
Connect:1666:wsaeconnrefused
Here, the most basic client configuration has been completed, very simple:-) There are other settings that can be stored in the configuration file, such as
P4editor Specifies that the VIM editor should be used by default when editing, P4diff specifies the tool to use when comparing files.
P4PASSWD when a user needs a password, they can provide a default password, others can refer to the official document P4 user ' s Guide

[Configuration after connection]
All previous settings were stored in environment variables, configuration files, or the registry, which only defined the behavior of a client, a large number of things such as tracking user changes, open, submitted files, and so on are recorded by the server, So now 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 that holds some of the user's information, such as user names, Email,fullname, and so on, that users can modify some of these settings themselves, and then automatically submit them to the server to update the user settings after they are saved. The editor used in this procedure can be specified in an environment variable or in a configuration file (P4editor).
$P4 Client
As above, this command edits a client's configuration file. Root corresponds to the absolute path of workspace on this machine, and the options define some client attributes, such as the unlocked value allows other users to switch to your workspace, and other definitions refer to the official documentation. The view configuration is more important, and it defines the mapping of the files above the server to the workspace. For example
depot/...//test-client/...
The left and right sides represent the source and destination addresses, separated by spaces, meaning to map all files in the server depot to my working directory (the absolute path specified with the root parameter). Mappings can have multiple lines:
depot/src/...//test-client/local-src/...
depot/doc/...//test-client/local-doc/...
This maps the code and document to local, and does not necessarily use the same name as the server. There may be some files or directories that need to be emitted, and only a minus sign must precede the mapping:
-//depot/doc/file1.txt//test-client/local-doc/file1.txt
This excludes a file. Be aware of conflicts in this process as follows:
depot/src/...//test-client/src/...
depot/doc/...//test-client/src/...
Map all two directories on the server to the same directory locally.
The above procedure uses a wildcard character "..." which recursively matches all files under this directory as well as subdirectories, and another "*" that is not used above to match a single directory of files, such as//test-client/src/*.c matching the SRC directory under all the. C The file as the extension.
It says that if you map all two directories on the server to a local directory, there will be a conflict, which will overwrite the former, but if you write this:
depot/src/...//test-client/local-src/...
+//depot/doc/...//test-client/local-src/...
will produce a different effect, the files in the two directories will appear in the LOCAL-SRC directory, but if there are files with duplicate names, the latter will overwrite the former.
At this point, the client configuration is basically completed, you can $p4 sync a bit of the server to grasp the things down to see:-)
In addition, if you want to delete this cient words very simple $p4 client-d test-client can be

[File Management]
Configuration for so long, now began to get to the point, file management is our use of perforce core work. Simply put, file operations can be grouped into three categories: adding files to depot, modifying and submitting files, and deleting files.
Before this, it is best to ensure that the latest version of workspace files and servers is synchronized, using the command:
$P4 sync ...
If you need to sync to a version, add a #1 number to represent the version number, and if you need to force all files to be synchronized, you can add the-f argument. The specific use of sync can be ordered
$P4 Help Sync
BTW: You can try $P4 Help

To add a file:
$P4 Add *.txt
Add all files in the current directory to TXT to the depot directory, and note that you cannot use wildcard characters when adding files ... Because... A server is responsible for parsing, at which point the server does not know what file to add, but can use *, it is the shell responsible for parsing.
In addition, all modifications are not committed to the server until they are submitted.

To modify a file:
$P4 Edit//DEPOT/SRC/A.C
After this file is executed on the server it will be recorded that the current client is already editing this file, there is only one action locally, is to remove the read-only attribute of the A.C file, at which point we are free to edit the file using some kind of editor, where all the files are read-only, and do not manually remove the read-only attribute to edit, because the server will not be able to track the client's modified records.

To delete a file:
$P4 Delete//depot/doc/a.pdf
Note that this file is not deleted on the server until you submit it.

Undo Modification:
$p4 revert *.txt
This will be all previously added or modified, txt as the extension of the file all to the original state, the original added files will be deleted, modified files are restored to the implementation of P4 sync version.
Finally, we can submit all the changes above:
$P4 Submit
At this time P4 will invoke the default or P4editor designated editor to edit a configuration file, which contains the author's information, the description of this submission and the listed documents involved, in general, the description of a complete fill save on it. Then you'll see a bunch of things on the screen, and finally show change XXXX submitted. It means the submission has been successful. If there is an error, there may be a conflict or other situation, the question about the conflict left behind to say ~ ~_~ ~
diff between files:
$P4 diff file
$P4 diff2 file1 file2
The former is compared on the client side, using the client-side configuration tools, compared to Perforce's own diff I prefer Vimdiff:-) the latter is compared to the server side, returning two files (and possibly many files).
Work offline:
When working online, all files are modified by the server to record, the file read and Write permission settings are synchronized with the server, but one but offline need to use another method to manage workspace inside the file.
First you need to manually remove the read-only attribute for those files that are waiting to be modified, and then you can start modifying them, waiting for two things to do when you establish a connection to the server:
1 Find all 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 will behere is perforce diff detailing:

Overview
Compare files in one client workspace to file versions in one version library
Grammar
P4 [G-opts] diff [-dflag-f-M max-sa-sb-sd-se-sr-sl-t] [file[rev#] ...]
Describe
The P4 diff command runs a diff program on the Perforce client that compares the file in the client workspace with the version file in the version library.
This command requires a file parameter containing the version identifier. If a version identifier is included, the file in the client workspace is compared to the specified version file. If you do not include a version identifier, the client workspace file is compared to the version that is currently being edited (usually the latest version). In both cases, the client's files must be opened for editing, or the comparison must be compared to a version file that is different from the last synchronized version of the client file.
If the file name includes wildcard characters, all files that are open to match the template are compared. If no file parameters are provided, all open files are compared to their corresponding files in the version library.
By default, the diff program uses the built-in P4 client program. If you want to change the diff program to run an external program, set the P4DIFF environment variable or register a variable to point to the new program.
Options
-F

Force a comparison (if no version identifier is available, compare to the latest version), even if the client file is not open for editing
-dflags

Pass options to the diff program that follows (read the use tips below)
-M Max
Qualifying output displays the first max file for diffs (or status)


-sa

Displays only those files that are open that are different or non-existent from the version library version of the file

-sb

Displays only the names of the files that have been resolved to the integration, but that have been modified in the parse back

-sd

Only displays the name of a file that is not open and does not exist in the client workspace, but exists in the version library.
-se

Displays only the names of files that are not open in the client workspace but are different from the version in the version library

-sr

Displays only those files that are opened in the client workspace that identify the version in the version library.

-SL file ...

All open files are compared to the version library and then displayed in three states same, diff, or missing.
If You use the THE-F flag together with THE-SL flag, the files that are the open for edit are also compared and their status islisted .

-T
Compare even file types that are not text-type files of different
G-opts read the Global Options section

Use hints
Can File Arguments use Revision specifier?

YES
Can File Arguments use Revision Range?

NO
Minimal Access level Required
Read

The diff options supported by P4 diff are:
Options
Name
-dn
RCS output format, showing additions and deletions of files and related rows
-dc
Text output format, showing line numbering range and three-line change content
-ds
Summarizes the output format, showing only the total number of rows added, deleted, or modified
-du
Unifiedoutput format, showing added and deleted lines with sufficient context forcompatibility with the patch (1).
-dl
Ignoreline-ending (CR/LF) Convention when finding diffs
-db
Ignorechanges made within whitespace; This flag implies-dl.
-dw
Ignorewhitespace altogether; This flag implies-dl.
L
In order to pass more than one option to the diff program, you can package them. For example:
P4 Diff-dub File
Specifies a unified diff that ignores changes in whitespace.
L
?
The header line of an Unifieddiff produced with THE-DU option for use with patch (1) displays filenames Inperforce syntax, Not a local syntax.
Example
P4 diff File#5

Compare "File" in the client workspace with version fifth in the version library
P4 diff @1999/05/22

Compare all open files in the client workspace with the version modified by May 22, 1999 in the version library.
P4 Diff-du File
Compares the file to display output that conforms to the patch (1) utility format.
P4 DIFF-SR | P4-x-Revert
Restores all files that have been opened without modification.
This is differs from P4 revert-a (revert allunchanged files, where resolving a file, even if no changes are, made as A change), in which it reverts files whose workspace content matches the depotcontent, including resolved files that happen To is identical to those in Thedepot.
The first command displays all files that have been opened without modification. The second command (running p4-x and taking arguments, one perline, from standard input, abbreviated as "-") reverts each File Inthat list.
(This is the UNIX version of this command;it uses a pipe.) Most operating systems have some equivalent way of Performingthese operations in series).
P4 for more information about the-X option, read the Global Options section

Related commands
Compare file versions in two-version libraries
P4 diff2
View the entire contents of a file
P4print
*************************************************************************************************************** *********************perforce Use Chinese tutorial: P4 diff2Perforce command: P4 diff2

Overview
Compare two versions of a file in a version library
Grammar
P4 [g-opts] diff2 [-dflags-q-t-u]file1[rev] File2[rev]
P4 [g-opts] diff2 [-dflags-q-t-u]-bbranch [[Fromfile[rev]] Tofile[rev]
Describe
The P4 diff2 command uses the diff program built into the Perforce server to compare two versions of a file in a version library. These versions usually refer to two different versions of the same file, but they can also be versions of two completely different files. If no version is provided to the file parameter, then the latest version is used for comparison.
P4 DIFF2 does not use a diff program defined by the environment variable P4diff. The diff algorithm used by the P4 diff command runs on a perforce server machine and always uses the diff program built into the server
You can specify a file template with (or no) version identification at the location of the specified file parameter, which can cause perforce to perform a diff command on those matching templates. If you invoke the P4 diff2 command using a file template, use quotes or backslashes to exit the file template from the OS shell, then determine that the wildcard characters in the two templates match.
Perforce presents the diffs in UNIX Diffformat and prepended with a header. The start section is formatted as follows:
= = = File1 (filetype1)-file2 (filetype2) = = Summary
The values and meanings that summary may appear are as follows:
Content: Different contents of a file version
Types: Content is exactly the same, but the file type is different
Identical: version has the same content and file type
If the file file1 or file2 does not exist in the specified version, the start section will display summary as <none>.
Options
-Q
Quietdiff.
Displays only the header portion of the table, and does not display content at the same time as the content and type of the file version
-dflags

Run the diff program as a parameter to one of the standard UNIX diff options. Read the "Use Tips" later
-B Branchname
Fromfile[rev] Tofile[rev]
Use the definition of a branch to compare files in two branch lines of code. The file being compared can be defined by any one of the FromFile or tofile in the document template
-T

Compare even file types that are not text-type files of different
-U
Generateunified output format, showing added and deleted lines with sufficient contextfor compatibility with the patch (1) Utility. Only those the files that differ areincluded. File names and dates remain in Perforce syntax.
G-opts
Read the Global Options section
Use hints
Can File Arguments use Revision specifier?

Yes
Can File Arguments use Revision Range?

NO
Minimal Access level Required
Readaccess necessary for both file revisions

The diff flagssupported by P4 diff2 are:
Options
Name
-dn
RCS output format, showing additions and deletions of files and related rows
-dc
Text output format, showing line numbering range and three-line change content
-ds
Summarizes the output format, showing only the total number of rows added, deleted, or modified
-du
The unified output format showing added and deleted lines with sufficient context forcompatibility with the patch (1).
-db
Ignore changes made in spaces
-dw
Ignore the spaces that are joined together
In order to pass more than one option to the diff program, you can package them. For example
P4 Diff2-dub File1 File2
Specifies a unified diff that ignoreschanges in whitespace.
The header lineof a unified diff produced with THE-DU option for patch (1) use displays thediffed files in Perforce syntax , not a local syntax.


When the P4 diff2 command is used to compare binary files, the row
... files differ ...
will be shown if they are not recognized.
Option-B branch [[Fromfile[rev]] Tofile[rev]] The first time see is may feel incorrect. Since The Branch specification maps fromfiles to Tofiles, why Wouldyou, specify both FromFile and ToFile file patterns? You are wouldn ' t, but thissyntax allows you-specify a FromFile file pattern and a tofile revision, Ora FromFile, revision D a tofile file pattern.
Example
P4 diff2-ds file#1 File

Compares the second and latest versions of the file and displays information that is added, changed, or deleted in the file
P4 diff2
File@34 file@1998/12/04
Diff the revision of file that is thedepot after Changelist is submitted against the revision in the depot Ght on December 4, 1998.
P4 diff2
depot/rel1/...//depot/rel2/... #4

Compare all the latest files and version libraries in the version library//depot/rel1//depot/rel2 Fourth version file
P4 diff2
depot/rel1/*//depot/rel2/...

Not allowed. The wildcard pattern for each file must match
P4 diff2
-B branch2//depot/rel2/... #2 @50
Compare the second revision of the Filesin//depot/rel2/. To the files branched from it by branch Specificationbranch2 a t the revision they were at Changelist 50.
Related commands
Compare version files in a client workspace to a file in a version library
P4 diff

View the entire contents of a file
P4 Print

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.