Best practice hg-hooks for perl users

Roland Schmitz sch.r at web.de
Thu Sep 3 11:54:40 CDT 2009


Hi,

> Does anybody uses perl specific hooks?
maybe there some (more) perl coders out there using mercurial ...
I found following Perl::Critic (static code analysis) SVN Hook:
#!/usr/bin/perl

use strict;
use warnings;
use Perl::Critic;

my ($repo; $tnx) = @ARGV;

my @files = qx{ svnlook changed "$repo" --transaction $txn };
my $fail;

for my $file (@files) {
  my ($type, $name) = split /\s+/, $file;
  my $content       = qx{ svnlook cat --transaction $txn $repo $name };
  my $pc            = Perl::Critic->new( -severity => 5 );
  my @violations    = $pc->critique( \$content );

  print STDERR $_,"\n" for @violations;
  $fail = 1 if @violations;
}

exit $fail;


Using this as a template i "converted" it into:


#!/usr/bin/perl

use strict;
use warnings;
use Perl::Critic;

my @files = qx{ hg status };
my $fail=0;

for my $file (@files) {
  chomp($file);
  my ($type, $name) = split /\s+/, $file;
  my $content       = qx{ hg cat $name };
  my $pc            = Perl::Critic->new( -severity => 5 );
  my @violations    = $pc->critique( \$content );

  print STDERR $_,"\n" for @violations;
  $fail = 1 if @violations;
}

exit $fail;

If you have increasements to this hook please contact me, if your're using 
other (perl) specific hooks contact me also ;-}
-- 
Mit freundlichem Gruss    Yours sincerely

  Roland Schmitz


More information about the Mercurial mailing list