p4tkd.in #1

  • //
  • guest/
  • anders_johnson/
  • perforce/
  • utils/
  • p4tkd/
  • p4tkd.in
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!@@Perl@@ -w

=head1 NAME

p4tkd - Run tkdiff with $P4CLIENT set

=head1 SYNOPSIS

p4tkd I<tkdiff-args>

=head1 DESCRIPTION

If the current client (as reported by B<p4 info>) is known to the Perforce
database, then the P4CLIENT environment variable is set to its name, and
B<tkdiff> is run with I<tkdiff-args> as its arguments.
Otherwise, an error is printed.

This is convenient if you set the client name via a $P4CONFIG file.

=head1 CAVEATS

=over 2

=item *

Requires the C<P4> module, which requires the C<P4::Client> module, which
is bundled with the C<P4:UI> module.

=back

=head1 SEE ALSO

=over 2

=item *

tkdiff (http://www.accurev.com/free/tkdiff/)

=back

=cut

use strict;
use P4;

my $p4=new P4;
my $client=$p4->GetClient();
$p4->Init() || die("Failed to connect to Perforce Server");
my @info=$p4->Info();
$p4->Final();
my $valid;
for (@info) {
	if(/^Client root:\s+/) {
		$valid=1;
		last;
	}
}
if($valid) {
	$ENV{'P4CLIENT'}=$client;
	exec('@@Tkdiff@@', @ARGV) || die("Failed to exec tkdiff because $!");
}
else {
	die("Client \"$client\" is unknown.\n");
}

# Change User Description Committed
#1 1780 anders_johnson p4checkpoint-0.03, p4tkd-0.01, p4tkmerge-0.02