Bug 387970: _M5 regression issues; this patch moves CvsTag from Bootstrap::Step::Tag to Bootstrap::Util, so other parts can get access to its functionality. (Need this change to fix the Bootstrap::Step::TinderConfig not tagging things when it's done.)

This commit is contained in:
preed@mozilla.com 2007-08-15 17:03:47 -07:00
parent 316ba54207
commit 4e684f94ad
2 changed files with 122 additions and 87 deletions

View File

@ -8,7 +8,7 @@ use File::Copy qw(move);
use POSIX qw(strftime);
use MozBuild::Util qw(MkdirWithPath RunShellCommand);
use Bootstrap::Util qw(CvsCatfile);
use Bootstrap::Util qw(CvsCatfile GetDiffFileList);
use Bootstrap::Step;
use Bootstrap::Step::Tag::Bump;
@ -236,50 +236,34 @@ sub CvsTag {
my %args = @_;
# All the required args first, followed by the optional ones...
die "ASSERT: Bootstrap::Step::Tag::CvsTag(): null tagName" if
(!exists($args{'tagName'}));
my $tagName = $args{'tagName'};
die "ASSERT: Bootstrap::Step::Tag::CvsTag(): null coDir" if
(!exists($args{'coDir'}));
my $coDir = $args{'coDir'};
die "ASSERT: Bootstrap::Step::Tag::CvsTag(): invalid files data" if
(exists($args{'files'}) && ref($args{'files'}) ne 'ARRAY');
die "ASSERT: Bootstrap::Step::Tag::CvsTag(): null logFile"
if (!exists($args{'logFile'}));
my $logFile = $args{'logFile'};
my $branch = exists($args{'branch'}) ? $args{'branch'} : 0;
my $files = exists($args{'files'}) ? $args{'files'} : [];
my $force = exists($args{'force'}) ? $args{'force'} : 0;
die "ASSERT: Bootstrap::Step::Tag::CvsTag(): null coDir" if
(!exists($args{'coDir'}));
# We renamed this argument when CvsTag() got moved...
$args{'cvsDir'} = $args{'coDir'};
# We need to provide the fullpath to Bootstrap::Util::CvsTag() now.
my $config = new Bootstrap::Config();
my $logDir = $config->Get(sysvar => 'logDir');
$args{'logFile'} = catfile($config->Get(sysvar => 'logDir'), $logFile);
# only force or branch specific files, not the whole tree
if ($force && scalar(@{$files}) <= 0) {
die("ASSERT: Bootstrap::Step::Tag::CvsTag(): Cannot specify force without files");
} elsif ($branch && scalar(@{$files}) <= 0) {
die("ASSERT: Bootstrap::Step::Tag::CvsTag(): Cannot specify branch without files");
} elsif ($branch && $force) {
die("ASSERT: Bootstrap::Step::Tag::CvsTag(): Cannot specify both branch and force");
# We call this by full scoping (and don't include it in the use() statement
# for Bootstrap::Util above) to disambiguate between the Util version and
# the Tag version, which is a shim now.
my $rv = Bootstrap::Util::CvsTag(%args);
my $exitValue = $rv->{'exitValue'};
my $timedOut = $rv->{'timedOut'};
my $signalNum = $rv->{'signalNum'};
my $dumpedCore = $rv->{'dumpedCore'};
if ($timedOut || ($exitValue != 0)) {
$this->Log(msg => "Bootstrap::Step::Tag::CvsTag failed; rv was $exitValue, output: $rv->{'output'}");
die("Bootstrap::Step::Tag::CvsTag: returned bad exit code: $exitValue");
}
my @cmdArgs;
push(@cmdArgs, 'tag');
push(@cmdArgs, '-F') if ($force);
push(@cmdArgs, '-b') if ($branch);
push(@cmdArgs, $tagName);
push(@cmdArgs, @{$files}) if (scalar(@{$files}) > 0);
$this->Shell(
cmd => 'cvs',
cmdArgs => \@cmdArgs,
dir => $coDir,
logFile => $logFile,
);
}
#
@ -326,53 +310,4 @@ sub GenerateRelbranchName {
return 'GECKO' . $geckoVersion . '_' . $geckoDateSpec . '_RELBRANCH';
}
sub GetDiffFileList {
my $this = shift;
my %args = @_;
foreach my $requiredArg (qw(cvsDir prevTag newTag)) {
if (!exists($args{$requiredArg})) {
die "ASSERT: MozBuild::Util::GetDiffFileList(): null arg: " .
$requiredArg;
}
}
my $cvsDir = $args{'cvsDir'};
my $firstTag = $args{'prevTag'};
my $newTag = $args{'newTag'};
my $rv = RunShellCommand(command => 'cvs',
args => ['diff', '-uN',
'-r', $firstTag,
'-r', $newTag],
dir => $cvsDir,
timeout => 3600);
# Gah. So, the shell return value of "cvs diff" is dependent on whether or
# not there were diffs, NOT whether or not the command succeeded. (Thanks,
# CVS!) So, we can't really check exitValue here, since it could be 1 or
# 0, depending on whether or not there were diffs (and both cases are valid
# for this function). Maybe if there's an error it returns a -1? Or 2?
# Who knows.
#
# So basically, we check that it's not 1 or 0, which... isn't a great test.
#
# TODO - check to see if timedOut, dumpedCore, or sigNum are set.
if ($rv->{'exitValue'} != 1 && $rv->{'exitValue'} != 0) {
die("ASSERT: MozBuild::Util::GetDiffFileList(): cvs diff returned " .
$rv->{'exitValue'});
}
my @differentFiles = ();
foreach my $line (split(/\n/, $rv->{'output'})) {
if ($line =~ /^Index:\s(.+)$/) {
push(@differentFiles, $1);
}
}
return \@differentFiles;
}
1;

View File

@ -10,7 +10,9 @@ use MozBuild::Util qw(RunShellCommand);
use base qw(Exporter);
our @EXPORT_OK = qw(CvsCatfile GetLocaleManifest
our @EXPORT_OK = qw(CvsCatfile CvsTag
GetDiffFileList
GetLocaleManifest
GetBouncerPlatforms GetPatcherPlatforms
GetBouncerToPatcherPlatformMap);
@ -165,4 +167,102 @@ sub GetLocaleManifest {
return $localeManifest;
}
sub CvsTag {
my %args = @_;
# All the required args first, followed by the optional ones...
die "ASSERT: Bootstrap::Step::Tag::CvsTag(): null tagName" if
(!exists($args{'tagName'}));
my $tagName = $args{'tagName'};
die "ASSERT: Bootstrap::Step::Tag::CvsTag(): null cvsDir" if
(!exists($args{'cvsDir'}));
my $cvsDir = $args{'cvsDir'};
die "ASSERT: Bootstrap::Step::Tag::CvsTag(): invalid files data" if
(exists($args{'files'}) && ref($args{'files'}) ne 'ARRAY');
die "ASSERT: Bootstrap::Step::Tag::CvsTag(): null logFile"
if (!exists($args{'logFile'}));
my $logFile = $args{'logFile'};
my $branch = exists($args{'branch'}) ? $args{'branch'} : 0;
my $files = exists($args{'files'}) ? $args{'files'} : [];
my $force = exists($args{'force'}) ? $args{'force'} : 0;
my $timeout = exists($args{'timeout'}) ? $args{'timeout'} : undef;
# only force or branch specific files, not the whole tree
if ($force && scalar(@{$files}) <= 0) {
die("ASSERT: Bootstrap::Util::CvsTag(): Cannot specify force without files");
} elsif ($branch && scalar(@{$files}) <= 0) {
die("ASSERT: Bootstrap::UtilCvsTag(): Cannot specify branch without files");
} elsif ($branch && $force) {
die("ASSERT: Bootstrap::UtilCvsTag(): Cannot specify both branch and force");
}
my @cmdArgs;
push(@cmdArgs, 'tag');
push(@cmdArgs, '-F') if ($force);
push(@cmdArgs, '-b') if ($branch);
push(@cmdArgs, $tagName);
push(@cmdArgs, @{$files}) if (scalar(@{$files}) > 0);
my %cvsTagArgs = (command => 'cvs',
args => \@cmdArgs,
dir => $cvsDir,
logfile => $logFile);
$cvsTagArgs{'timeout'} = $timeout if (defined($timeout));
return RunShellCommand(%cvsTagArgs);
}
sub GetDiffFileList {
my %args = @_;
foreach my $requiredArg (qw(cvsDir prevTag newTag)) {
if (!exists($args{$requiredArg})) {
die "ASSERT: MozBuild::Util::GetDiffFileList(): null arg: " .
$requiredArg;
}
}
my $cvsDir = $args{'cvsDir'};
my $firstTag = $args{'prevTag'};
my $newTag = $args{'newTag'};
my $rv = RunShellCommand(command => 'cvs',
args => ['diff', '-uN',
'-r', $firstTag,
'-r', $newTag],
dir => $cvsDir,
timeout => 3600);
# Gah. So, the shell return value of "cvs diff" is dependent on whether or
# not there were diffs, NOT whether or not the command succeeded. (Thanks,
# CVS!) So, we can't really check exitValue here, since it could be 1 or
# 0, depending on whether or not there were diffs (and both cases are valid
# for this function). Maybe if there's an error it returns a -1? Or 2?
# Who knows.
#
# So basically, we check that it's not 1 or 0, which... isn't a great test.
#
# TODO - check to see if timedOut, dumpedCore, or sigNum are set.
if ($rv->{'exitValue'} != 1 && $rv->{'exitValue'} != 0) {
die("ASSERT: MozBuild::Util::GetDiffFileList(): cvs diff returned " .
$rv->{'exitValue'});
}
my @differentFiles = ();
foreach my $line (split(/\n/, $rv->{'output'})) {
if ($line =~ /^Index:\s(.+)$/) {
push(@differentFiles, $1);
}
}
return \@differentFiles;
}
1;