Perforce Command Reference:
[Index] [Prev] [Next]
p4 diff2
Synopsis
Compare two depot file revisions
Syntax
p4 [g-opts] diff2 [-dflag -q] file1[rev] file2[rev]
p4 [g-opts] diff2 [-dflag -q] -b branch [fromfile[rev] [tofile[rev]] ]
Description
p4 diff2 uses the p4d server'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 will be used.
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, with a header prepended. The header is formatted as follows:
==== file1 (filetype1) - file2 (filetype2) ==== summary
If file1 or file2 doesn't exist at the specified revision, the header will display it as <none>. 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.
Options
-q |
Display only the header, and don't even display that when the file revisions' contents and types are identical.
|
-dflag |
Runs the diff routine with one of a subset of the standard UNIX diff flags. See the Usage Notes below for a listing of these flags.
|
-b branchname fromfile[rev] tofile[rev] |
Use a branch specification to diff files in two branched codelines. The files that are compared can be limited by file patterns in either fromfile or tofile.
|
g_opts |
See global options section.
|
Usage Notes
- The UNIX diff flags that can be used with the -dflag flag are:
UNIX diff Flag |
Name
|
---|
-dn |
RCS diff
|
-dc |
context diff
|
-ds |
summary diff
|
-du |
unified diff
|
- p4 diff2 does not use the diff program specified by the environment variable P4DIFF. p4 diff2 runs on the server, and always uses the p4d server's built-in diff.
- When p4 diff2 is used to diff binary fiiles, the line
... files differ ...
- will be printed if they are not identical.
- The option -b branch [fromfile[rev] [tofile[rev]] ] seems incorrect at first. Since the branch specification maps fromfiles to tofiles, why would you specify both fromfile and tofile file patterns? You wouldn't, but this syntax allows you to specify a fromfile file pattern and a tofile revision, or a fromfile revision and a tofile file pattern.
Examples
p4 diff2 -ds foo#1 foo |
Compare the second revision of file foo to its head revision, in UNIX diff summary format.
|
p4 diff2 foo@34 foo@1998/12/04 |
Diff the revision of foo that was in the depot after changelist 34 was submitted against the revision in the depot at midnight on December 4, 1998.
|
p4 diff2
//depot/bar/... //depot/bar2/...#4 |
Compare the head revisions of all files under //depot/bar to the fourth revision of all files under //depot/bar2
|
p4 diff2 //depot/bar/* //depot/bar2/... |
Not allowed. The wildcards in each file pattern need to match.
|
p4 diff2 -b foo //depot/bar/...#2 @50 |
Compare the second revision of the files in //depot/bar/... to the files branched from it by branch specification foo at the revision they were at in changelist 50.
|
Related Commands
To compare a client workspace file to a depot file revision |
p4 diff
|
To view the entire contents of a file |
p4 print
|
Perforce Command Reference:
[Index] [Prev] [Next]
Copyright 1999 Perforce Software.
Contact us at [email protected]
Last updated: 09/15/99 (Manual version 99.1.cr.6)