perforce 使用教程(zz)

http://www.perforce.com/documentation/perforce_technical_documentation

http://blog.csdn.net/brucexu1978/article/details/7181768

http://www.perforce.com/perforce/doc.current/manuals/cmdref/sync.html

P4递交建议流程:

1. p4 sync

2. 覆盖或者改动local文件

3. p4 delete or 直接delete 废弃的文件

4. p4 add: 增加新文件到depot

5. p4 diff -se: 查看编辑过的文件

6. p4 diff -se | p4 -x - edit: 把所有改动过的文件置为open for submit,对于覆盖的文件 or没有用p4 edit的文件,需要这个命令, 才能将文件置为open状态, 才能方便递交

7. p4 diff -sd: 查看删除的文件(未用p4 delete删除的)

8. p4 diff -sd | p4 -x - delete: 置删除的文件为opened状态, 方便递交

9. p4 submit -d 'xxx': 递交

P4可以差分递交, 只要别人的递交没有影响到你的递交, 任何时候都可递交, 这一点, 和svn相同, 和git不同。

恢复:

p4 revert -a (file 可选): revert所有打开的已经存在的文件

 

p4 revert //...

Revert every file you have open, in every one of your pending changelists, to its pre-opened state.

p4 revert -c default //...

Revert every file open in the default changelist to its pre-opened state.

p4 revert -n *.txt

Preview a reversion of all open .txt files in the current directory, but don't actually perform the revert.

p4 revert -c 31 *.txt

Revert all .txt files in the current directory that were open in changelist 31.

p4 revert -a

Revert all unchanged files. This command is often used before submitting a changelist.

p4 revert file: revrt 已经打开的已经存在的文件或者新add的文件

p4 sync -f: 强行同步到head changelist, 如果有打开的文件, 需要先revert

下面是网上的资料, 通用但不实用:

环境变量:
export P4PASSWD=abcdefg
export P4CLIENT=xxx //这个可以不设
export P4USER=yyy
export P4PORT=ip:port

1. p4 client #配置本地信息,文件下载在哪里在这里面配置,Root项

   -t clientname
