|
10 | 10 | $AUTHOR = 'Eric Wong <normalperson@yhbt.net>'; |
11 | 11 | $VERSION = '@@GIT_VERSION@@'; |
12 | 12 |
|
| 13 | +use Git::SVN::Utils qw(fatal can_compress); |
| 14 | + |
13 | 15 | # From which subdir have we been invoked? |
14 | 16 | my $cmd_dir_prefix = eval { |
15 | 17 | command_oneline([qw/rev-parse --show-prefix/], STDERR => 0) |
|
35 | 37 | $ENV{TZ} = 'UTC'; |
36 | 38 | $| = 1; # unbuffer STDOUT |
37 | 39 |
|
38 | | -sub fatal (@) { print STDERR "@_\n"; exit 1 } |
39 | | - |
40 | 40 | # All SVN commands do it. Otherwise we may die on SIGPIPE when the remote |
41 | 41 | # repository decides to close the connection which we expect to be kept alive. |
42 | 42 | $SIG{PIPE} = 'IGNORE'; |
@@ -66,7 +66,7 @@ sub _req_svn { |
66 | 66 | fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)"; |
67 | 67 | } |
68 | 68 | } |
69 | | -my $can_compress = eval { require Compress::Zlib; 1}; |
| 69 | + |
70 | 70 | use Carp qw/croak/; |
71 | 71 | use Digest::MD5; |
72 | 72 | use IO::File qw//; |
@@ -1578,7 +1578,7 @@ sub cmd_reset { |
1578 | 1578 | } |
1579 | 1579 |
|
1580 | 1580 | sub cmd_gc { |
1581 | | - if (!$can_compress) { |
| 1581 | + if (!can_compress()) { |
1582 | 1582 | warn "Compress::Zlib could not be found; unhandled.log " . |
1583 | 1583 | "files will not be compressed.\n"; |
1584 | 1584 | } |
@@ -2013,13 +2013,13 @@ sub md5sum { |
2013 | 2013 | } elsif (!$ref) { |
2014 | 2014 | $md5->add($arg) or croak $!; |
2015 | 2015 | } else { |
2016 | | - ::fatal "Can't provide MD5 hash for unknown ref type: '", $ref, "'"; |
| 2016 | + fatal "Can't provide MD5 hash for unknown ref type: '", $ref, "'"; |
2017 | 2017 | } |
2018 | 2018 | return $md5->hexdigest(); |
2019 | 2019 | } |
2020 | 2020 |
|
2021 | 2021 | sub gc_directory { |
2022 | | - if ($can_compress && -f $_ && basename($_) eq "unhandled.log") { |
| 2022 | + if (can_compress() && -f $_ && basename($_) eq "unhandled.log") { |
2023 | 2023 | my $out_filename = $_ . ".gz"; |
2024 | 2024 | open my $in_fh, "<", $_ or die "Unable to open $_: $!\n"; |
2025 | 2025 | binmode $in_fh; |
@@ -2054,6 +2054,9 @@ package Git::SVN; |
2054 | 2054 | use Memoize; # core since 5.8.0, Jul 2002 |
2055 | 2055 | use Memoize::Storable; |
2056 | 2056 | use POSIX qw(:signal_h); |
| 2057 | + |
| 2058 | +use Git::SVN::Utils qw(fatal can_compress); |
| 2059 | + |
2057 | 2060 | my $can_use_yaml; |
2058 | 2061 | BEGIN { |
2059 | 2062 | $can_use_yaml = eval { require Git::SVN::Memoize::YAML; 1}; |
@@ -2879,8 +2882,8 @@ sub assert_index_clean { |
2879 | 2882 | command_noisy('read-tree', $treeish); |
2880 | 2883 | $x = command_oneline('write-tree'); |
2881 | 2884 | if ($y ne $x) { |
2882 | | - ::fatal "trees ($treeish) $y != $x\n", |
2883 | | - "Something is seriously wrong..."; |
| 2885 | + fatal "trees ($treeish) $y != $x\n", |
| 2886 | + "Something is seriously wrong..."; |
2884 | 2887 | } |
2885 | 2888 | }); |
2886 | 2889 | } |
@@ -3235,7 +3238,7 @@ sub mkemptydirs { |
3235 | 3238 | my %empty_dirs = (); |
3236 | 3239 | my $gz_file = "$self->{dir}/unhandled.log.gz"; |
3237 | 3240 | if (-f $gz_file) { |
3238 | | - if (!$can_compress) { |
| 3241 | + if (!can_compress()) { |
3239 | 3242 | warn "Compress::Zlib could not be found; ", |
3240 | 3243 | "empty directories in $gz_file will not be read\n"; |
3241 | 3244 | } else { |
@@ -3918,7 +3921,7 @@ sub set_tree { |
3918 | 3921 | my ($self, $tree) = (shift, shift); |
3919 | 3922 | my $log_entry = ::get_commit_entry($tree); |
3920 | 3923 | unless ($self->{last_rev}) { |
3921 | | - ::fatal("Must have an existing revision to commit"); |
| 3924 | + fatal("Must have an existing revision to commit"); |
3922 | 3925 | } |
3923 | 3926 | my %ed_opts = ( r => $self->{last_rev}, |
3924 | 3927 | log => $log_entry->{log}, |
@@ -4347,6 +4350,7 @@ sub remove_username { |
4347 | 4350 | package Git::SVN::Log; |
4348 | 4351 | use strict; |
4349 | 4352 | use warnings; |
| 4353 | +use Git::SVN::Utils qw(fatal); |
4350 | 4354 | use POSIX qw/strftime/; |
4351 | 4355 | use constant commit_log_separator => ('-' x 72) . "\n"; |
4352 | 4356 | use vars qw/$TZ $limit $color $pager $non_recursive $verbose $oneline |
@@ -4445,15 +4449,15 @@ sub config_pager { |
4445 | 4449 | sub run_pager { |
4446 | 4450 | return unless defined $pager; |
4447 | 4451 | pipe my ($rfd, $wfd) or return; |
4448 | | - defined(my $pid = fork) or ::fatal "Can't fork: $!"; |
| 4452 | + defined(my $pid = fork) or fatal "Can't fork: $!"; |
4449 | 4453 | if (!$pid) { |
4450 | 4454 | open STDOUT, '>&', $wfd or |
4451 | | - ::fatal "Can't redirect to stdout: $!"; |
| 4455 | + fatal "Can't redirect to stdout: $!"; |
4452 | 4456 | return; |
4453 | 4457 | } |
4454 | | - open STDIN, '<&', $rfd or ::fatal "Can't redirect stdin: $!"; |
| 4458 | + open STDIN, '<&', $rfd or fatal "Can't redirect stdin: $!"; |
4455 | 4459 | $ENV{LESS} ||= 'FRSX'; |
4456 | | - exec $pager or ::fatal "Can't run pager: $! ($pager)"; |
| 4460 | + exec $pager or fatal "Can't run pager: $! ($pager)"; |
4457 | 4461 | } |
4458 | 4462 |
|
4459 | 4463 | sub format_svn_date { |
@@ -4602,7 +4606,7 @@ sub cmd_show_log { |
4602 | 4606 | } elsif ($::_revision =~ /^\d+$/) { |
4603 | 4607 | $r_min = $r_max = $::_revision; |
4604 | 4608 | } else { |
4605 | | - ::fatal "-r$::_revision is not supported, use ", |
| 4609 | + fatal "-r$::_revision is not supported, use ", |
4606 | 4610 | "standard 'git log' arguments instead"; |
4607 | 4611 | } |
4608 | 4612 | } |
|
0 commit comments