#!/usr/bin/perl # Extremely simple script that parses the "p4 diff2 -q -t" output to display # the differences between two filesets. For instance, one can see the # differences between the state of the depot at changelist X verses the # current changelist: # perl p4-diff.pl //...@X //...#head # The generated output shows only the modified files between the two states # by outputting a modification indicator in the first column, a space, then # the depot name. The indicator uses "+" to mean that the file was added # in the second argument, a "-" to mean the file was removed from the first # to the second, and "!" means that the file was modified. Currently, this # does not track if a file was renamed. # # Using the example above, if the output looks like: # + //depot/1 # - //depot/2 # ! //depot/3 # then this means that the file "//depot/1" did not exist in changelist X, # but exists now; that the file "//depot/2" existed in changelist X, but does # not exist now; that the file "//depot/3" was changed between changelist X # and now. # # # by Matt Albrecht # # Revision history: # 17-Jun-2003: Initial release my ($label1, $label2) = @ARGV; my $p4cmd = "p4 diff2 -t -q $label1 $label2"; print STDERR "$p4cmd\n"; my @lines = `$p4cmd`; foreach (@lines) { chomp; if (/^==== \<\s*none\s*\> - ([^#]+)#(\d+) ====/) { print "+ $1\n"; } elsif (/^==== ([^#]+)#(\d+) - \<\s*none\s*\> ===/) { print "- $1\n"; } elsif (/^==== ([^#]+)#(\d+) \([^\)]+\) - ([^#]+)#(\d+) \([^\)]+\) ====/) { print "! $1\n"; } else { print STDERR "(ignored $_)\n"; } }