拷贝客户工作区 clientname 的视图和客户选项到该工作区的视图和选项字段中去(i.e, 使用 clientname's 视图作为一个模版)

   -d client name 删除这个client



2、p4 sync #从perforce 下载文件

p4 sync
Copy the latest revision of all files from the depot to the client workspace, as mapped through the client view.
If the file is already open in the client workspace, or if the latest revision of the file exists in the client workspace, it is not copied.
p4 sync file.c#4
Copy the fourth revision of file.c to the client workspace, with the same exceptions as in the example above.
p4 sync //depot/proj1/...@21
Copy all the files under the //depot/proj1 directory from the depot to the client workspace, as mapped through the client view.
Don't copy the latest revision; use the revision of the file in the depot after changelist 21 was submitted.
p4 sync @labelname
If labelname is a label created with p4 label, and populated with p4 labelsync, bring the workspace into sync with the files and revision levels specified in labelname.
Files listed in labelname, but not in the workspace view, are not copied into the workspace.
Files not listed in labelname are deleted from the workspace. (That is, @labelname is assumed to apply to all revisions up to, and including, the revisions specified in labelname. This includes the nonexistent revision of the unlisted files.)
p4 sync @labelname,@labelname
Bring the workspace into sync with a label as with p4 sync @labelname, but preserve unlabeled files in the workspace.
(The revision range @labelname,@labelname applies only to the revisions specified in the label name itself, and excludes the nonexistent revision of the unlisted files.)
p4 sync @2001/06/24
Bring the workspace into sync with the depot as of midnight, June 24, 2001. (That is, include all changes made during June 23.)
p4 sync status@june1st.txt
Sync a filename containing a Perforce wildcard by using the ASCII expression of the character's hexadecimal value. In this case, the file in the client workspace is status@june1st.txt.
p4 sync file.c#none
Sync to the nonexistent revision of file.c; the file is deleted from the workspace.
p4 sync ...#none
Sync to the nonexistent revision of all files; all files in the workspace (that are under Perforce control) are removed.

   p4 sync ...


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,编辑标签
20、p4 tag -l label ... #把当前目录下面的所有文件添加到标签 label
21、p4 changes ... #当前目录的changelist

    如果想看某个changlist影响的文件,使用p4 describe changelist_number(changelist的number)

22: p4 reopen 如果已经创建了一个changelist,但是现在又打开了一个文件想加入到这个还没有checkin的changelist中,使用这个命令。

  for example:

     p4 reopen -c changelist //...

-c changelist# file
Move all open files matching file pattern file to pending changelist changelist#. To move a file to the default changelist, use default as the changelist number
-c changelist# file
Move all open files matching file pattern file to pending changelist changelist#. To move a file to the default changelist, use default as the changelist number.
-t filetype file
When submitted, store file as type filetype. All subsequent revisions will be of that file type until the type is changed again.
See the File Types section for a list of file types.
See the Global Options section.
-c changelist# file
Move all open files matching file pattern file to pending changelist changelist#. To move a file to the default changelist, use default as the changelist number.
-t filetype file
When submitted, store file as type filetype. All subsequent revisions will be of that file type until the type is changed again.
See the File Types section for a list of file types.
See the Global Options section.

http://www.perforce.com/perforce/doc.current/manuals/cmdref/reopen.html

   

 查看workspace sync到的changelist

perforce的workspace其实是一些特定版本的文件的结合,相比只将workspace对应到某个特定的changelist,此方法更灵 活。changelist和文件间的关系为:每个changelist其实是某些特定版本文件的集合,但是并不是所有的版本的文件结合都对应到一个 changelist。perforce允许用户将workspace同步到文件的某些特定版本,不一定对应一个chagnelist。

使用如下三步来确定workspace的最新状态
p4 changes 命令可以查看workspace中文件集合所对应的最高chagnelist:
p4 changes -m1 //...#have
可以使用如下命令查看workspace中是否所有的文件都被sync到了最高changelist:
p4 sync -n @<changelist retuned by p4 changes>
如果以上命令显示所有的文件都已经是updated,则表示workspace当前被sync到了最高changelist。
 

22、 p4 sync @10931 #sync file @changelist
23、 p4 sync ...@10929 #only sync localfile@changelist
24、p4 help revisions #查看关于文件范围的帮助

export好变量之后,然后用1进行配置,就可以用p4 sync进行代码下载了

如果commandbar是目录则后面要加上/...,如果是文件的话就不用

在虚拟机上使用p4

一共分为如下几步:

1. 要在 Linux 上用 P4 ,就需要虚拟机能够访问外网

2. 安装及配置 P4

3. 配置源代码环境

 

下面具体介绍一下各个步骤:(我称我们的工作机本身为“主机”)

1. 配置虚拟机访问外部网络。设置步骤如下

1) 共享主机网卡

本地连接 -》 属性 -》高级 -》选择允许其它网络通过本...,并选择家庭网络连接为 VMware Network Adapter VMnet1

 

2) 设置虚拟机 IP 信息

选择 Traditional ….


3) 设置静态 IP

IP 192.168.0. xxx

Subnet mask 255.255.255.0

DNS 192.168.0.1(编辑/etc/reslove.conf)

Default Gateway 192.168.0.1

2. 安装及配置 P4

1) 下载客户端 http://www.perforce.com/perforce/downloads/index.html 我使用的是 The Perforce Command-Line Client (P4)

2) 把客户端放在文件夹 /usr/local/bin 。这样能在任何目录直接使用 p4 命令

3) 配置客户端,在线帮助有很多种方式,我使用配置文件方式。步骤如下

a. 在 /usr 下面新建一个文件夹 p4config ( 可以自定义 ) ,在文件夹里面新建文件 p4.configfile.

