Changes Between Labels

TASK

How do I find out what changed between two labels?


SOLUTION

Differences in File Names

To see which files are different between two labels, first output the labels' contents to two text files:

p4 files //...@label > label.out
p4 files //...@label2 > label2.out

Then, diff the two output files label.out and label2.out. This diff will show which file's revisions have changed between the two labels, as well as show which files are in one label but not in the other.

Example

p4merge.exe label.out label2.out  (Windows)
diff label.out label2.out        (Unix)

Differences in File Content

To display the actual content diffs for files that exist in labels, use the following command. You might want to redirect this output to a file — it could be large:

p4 diff2 //...@label1 //...@label2

The above command will produce output for files that exist in one label but not the other. For example:

==== <none> - //depot/test/file#1 ====

Differences in Changelists

To get an approximate idea of which changelists were submitted between label1 and label2, retrieve the highest changelist number in each label, then list the changelists in that range that affected the files in the labels' views:

p4 changes -m1 @label1       [say this is 200]
p4 changes -m1 @label2       [and say this is 250]
p4 changes //labelview/...@201,@250

Use the path listed in the "View" fields of the labels' specs for labelview.

The above command will be less accurate if some files in label1 are newer than their counterparts in label2, if some files in label2 are newer than their counterparts in label1, or if the View: fields are different between the two labels.

Finally, do not use the following command, since it will not do the expected:

p4 changes @label1,@label2

The above command does not include changes to files that exist in one label but not the other. Keep in mind that adds and deletes will cause the above command to completely ignore those files unless they are listed in both labels simultaneously, and where the second label contains a revision of the file which is equal to or greater than the first.

For illustration;

@label1 - foo#2
@label2 - foo#1

p4 changes @label1,@label2
[no results]

p4 changes @label2,@label1
Change 17 on 2008/05/05 by marc@fasty

Note: Perforce revision ranges, when labels are involved, operate on the intersection of the files.

Note: With the addition of P4V's Folder Diff, users can now perform a graphical diff  of two labels.

Within P4V, choose Tools -> Diff Against... from the menu to open P4V's Diff dialog. In the Diff dialog, enter the appropriate paths into the fields '1st Path' and '2nd Path' before selecting the radio button Specify Revision. This selection will enable the drop down allowing you to select Label from the list before entering the name of the label specification. After entering the details for the two labels, press Diff to show the differences between the two labels.