Merge branch 'nd/maint-diffstat-summary' into maint
[git.git] / perl / Git / SVN / Utils.pm
1 package Git::SVN::Utils;
2
3 use strict;
4 use warnings;
5
6 use base qw(Exporter);
7
8 our @EXPORT_OK = qw(fatal can_compress);
9
10
11 =head1 NAME
12
13 Git::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
21 This module contains functions which are useful across many different
22 parts of Git::SVN.  Mostly it's a place to put utility functions
23 rather than duplicate the code or have classes grabbing at other
24 classes.
25
26 =head1 FUNCTIONS
27
28 All functions can be imported only on request.
29
30 =head3 fatal
31
32     fatal(@message);
33
34 Display 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.
40 sub fatal (@) { print STDERR "@_\n"; exit 1 }
41
42
43 =head3 can_compress
44
45     my $can_compress = can_compress;
46
47 Returns true if Compress::Zlib is available, false otherwise.
48
49 =cut
50
51 my $can_compress;
52 sub can_compress {
53         return $can_compress if defined $can_compress;
54
55         return $can_compress = eval { require Compress::Zlib; };
56 }
57
58
59 1;