b. 用 VI 打卡 p4.configfile, 输入如下配置

 

P4CLIENT= (定义你的工作空间,比如 ygxu_xms )

P4PASSWD= (你的密码)

P4PORT=10.12.33.133:1700

P4USER= (你的用户名)

 

保存退出。

c. 配置环境变量。修改后需要重启这个才生效

用 vi 打开 /etc/profile , 末尾处加入

 

#

# pv4 config file path

#

if test -z "$P4CONFIG" ; then

export P4CONFIG=/usr/p4config/p4.configfile

fi

 

d. 测试环境配置是否成功

命令 p4 info , 如果显示了连接信息,则 OK ,否则会提示连接不上

 

 

需要注意p4config 文件,有时候一个用户会在自己的home目录下建立多个client,如果在一个目录下有多个子目录,每一个子目录都是一个新的client,那么每一个client都应该提供一个p4config文件;

如果只是提供一个p4config文件,那么那个p4config文件中指定的p4 client作为当前client,而无法使用另外一个client。

 

//创建相同client配置的另外一个client,可以使用前一个client作为template,这样client文件可以自动修改

p4 client -t template_client new_client

 

 

3. 配置源代码环境

使用命令 p4 client 会有如下信息显示

 

Client: 你 上面配置的工作空 间

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

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

Owner: 你 的用 户 名

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/...

….

 

两个地方需要修改:

a . Root . 这个决定你的代码会放在什么地方,如上,我的是 /home/hammer

b. View. 这个决定你需要取哪些代码下来,因为一般不会把全部代码取下来,在 Linux 上我们一般只需要 XMS 的 SS7_Mainline, 所以把其他的删掉,修改成上面这个样子

 

注意事项,一定要保证空间足够,建议先删掉原来的 SS7_Mainline ,使用 Shrink 工具回收空间之后再取代码。

好了,使用 p4 sync 命令吧,就可以继续工作了!

关于 p4 的使用命令,文档如下:

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

更详细的命令格式参考 http://www.perforce.com/perforce/products/p4.html

p4客户端下载 http://www.perforce.com/perforce/downloads/index.html

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

快速上手perforce

perforce是什么?参考http://www.perforce.com

[概念]
先说说概念吧,一般来说版本控制软件都会分client和server,server负责做一些管理代码和文档仓库,控制各个用户的权限,记录版本升级历 史之类的事情,client使用某种客户端连入server来完成代码、文档的修改、提交等工作,perforce也不例外。在server端 perforce做得很精简,没有太多的依赖,一个p4d搞定,配置起来也很简单,它的主要任务就是管理一个文件仓库depot。在client端有 user和workspace两个概念,user顾名思义就是在server上登记的一个用户,每个user可以拥有零个或者多个workspace,甚 至也可以switch到别人的workspace上去,只要有权限。简单的说workspace是depot到本地的一个映射,例如这样写 //depot/foo/... //myspace/bar/...就把depot里面foo目录下面所有东西映射到本地bar目录里面去了,myspace是和特定的 workspace相关的,在设置workspace的时候可以设置它的绝对路径。

