p4 diff2
Synopsis
Compare two depot file revisions.
Syntax
p4 [g-opts
] diff2 [-doptions
] [-Od -q -t -u] file1
[rev
] file2
[rev
]
p4 [g-opts
] diff2 [-doptions
] [-Od -q -t -u] -b branch
[[fromfile
[rev
]] tofile
[rev
]]
p4 [g-opts
] diff2 [-doptions
] [-Od -q -t -u] -S stream
[-P parent
]
[[fromfile
[rev
]] tofile
[rev
]]
Description
p4 diff2 uses the Perforce service's built-in diff routine to compare two file revisions from the depot. These revisions are usually two versions of the same file, but they can be revisions of entirely separate files. If no file revision is explicitly provided with the file argument, the head revision is used.
p4 diff2 does not use the diff program specified by the
environment variable P4DIFF
.
The diff algorithm used by p4 diff2 runs on the machine
hosting the shared Perforce service, and always uses the service's
built-in diff routine.
You can specify file patterns as arguments in place of specific files, with or without revision specifiers; this causes Perforce to perform multiple diffs for each pair of files that match the given pattern. If you invoke p4 diff2 with file patterns, escape the file patterns from the OS shell by using quotes or backslashes, and be sure that the wildcards in the two file patterns match.
Perforce presents the diffs in UNIX diff format, prepended with a header. The header is formatted as follows:
====file1
(filetype1
) -file2
(filetype2
) ====summary
The possible values and meanings of summary
are:
-
content
: the file revisions' contents are different, -
types
: the revisions' contents are identical, but the filetypes are different, -
identical
: the revisions' contents and filetypes are identical.
If either file1
or
file2
does not exist at the specified revision,
the header displays the summary
as
<none>
.
Options
|
Use a branch mapping to diff files in two branched codelines.
The files that are compared can be limited by file patterns in
either the |
|
Runs the diff routine with one of a subset of the standard UNIX diff options. See Usage Notes for a listing of these options. |
|
Limit output to only those files that differ. |
|
Quiet diff. Display only the header; if
|
|
Diff a stream with its parent. To diff the stream with a stream
other than its configured parent, specify |
|
Diff the file revisions even if the file(s) are not of type
|
|
Generate unified output format, showing added and deleted lines
with sufficient context for compatibility with the
|
|
See “Global Options”. |
Usage Notes
Can File Arguments Use Revision Specifier? |
Can File Arguments Use Revision Range? |
Minimal Access Level Required |
---|---|---|
Yes |
No |
|
-
The diff options supported by p4 diff2 are:
Option
Name
-dn
RCS output format, showing additions and deletions made to the file and associated line ranges.
-dc[
num
]context output format, showing line number ranges and
num
lines of context around the changes.-ds
summary output format, showing only the number of chunks and lines added, deleted, or changed.
-du[
num
]unified output format, showing added and deleted lines with
num
lines of context, in a form compatible with thepatch(1)
utility.-dl
ignore line-ending (CR/LF) convention when finding diffs
-db
ignore changes made within whitespace; this option implies
-dl
.-dw
ignore whitespace altogether; this option implies
-dl
. -
To pass more than one option to the diff routine, group them together. For example:
p4 diff2 -dub
file1
file2
specifies a unified diff that ignores changes in whitespace.
-
The header line of a unified diff produced with the
-du
option forpatch(1)
use displays the diffed files in Perforce syntax, not local syntax. -
When p4 diff2 is used to diff
binary
files, the line... files differ ...
is printed if they are not identical.
-
The option
-b
branch
[
may seem incorrect at first. Because the branch mapping maps[fromfile[rev]]
tofile[rev]
]fromfiles
totofiles
, why would you specify bothfromfile
andtofile
file patterns? You wouldn't, but this syntax allows you to specify afromfile
file pattern and atofile
revision, or afromfile
revision and atofile
file pattern. -
RCS keywords within files are not expanded with p4 diff2.
Examples
p4 diff2 -ds file#1 file |
Compare the fist revision of file |
p4 diff2 file@34 file@1998/12/04 |
Diff the revision of |
p4 diff2 //depot/rel1/... //depot/rel2/...#4 |
Compare the head revisions of all files under
|
p4 diff2 //depot/rel1/* //depot/rel2/... |
Not allowed. The wildcards in each file pattern must match. |
p4 diff2 -b branch2 //depot/rel2/...#2 @50 |
Compare the second revision of the files in
|