Perforce命令: p4 diff2

来源:互联网 发布:mac怎么安装虚拟机 编辑:程序博客网 时间:2024/05/21 19:47
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