[连接之前的配置]
首先我们需要一个用户,假设已存在一个用户test,没有密码。
$P4CONFIG=p4conf.conf; export P4CONFIG
windows下使用
p4 set P4CONFIG=p4conf.conf
这个命令设置一个环境变量P4CONFIG,文件名可以自己定义,里面可以存放客户端的配置。在UNIX系统中配置信息都可以写道环境变量里,windows下可以都写到注册表里去,不过我更倾向于在某一个目录下面建立一个配置文件,这样可以很方便的切换不同的workspace。然后我们就可以开始编辑这个p4conf.conf配置文件,格式很简单都是 setting=value 形式的。
建立一个workspace目录,在里面新建一个p4conf.conf文件,内容如下:
P4PORT=192.168.0.1:1666
P4USER=test
P4CLIENT=test-client
这是一个最简单的配置文件,P4PORT指名了服务器的ip和端口,ip也可以用计算机名代替,例如
P4PORT=p4server:1666
如果留空 P4PORT=1666 这样代表默认连接本地的server,如同 P4PORT=127.0.0.1:1666一样。
P4USER是用户名,P4CLIENT是当前是用的workspace名字,这个名字可以任意取,仅仅是一个标识。
这时候就可以cd到这个目录运行一下
$p4 info
看看输出是什么,如果显示了如下内容
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 China Standard Time
Server version: P4D/NTX86/2006.1/102189 (2006/06/27)
Server license: none
就表示成功连上服务器了,如果出现像这样的错误,那就要检查一下P4PORT有没有设置正确
Perforce client error:
Connect to server failed; check $P4PORT.
TCP connect to 1666 failed.
connect: 1666: WSAECONNREFUSED
到这儿,最基本的client配置已经完成,很简单吧:-) 在配置文件里还可以存放一些其他的设置,例如
P4EDITOR指定在编辑的时候默认使用这个vim编辑器,P4DIFF指定了比较文件的时候使用的工具,
P4PASSWD当用户需要密码的时候可以提供一个默认密码,其他还有一些可以参考官方文档 P4 User's Guide

[连接之后的配置]
之前的所有设置都是保存在环境变量,配置文件或者注册表里面的,这仅仅定义了一个客户端的行为,很大一部分事情例如追踪用户的修改、打开、提交的文件之类都是由服务器记录下来的,所以现在我们需要通过一些命令来配置一下服务器那头的用户信息。
$p4 user
这个命令的结果是p4使用一个默认的编辑器打开一个临时文件,文件中保存着用户的一些信息,例如用户名,Email,FullName之类,用户可以自己 修改其中某些设置,保存以后它会自动提交到服务器上更新用户设置。这个过程中使用的编辑器可以在环境变量或者配置文件中指定(P4EDITOR)。
$p4 client
和上面一样,这个命令编辑一个client的配置文件。Root对应于workspace在本机上的绝对路径,Options定义了一些client的属 性,例如unlocked值允许其他的用户switch到你的工作空间,其他的定义可以参考官方文档。View的配置比较重要,它定义了服务器上面的文件 到workspace的映射。例如
//depot/... //test-client/...
左右分别代表源地址和目的地址,中间以空格隔开,它的意思是将服务器depot里面所有文件映射到我的工作目录(在这之前用Root参数指定的绝对路径)。映射可以有多行:
//depot/src/... //test-client/local-src/...
//depot/doc/... //test-client/local-doc/...
这样就将代码和文档分别映射到本地,而且不一定要和服务器上使用相同的名字。在这之中也许会有需要排出的一些文件或者目录,这时只需要在映射前面加上一个减号:
-//depot/doc/file1.txt //test-client/local-doc/file1.txt
这样就排除了一个文件。在这个过程中要留意出现冲突,如下:
//depot/src/... //test-client/src/...
//depot/doc/... //test-client/src/...
将服务器上两个目录都映射到本地同一个目录。
上面的过程中使用了一种通配符“...”它递归的匹配这个目录以及子目录下面的所有文件,另一种上面没有使用的 “*” 匹配单个目录下的文件,例如 //test-client/src/*.c 匹配 src目录下面所有以 .c 作为扩展名的文件。
上面说了,如果把服务器上的两个目录都映射到本地通一个目录会产生冲突,后者会把前者覆盖,但如果这样写:
//depot/src/... //test-client/local-src/...
+//depot/doc/... //test-client/local-src/...
就会产生不同的效果,两个目录里面的文件都会出现在local-src这个目录中,不过如果仍然有重名的文件则后者会把前者覆盖。
至此,client的配置基本上完成,可以 $p4 sync 一下把服务器上的东西抓下来看看:-)
另外,如果要删除这个cient的话很简单 $p4 client -d test-client 就可以了

