ClearCase-SyncTree
view release on metacpan or search on metacpan
summary verbose=i vp Version
)) || exit 1;
usage() if $opt{help};
if ($opt{Version}) {
print ClearCase::SyncTree->version, "\n";
exit 0;
}
usage("-sbase is a required flag") if !$opt{sbase};
usage("-dbase is a required flag") if !$opt{dbase};
usage("-force and -stop are mutually exclusive") if $opt{force} && $opt{stop};
usage("-yes and -no are mutually exclusive") if $opt{yes} && $opt{no};
usage("-vreuse requires -label") if $opt{vreuse} && !$opt{label};
# Implement the -summary functionality.
if ($opt{summary}) {
my $start = new Benchmark;
ClearCase::Argv->summary; # start keeping stats
END {
if ($start && $opt{summary}) {
# print out the stats we kept
print STDERR ClearCase::Argv->summary;
# show timing data
my $timing = timestr(timediff(new Benchmark, $start));
print "Elapsed time: $timing\n";
}
}
}
if (!exists($opt{verbose}) || $opt{verbose} == 1) {
# do nothing
} elsif ($opt{verbose} == 0) {
ClearCase::Argv->quiet(1);
} else {
ClearCase::Argv->dbglevel(1);
}
# Create the object we'll be working with.
my $sync = ClearCase::SyncTree->new;
# The dest base must be normalized right away so we can work with it.
# This means conversion to an absolute, view-extended, pathname.
$opt{dbase} = $sync->dstbase($opt{dbase});
# Normalize src dir path too.
die "$prog: Error: no such directory $opt{sbase}\n" unless -d $opt{sbase};
$opt{sbase} = Cwd::realpath($opt{sbase});
$opt{sbase} =~ s%\\%/%g if MSWIN;
# Suppress blathering on stdout from cleartool if asked.
ClearCase::Argv->quiet(1) if $opt{quiet};
# Support incremental label families (ClearCase::Wrapper::MGi)
if ($opt{label}) {
my $ct = $sync->clone_ct({autofail=>0, stderr=>0});
my $dvob = $ct->desc(['-s'], "vob:$opt{dbase}")->qx;
my $lbtype = "lbtype:$opt{label}\@$dvob";
$sync->lblver($opt{label}) if $opt{vreuse} && $ct->desc(['-s'], $lbtype)->qx;
my ($inclb) = grep s/-> (lbtype:.*)$/$1/,
$ct->desc([qw(-s -ahl EqInc)], $lbtype)->qx;
if ($inclb) {
die "$prog: Error: incremental label types must be unlocked\n"
if $ct->lslock(['-s'], $lbtype, $inclb)->qx;
$inclb =~ s/^lbtype:(.*)@.*$/$1/;
$sync->inclb($inclb);
}
}
if ($opt{flist}) {
#usage("-flist and -map are mutually exclusive") if $opt{map};
usage("-flist and -Narrow are mutually exclusive") if $opt{Narrow};
open(FLIST, $opt{flist}) || die "$prog: Error: $opt{flist}: $!";
while(<FLIST>) {
chomp;
s/^\s+//;
s/\s+$//;
next if ! $_ || /^#/;
my($from, $to) = split /\s*=>\s*/;
if (! $to) {
$to = $from;
$to =~ s%^$opt{sbase}/%% if $to !~ m%^$opt{dbase}%;
}
ClearCase::SyncTree->canonicalize($opt{sbase}, $from);
ClearCase::SyncTree->canonicalize($opt{dbase}, $to);
$to = $sync->normalize($to);
die "$prog: Error: $from: No such file or directory\n" unless -e $from;
die "$prog: Error: to-file '$to' not under $opt{dbase}\n"
if $to !~ m%^$opt{dbase}%;
if (-d $from) {
opendir(DIR, $from) || warn "$prog: Error: $from: $!";
my @entries = readdir DIR;
closedir(DIR);
next unless @entries == 2;
}
$from =~ s%\\%/%g if MSWIN;
$to =~ s%\\%/%g if MSWIN;
$xfer{$from} = $to;
}
close(FLIST);
# Reopen stdin for further use.
open(STDIN, "<&STDERR") if $opt{flist} eq '-';
}
if ($opt{map}) {
while (@ARGV) {
my($from, $to) = split /\s*=[=>]\s*/, shift;
$to ||= shift;
ClearCase::SyncTree->canonicalize($opt{sbase}, $from);
ClearCase::SyncTree->canonicalize($opt{dbase}, $to);
$to = $sync->normalize($to);
die "$prog: Error: odd number of files specified with -map\n" if !$to;
die "$prog: Error: to-file '$to' not under $opt{dbase}\n"
if $to && $to !~ m%^$opt{dbase}%;
next if -d $from;
$xfer{$from} = $to;
}
} elsif (!$opt{flist}) {
if (@ARGV) {
if (-r $ARGV[0]) { # relative paths are OK, but must point under src
my @argv = @ARGV;
my @abort;
for my $arg (@argv) {
( run in 0.887 second using v1.01-cache-2.11-cpan-39bf76dae61 )