sub usage {
print <<__EOF__;
-$0: Usage: $0 [[--maintainer M --module M --files]|file ...]
+$0: Usage: $0 [[--maintainer M --module M --files --check]|file ...]
--maintainer M list all maintainers matching M
--module M list all modules matching M
--files list all files
+--check check consistency of Maintainers.pl
+--opened list all modules of files opened by perforce
Matching is case-ignoring regexp, author matching is both by
the short id and by the full name and email. A "module" may
not be just a module, it may be a file or files or a subdirectory.
my $Maintainer;
my $Module;
my $Files;
+my $Check;
+my $Opened;
sub process_options {
usage()
'maintainer=s' => \$Maintainer,
'module=s' => \$Module,
'files' => \$Files,
+ 'check' => \$Check,
+ 'opened' => \$Opened,
);
- my @Files = @ARGV;
+ my @Files;
+
+ if ($Opened) {
+ my @raw = `p4 opened`;
+ die if $?;
+ @Files = map {s!#.*!!s; s!^//depot/.*?/perl/!!; $_} @raw;
+ } else {
+ @Files = @ARGV;
+ }
usage() if @Files && ($Maintainer || $Module || $Files);
}
}
}
+ elsif ($Check) {
+ duplicated_maintainers();
+ }
else {
usage();
}
}
+sub duplicated_maintainers {
+ my %files;
+ for my $k (keys %Modules) {
+ for my $f (get_module_files($k)) {
+ ++$files{$f};
+ }
+ }
+ for my $f (keys %files) {
+ if ($files{$f} > 1) {
+ warn "File $f appears $files{$f} times in Maintainers.pl\n";
+ }
+ }
+}
+
1;