[文件管理]
配置了这么半天,现在开始步入正题,文件的管理才是我们使用perforce的核心工作。简单的说,文件操作可以分成三类:往depot里面添加文件,修改并提交文件和删除文件。
在这之前最好保证workspace里面文件和服务器上的最新版本同步,使用命令:
$p4 sync ...
如果需要同步到某一个版本,在后面添上 #1 数字代表版本号;如果需要强制同步所有文件,可以加上 -f 参数。关于sync的具体用法可以用命令
$p4 help sync
btw: 可以试试看$p4 help help

添加文件:
$p4 add *.txt
将当前目录下所有扩展名为txt的文件添加到depot相应目录,注意在添加文件的时候不可以使用通配符 ... 因为 ... 有服务器负责解析,这时候服务器并不知道需要添加什么文件,但却可以使用 * ,它是由shell负责解析。
另外,所有修改在submit之前都不会提交到服务器。

修改文件:
$p4 edit //depot/src/a.c
这个文件执行以后在服务器上就会记录下当前的 client已经在编辑这个文件,在本地只有一个动作,就是将a.c文件的只读属性去掉,这时候我们就可以随便使用某种编辑器来编辑这个文件了,在这之前所有文件都是只读的,而且不要手动去掉只读属性来编辑,因为那样服务器跟踪不到client的修改记录。

删除文件:
$p4 delete //depot/doc/a.pdf
注意在submit之前这个文件在服务器上也是不会被删除的。

撤销修改:
$p4 revert *.txt
这会将之前所有添加的或者修改的,以txt作为扩展名的文件全部撤销到原先的状态,原先添加的文件会被删除,修改的文件被还原到执行p4 sync时候的版本。
最后我们可以将上面所有修改全部提交:
$p4 submit
这时候p4会调用默认的或者P4EDITOR所指定的编辑器来编辑一个配置文件,里面包含了提交者的信息,对这次提交的描述以及列举出涉及到的文件等,一般来说把Description一项填充完保存就可以了。然后会看到屏幕上哗啦哗啦的输出一堆东西,最后显示 Change xxxx submitted. 就表示这次提交成功了。如果出现错误,有可能是存在冲突或者别的情况,关于冲突的问题留着后面再说~~_~~
文件之间的diff:
$p4 diff file
$p4 diff2 file1 file2
前者在client端进行比较,使用client端配置的工具,相对于perforce自带的diff我还是更喜欢vimdiff :-)后者在server端比较,返回两个文件(也可能是很多文件)之间的比较结果。
离线工作:
在线工作的时候所有文件的修改都由服务器来记录,文件的读写权限设置也是和服务器上同步的,但是一但离线就需要用另一种方法来管理workspace里面的文件了。
首先需要对那些等待修改的文件手动去掉只读属性,然后可以开始修改,等到和服务器建立连接的时候需要做两件事情:
1 找到所有修改过的文件,open for edit
$p4 diff -se | p4 -x - edit
2 找到所有删除的文件, open for delete
$p4 diff -sd | p4 -x - delete
最后 submit 就可以

下面是perforce diff详述:

