#!/usr/bin/perl -w
use lib '.';
use Getopt::Long;
use P4::Modules;
($BRANCH, $file) = ('main', '');
my $help = 0;
(my $cmd = $0) =~ s/.*\///;
sub usage {
print <<_EOF_;
Usage: $cmd -b branch -f file -r root path
$cmd -h
-b branch the default branch to use (def. $BRANCH)
-f file the modules file to use (def. system installed)
-h show usage
_EOF_
exit $_[0] || 0;
}
usage(0) unless @ARGV;
GetOptions('branch=s' => \$BRANCH,
'file=s' => \$file,
'help' => \$help) || usage(1);
usage(0) if $help;
my $path = shift || usage(1);
my $mod = P4::Modules->new($file);
my $depotpath = $mod->where($BRANCH, $path);
print $depotpath ? "$depotpath\n" : "no mapping for $BRANCH and $path\n";
exit 1 unless $depotpath;