perl / Git / SVN / Utils.pmon commit Merge branch 'mz/cherry-pick-cmdline-order' into maint (78ed88d)
   1package Git::SVN::Utils;
   2
   3use strict;
   4use warnings;
   5
   6use base qw(Exporter);
   7
   8our @EXPORT_OK = qw(fatal can_compress);
   9
  10
  11=head1 NAME
  12
  13Git::SVN::Utils - utility functions used across Git::SVN
  14
  15=head1 SYNOPSIS
  16
  17    use Git::SVN::Utils qw(functions to import);
  18
  19=head1 DESCRIPTION
  20
  21This module contains functions which are useful across many different
  22parts of Git::SVN.  Mostly it's a place to put utility functions
  23rather than duplicate the code or have classes grabbing at other
  24classes.
  25
  26=head1 FUNCTIONS
  27
  28All functions can be imported only on request.
  29
  30=head3 fatal
  31
  32    fatal(@message);
  33
  34Display a message and exit with a fatal error code.
  35
  36=cut
  37
  38# Note: not certain why this is in use instead of die.  Probably because
  39# the exit code of die is 255?  Doesn't appear to be used consistently.
  40sub fatal (@) { print STDERR "@_\n"; exit 1 }
  41
  42
  43=head3 can_compress
  44
  45    my $can_compress = can_compress;
  46
  47Returns true if Compress::Zlib is available, false otherwise.
  48
  49=cut
  50
  51my $can_compress;
  52sub can_compress {
  53        return $can_compress if defined $can_compress;
  54
  55        return $can_compress = eval { require Compress::Zlib; };
  56}
  57
  58
  591;