概述
对一个客户工作区中的文件和一个版本库中的文件版本进行比较
语法
p4 [g-opts] diff [-dflag -f -m max -sa -sb-sd -se -sr -sl -t] [file[rev#]...]
描述
p4 diff 命令在Perforce客户端上运行一个diff程序, 对客户工作区中的文件和版本库中的版本文件进行比较。
个命令需要一个包含版本标识符的文件参数。如果包含了一个版本标识符,在客户工作区的文件会与该指定的版本文件进行比较。如果没有包含版本标识符,那么客户工作区的文件会与当前被编辑的版本(通常是最新的版本)进行比较。在这两种情况中,客户的文件都必须被打开编辑,或比较必须是对客户文件最后一个同步版本不同的版本文件进行比较。
如果文件名包括通配符,那么所有打开得匹配该模板的文件都会被比较。如果没有提供文件参数,那么所有打开的文件会与他们在版本库中的相应文件进行比较。
缺省情况下,diff 程序使用的是内建在p4客户程序中的。如果要改变diff 程序去运行一个外部程序,那么设置P4DIFF 环境变量或注册一个变量来指向这个新的程序。
选项
-f

强制进行比较 (如果没有版本标识符,那么于最新版本比较),即使客户文件没有打开进行编辑
-dflags

传递选项给后面的diff 程序 (阅读下面的使用提示)
-m max
限定输出显示diffs(or status) 的第一个max 文件


-sa

只显示那些打开的与版本库里版本文件不同或不存在的文件的名字

-sb

只显示打开得已解析过给集成的,但是在解析后背修改过的文件的名字

-sd

只显示那么没有打开得没有存在与客户工作区中,但是在版本库中存在的文件的名字。
-se

只显示没有打开的在客户工作区中但是与版本库中版本不同的文件的名字

-sr

只显示那些在客户工作区中打开的用来标识版本库中版本的文件的名字。

-sl file...

所有打开的文件与版本库进行比较,然后显示三种状态 same, diff, missing.中的一种
If you use the -f flag together with the-sl flag, files that are open for edit are also compared and their status islisted.

-t
比较甚至文件类型不是文本类型的文件的不同
g-opts 阅读 全局选项部分

使用提示
Can File Arguments Use Revision Specifier?

YES
Can File Arguments Use Revision Range?

NO
Minimal Access Level Required
read

p4 diff 支持的diff 选项有:
选项
名字
-dn
RCS输出格式,显示文件中增加的和删除的以及相关行的内容
-dc
文本输出格式,显示行编号范围和三行变更内容
-ds
总结输出格式,只显示总共增加,删除或修改的行数量
-du
unifiedoutput format, showing added and deleted lines with sufficient context forcompatibility with the patch(1) utility.
-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
为了传递超过一个的选项给diff程序,可以打包他们。例如:
p4 diff -dub file
specifies a unified diff that ignores changes in whitespace.
l
?
The header line of a unifieddiff produced with the -du option for use with patch(1) displays filenames inPerforce syntax, not local syntax.
举例
p4 diff file#5

将客户工作区中的“file”与版本库中的第五版本进行比较
p4 diff @1999/05/22

将客户工作区中所有打开得文件与版本库中May 22, 1999修改的版本进行比较.
p4 diff -du file
file 进行比较,显示符合patch(1) utility格式的输出.
p4 diff -sr | p4 -x - revert
恢复所有打开得没有修改过的文件。
This differs from p4 revert -a ( revert allunchanged files, where resolving a file, even if no changes are made, counts asa change), in that it reverts files whose workspace content matches the depotcontent, including resolved files that happen to be identical to those in thedepot.
第一个命令显示所有打开得没有修改过的文件。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关于 -x 选项的更多信息,阅读 全局选项 部分

相关命令
比较两个版本库中的文件版本的不同
p4 diff2
查看一个文件的全部内容
p4print
************************************************************************************************************************************

Perforce使用中文教程: p4 diff2

Perforce命令: p4 diff2

概述
比较版本库中文件的两个版本
语法
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]]
描述
p4 diff2 命令使用Perforce服务器中内建的diff程序对版本库中的俩个文件版本进行比较。这些版本通常是指同一个文件的两个不同的版本,但是他们也可以是两个完全不同文件的版本。如果没有没有提供版本给文件参数,那么最新的版本被用来比较。
p4 diff2 不使用由环境变量P4DIFF定义的diff程序。p4 diff命令使用的diff算法在装有Perforce服务器机器上运行,而且一直使用服务器内建的diff程序
可以在指定文件参数的位置指定一个有(或没有)版本标识的文件模版;这样可以导致Perforce对那些匹配模版的成对文件执行diff命令。如果你调用使用文件模版的p4 diff2命令,使用引号或反斜线可以从OS外壳中退出文件模版,那么确定在两个模版中的通配符相匹配。
Perforce presents the diffs in UNIX diffformat, prepended with a header. 起始部分的格式如下:
==== file1 (filetype1) - file2 (filetype2)==== summary
summary 可能出现的值和意义如下:
content: 文件版本的不同内容
types: 内容完全相同, 但是文件类型不同
identical: 版本的内容和文件类型都相同
如果文件file1 file2在指定的版本中不存在,那么起始部分将显示summary <none>.
选项
-q
Quietdiff.
只显示表头部分,并且在文件版本内容和类型不同时也不显示内容
-dflags

