[p4] How do you get a changeset out as a diff?
Tetlow, Gordon
gtetlow at soe.sony.com
Wed May 24 14:18:28 PDT 2006
> -----Original Message-----
> From: perforce-user-bounces at perforce.com
> [mailto:perforce-user-bounces at perforce.com] On Behalf Of Sam Roberts
> Sent: Wednesday, May 24, 2006 11:03 AM
> To: perforce-user at perforce.com
> Subject: Re: [p4] How do you get a changeset out as a diff?
>
>
> > On Tue, 23 May 2006 18:25:40 -0700 Sam Roberts
> <sroberts at bycast.com> wrote:
> > > I was hoping p4 diff blah/... at xxx,yyy would do it, but p4
> diff only
> > > diffs local copies against repository versions. Do I have
> to make a new
> > > client, map in version yyy, then diff it against version xxx?
>
> > Does "p4 describe -du xxxxxx" do what you want?
>
> On Tue, May 23, 2006 at 06:45:34PM -0700, David Birkhead wrote:
> > Check out p4 diff2
>
> Thanks guys, those commands were what I was looking for.
diff and diff2 don't take into account files that were added or deleted:
I wrote a script for this about a year or so ago. It's in Perl, but the
fundamentals are there. Most importantly, this also fixes up the format
so it works with the patch(1) unix util.
#!/usr/bin/perl
# new usage: ./p4patch
# Usage: p4 diff2 -du base_view your_view
use POSIX (strftime);
use File::Basename;
die "Usage: $0 [srcpath] [dstpath]\n" if ( $#ARGV ne 1 );
my $src_depot = shift;
my $dst_depot = shift;
my $src_base=dirname($src_depot);
my $dst_base=dirname($dst_depot);
$cmd = "p4 diff2 -du $src_depot $dst_depot";
open(P, "$cmd |") || die $!;
$time = localtime();
$time = strftime "%a %b %e %H:%M:%S %Y", localtime;
$time = strftime "%Y/%m/%d %T", localtime;
while (<P>) {
($f1, $f2, $r) = m|^==== (.+) - (.+) ====? ?(.*)| or print, next;
next if $r eq 'identical';
($src, $srcrev) = ($f1 =~ m|$src_base/([^#]*)#(\d+)|);
($dst, $dstrev) = ($f2 =~ m|$dst_base/([^#]*)#(\d+)|);
print "Index: $dst\n";
print '=' x 75 . "\n";
if ($r eq '') {
print `p4 print -q $f2 | diff -Nc /dev/null - | sed "s#^---
-#--- $dst#"`
if ($f1 =~ /<\s*none\s*>/);
print `p4 print -q $f1 | diff -Nc - /dev/null | sed
"s#^[*][*][*] -#*** $src#"`
if ($f2 =~ /<\s*none\s*>/);
next;
}
print "--- $src\t$time\t#$srcrev\n";
print "+++ $dst\t$time\n";
}
More information about the perforce-user
mailing list