#!/usr/bin/perl -w use lib '.'; use Getopt::Long; use P4::Modules; ($CHILD, $MODULES, $PARENT) = ('', '', 'main'); ($NAME, $file) = ('', ''); my $help = 0; (my $cmd = $0) =~ s/.*\///; sub usage { print <<_EOF_; Usage: $cmd -f file configfile $cmd -c child -f file -m 'modules' -n name -p parent $cmd -h -c child the branch to create (no default) -f file the module file to use (def. system installed) -h show usage -m modules modules to map from the perforce depots (no default) -n name the name of this new branch (no default) -p parent the default branch to use (def. $PARENT) _EOF_ exit $_[0] || 0; } usage(0) unless @ARGV; GetOptions('child=s' => \$CHILD, 'file=s' => \$file, 'help' => \$help, 'modules=s' => \$MODULES, 'name=s' => \$NAME, 'parent=s' => \$PARENT) || usage(1); usage(0) if $help; my $config = shift; require $config if $config; my $mod = P4::Modules->new($file); my %map = $mod->branch($PARENT, $MODULES, $CHILD); $branch_spec = <<_EOF_; Branch: $NAME Description: Automatically generated branch PARENT: $PARENT CHILD: $CHILD MODULES: $MODULES View: _EOF_ $branch_spec .= join("\n", map { "\t$_ $map{$_}" } keys %map) . "\n"; print "$branch_spec";