把标准的UNIX diff 选项之一作为参数运行diff程序。阅读后面的《使用提示》
-b branchname
fromfile[rev] tofile[rev]
使用一个分支的定义去比较在两个分支代码行里的文件。被比较的文件可以被文件模版中的 fromfile tofile 里的任意一个所限定
-t

比较甚至文件类型不是文本类型的文件的不同
-u
Generateunified output format, showing added and deleted lines with sufficient contextfor compatibility with the patch(1) utility. Only those files that differ areincluded. File names and dates remain in Perforce syntax.
g-opts
阅读全局选项 部分
使用提示
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:
选项
名称
-dn
RCS输出格式,显示文件中增加的和删除的以及相关行的内容
-dc
文本输出格式,显示行编号范围和三行变更内容
-ds
总结输出格式,只显示总共增加,删除或修改的行数量
-du
unified输出格式 showing added and deleted lines with sufficient context forcompatibility with the patch(1) utility.
-db
忽略在空格中做的改变
-dw
忽略连在一起的空格
为了传递超过一个的选项给diff 程序,可以打包他们。例如
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 local syntax.


p4 diff2 命令被用来对比较二进制文件时,该行
... files differ ...
会被显示出来,如果他们没有被识别的话。
选项 -b branch [[fromfile[rev]] tofile[rev] ] 在第一次看见是可能觉得不正确。Since the branch specification maps fromfiles to tofiles, why wouldyou specify both fromfile and tofile file patterns? You wouldn't, but thissyntax allows you to specify a fromfile file pattern and a tofile revision, ora fromfile revision and a tofile file pattern.
举例
p4 diff2 -ds file#1 file

比较 file 文件的第二个版本和最新版本,并显示文件中内容被添加,更改或删除的信息
p4 diff2
file@34 file@1998/12/04
Diff the revision of file that was in thedepot after changelist 34 was submitted against the revision in the depot atmidnight on December 4, 1998.
p4 diff2
//depot/rel1/... //depot/rel2/...#4

比较在版本库 //depot/rel1 中的所有最新文件与版本库 //depot/rel2 第四个版本文件
p4 diff2
//depot/rel1/* //depot/rel2/...

不允许。每个文件的通配符模式必须匹配
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 at the revision they were at in changelist 50.
相关命令
比较客户工作区中文件与版本库中的版本文件
p4 diff

查看一个文件的全部内容
p4 print

 

 

 

 

 

command 附录:

 

p4 add Open a new file to add it to the depot

p4 admin Perform administrative operations on the server

p4 annotate Print file lines along with their revisions

p4 branch Create or edit a branch specification

p4 branches Display list of branches

p4 browse Browse for a list of Zeroconf-registered Perforce servers

p4 change Create or edit a changelist description

p4 changes Display list of pending and submitted changelists

p4 changelist Create or edit a changelist description

p4 changelists Display list of pending and submitted changelists

p4 client Create or edit a client specification and its view

p4 clients Display list of known clients

p4 copy Makes target identical to source by branching, replacing or deleting

p4 cstat Lists the changes not synchronized in the current client

p4 counter Display, set, or delete a counter

p4 counters Display list of known counters

p4 dbschema Report information about metadata in the Perforce database

p4 dbstat Display size or simple statistics for a database table

p4 delete Open an existing file to delete it from the depot

