[p4perl] Issues running p4 diff2 using p4perl

Tony Smith tony at smee.org
Fri Nov 30 07:53:10 PST 2007


Hi Stuart,

The problem is that 'p4 diff2' doesn't show diffs when it's run in tagged mode 
(enabled by ParseForms). Tagged mode support for diff2 was added in the 
2004.2 server, but the server still sends output in the old (untagged) format 
to clients built before then. So I guess your old version of P4Perl was using 
a 2003.2 or older API.

You can solve this in two ways:

1. Downgrade your API level in your script to 56 (2003.2), which will probably 
make your old version of the script work again. Call it before you connect.

	$p4->SetApiLevel( 56 );
	$p4->Connect();

This is a way of getting old output formats sent from a new server to a new 
client and helps keep old scripts running.

2. Have a separate, non-tagged, client for running 'p4 diff2' commands. In a 
future version of P4Perl you'll be able to selectively turn tagged mode off 
for a specific command, but that's not there yet.

Hope that helps!

Tony

> We recently upgraded our perforce server version to 2006.2, which broke
> some scripts that had been using an old version of p4perl, so I've
> upgraded to the newest - 3.6001.
>
> This seems to have solved most things, however I cannot persuade diff2 to
> work - using ParseForms() and running either of the following lines
>
>         my @diff2 = $self->{p4}->Run("diff2",
> $file."\@".$self->{previous}, $file."\@".$self->{number});
>
>         my @diff2_context = $self->{p4}->Run("diff2", "-dc",
> $file."\@".$self->{previous}, $file."\@".$self->{number});
>
> results in a data structure that doesn't contain a diff - in both cases
> the output is
>
>   DB<5> x @diff2
> 0  HASH(0x32f97cc)
>    'depotFile' => ARRAY(0x32f9de4)
>       0  $file
>       1  $file
>    'rev' => ARRAY(0x3224948)
>       0  3
>       1  4
>    'status' => 'content'
>    'type' => ARRAY(0x32f9f34)
>       0  'text'
>       1  'text'
>
> Am I doing something wrong? Running the equivalent command on the command
> line produces the diff I'd expect, as does P4Perl without ParseForms.



More information about the p4perl mailing list