p4 depot Create or edit a depot specification

p4 depots Display list of depots

p4 describe Display a changelist description

p4 diff Display diff of client file with depot file

p4 diff2 Display diff of two depot files

p4 dirs List subdirectories of a given depot directory

p4 edit Open an existing file for edit

p4 export Extract journal or checkpoint records

p4 filelog List revision history of files

p4 files List files in the depot

p4 fix Mark jobs as being fixed by named changelists

p4 fixes List what changelists fix what job

p4 flush Fake a ‘p4 sync’ by not moving files

p4 fstat Dump file info

p4 grep Print lines in files (or revisions of files) that match a pattern

p4 group Change members of a user group

p4 groups List groups (of users)

p4 have List revisions last synced

p4 help Print this help message

p4 info Print out client/server information

p4 interchanges Lists changes not yet integrated from source to target

p4 integrate Schedule integration from one file to another

p4 integrated Show integrations that have been submitted

p4 istat Shows the stream’s integration status

p4 job Create or edit a job (defect) specification

p4 jobs Display list of jobs

p4 jobspec Edit the job template

p4 label Create or edit a label specification and its view

p4 labels Display list of labels

p4 labelsync Synchronize label with the current client contents

p4 license Update or display the license file

p4 lock Lock an opened file against changelist submission

p4 lockstat Report lock status of database tables

p4 logger Report what jobs and changelists have changed

p4 login Login to Perforce by obtaining a session ticket

p4 logout Logout of Perforce by removing or invalidating a ticket

p4 logstat Report size of journal, error log, and/or audit log files

p4 logtail Display the last block(s) of the error log

p4 merge Merge changes from one set of files into another

p4 monitor Display current running Perforce process information

p4 move Move file(s) from one location to another

p4 obliterate Remove files and their history from the depot

p4 opened Display list of files opened for pending changelist

p4 passwd Set user password on server (and Windows client)

p4 print Retrieve a depot file to the standard output

p4 protect Modify protections in the server namespace

p4 protects Display protections in place for a given user/path

p4 rename Explains how to rename files

p4 reopen Change the type or changelist number of an opened file

p4 replicate Replicate server metadata from one server to another

p4 resolve Merge open files with other revisions or files

p4 resolved Show files that have been merged but not submitted

p4 revert Discard changes from an opened file

p4 review List and track changelists (for the review daemon)

p4 reviews Show what users are subscribed to review files

p4 shelve Store files from a pending changelist, without submitting them

p4 set Set variables in the registry (Windows only)

p4 sizes Display size information for files in the depot

p4 stream Create or edit a stream specification

p4 streams Display a list of known streams

p4 submit Submit open files to the depot

p4 sync Synchronize the client with its view of the depot

p4 tag Tag files with a label

p4 tickets Display list of session tickets for this user

p4 triggers Modify list of pre-submit and form-validating triggers

p4 typemap Modify the file name-to-type mapping table

p4 unlock Release a locked file but leave it open

p4 unshelve Restore shelved files from a pending change into a workspace

p4 user Create or edit a user specification

p4 users Display list of known users

p4 verify Verify that the server archives are intact

p4 where Show how file names map through the client view

p4 workspace Create or edit a client specification and its view

p4 workspaces Display list of known clients

 

问题解决:

1. 有时候client里面会有一些null changelist,这样当运行p4 client -d xxx的时候会不允许删除client,错误信息,"use -f force delete client".

 解决方法: 假设当前要删除的client名称为 client_xxx.

             首先list所有的null changelist :

                  p4 changes -c client_xxx -s pending

             再删除这些pending的changelist:

                  p4 change -d ####

 

             有些时候,当使用rm -rf xxx删除目录的时候不允许删除,原因在于目录属性:

                  chmod -R 777 xxx_dir

             再来删除目录。

 

posted on 2013-12-19 09:10  莫水千流  阅读(52760)  评论(0编辑  收藏  举报