git-svn: Remove unnecessary Git::SVN::Util package
Digest::MD5 is loaded regardless of the package in which it's declared, so move its 'use' statement and the md5sum() function into the main package. Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net> Acked-by: Eric Wong <normalperson@yhbt.net>
This commit is contained in:
parent
70ae04e4e8
commit
8d7c4fad3f
23
git-svn.perl
23
git-svn.perl
@ -35,6 +35,7 @@ push @Git::SVN::Ra::ISA, 'SVN::Ra';
|
|||||||
push @SVN::Git::Editor::ISA, 'SVN::Delta::Editor';
|
push @SVN::Git::Editor::ISA, 'SVN::Delta::Editor';
|
||||||
push @SVN::Git::Fetcher::ISA, 'SVN::Delta::Editor';
|
push @SVN::Git::Fetcher::ISA, 'SVN::Delta::Editor';
|
||||||
use Carp qw/croak/;
|
use Carp qw/croak/;
|
||||||
|
use Digest::MD5;
|
||||||
use IO::File qw//;
|
use IO::File qw//;
|
||||||
use File::Basename qw/dirname basename/;
|
use File::Basename qw/dirname basename/;
|
||||||
use File::Path qw/mkpath/;
|
use File::Path qw/mkpath/;
|
||||||
@ -48,8 +49,7 @@ BEGIN {
|
|||||||
foreach (qw/command command_oneline command_noisy command_output_pipe
|
foreach (qw/command command_oneline command_noisy command_output_pipe
|
||||||
command_input_pipe command_close_pipe/) {
|
command_input_pipe command_close_pipe/) {
|
||||||
for my $package ( qw(SVN::Git::Editor SVN::Git::Fetcher
|
for my $package ( qw(SVN::Git::Editor SVN::Git::Fetcher
|
||||||
Git::SVN::Migration Git::SVN::Log Git::SVN
|
Git::SVN::Migration Git::SVN::Log Git::SVN),
|
||||||
Git::SVN::Util),
|
|
||||||
__PACKAGE__) {
|
__PACKAGE__) {
|
||||||
*{"${package}::$_"} = \&{"Git::$_"};
|
*{"${package}::$_"} = \&{"Git::$_"};
|
||||||
}
|
}
|
||||||
@ -842,19 +842,19 @@ sub cmd_info {
|
|||||||
command_output_pipe(qw(cat-file blob), "HEAD:$path");
|
command_output_pipe(qw(cat-file blob), "HEAD:$path");
|
||||||
if ($file_type eq "link") {
|
if ($file_type eq "link") {
|
||||||
my $file_name = <$fh>;
|
my $file_name = <$fh>;
|
||||||
$checksum = Git::SVN::Util::md5sum("link $file_name");
|
$checksum = md5sum("link $file_name");
|
||||||
} else {
|
} else {
|
||||||
$checksum = Git::SVN::Util::md5sum($fh);
|
$checksum = md5sum($fh);
|
||||||
}
|
}
|
||||||
command_close_pipe($fh, $ctx);
|
command_close_pipe($fh, $ctx);
|
||||||
} elsif ($file_type eq "link") {
|
} elsif ($file_type eq "link") {
|
||||||
my $file_name =
|
my $file_name =
|
||||||
command(qw(cat-file blob), "HEAD:$path");
|
command(qw(cat-file blob), "HEAD:$path");
|
||||||
$checksum =
|
$checksum =
|
||||||
Git::SVN::Util::md5sum("link " . $file_name);
|
md5sum("link " . $file_name);
|
||||||
} else {
|
} else {
|
||||||
open FILE, "<", $path or die $!;
|
open FILE, "<", $path or die $!;
|
||||||
$checksum = Git::SVN::Util::md5sum(\*FILE);
|
$checksum = md5sum(\*FILE);
|
||||||
close FILE or die $!;
|
close FILE or die $!;
|
||||||
}
|
}
|
||||||
$result .= "Checksum: " . $checksum . "\n";
|
$result .= "Checksum: " . $checksum . "\n";
|
||||||
@ -1195,11 +1195,6 @@ sub find_file_type_and_diff_status {
|
|||||||
return ("file", $diff_status);
|
return ("file", $diff_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
package Git::SVN::Util;
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use Digest::MD5;
|
|
||||||
|
|
||||||
sub md5sum {
|
sub md5sum {
|
||||||
my $arg = shift;
|
my $arg = shift;
|
||||||
my $ref = ref $arg;
|
my $ref = ref $arg;
|
||||||
@ -2971,7 +2966,7 @@ sub apply_textdelta {
|
|||||||
|
|
||||||
if (defined $exp) {
|
if (defined $exp) {
|
||||||
seek $base, 0, 0 or croak $!;
|
seek $base, 0, 0 or croak $!;
|
||||||
my $got = Git::SVN::Util::md5sum($base);
|
my $got = ::md5sum($base);
|
||||||
die "Checksum mismatch: $fb->{path} $fb->{blob}\n",
|
die "Checksum mismatch: $fb->{path} $fb->{blob}\n",
|
||||||
"expected: $exp\n",
|
"expected: $exp\n",
|
||||||
" got: $got\n" if ($got ne $exp);
|
" got: $got\n" if ($got ne $exp);
|
||||||
@ -2990,7 +2985,7 @@ sub close_file {
|
|||||||
if (my $fh = $fb->{fh}) {
|
if (my $fh = $fb->{fh}) {
|
||||||
if (defined $exp) {
|
if (defined $exp) {
|
||||||
seek($fh, 0, 0) or croak $!;
|
seek($fh, 0, 0) or croak $!;
|
||||||
my $got = Git::SVN::Util::md5sum($fh);
|
my $got = ::md5sum($fh);
|
||||||
if ($got ne $exp) {
|
if ($got ne $exp) {
|
||||||
die "Checksum mismatch: $path\n",
|
die "Checksum mismatch: $path\n",
|
||||||
"expected: $exp\n got: $got\n";
|
"expected: $exp\n got: $got\n";
|
||||||
@ -3345,7 +3340,7 @@ sub chg_file {
|
|||||||
$fh->flush == 0 or croak $!;
|
$fh->flush == 0 or croak $!;
|
||||||
seek $fh, 0, 0 or croak $!;
|
seek $fh, 0, 0 or croak $!;
|
||||||
|
|
||||||
my $exp = Git::SVN::Util::md5sum($fh);
|
my $exp = ::md5sum($fh);
|
||||||
seek $fh, 0, 0 or croak $!;
|
seek $fh, 0, 0 or croak $!;
|
||||||
|
|
||||||
my $pool = SVN::Pool->new;
|
my $pool = SVN::Pool->new;
|
||||||
|
Loading…
Reference in New Issue
Block a user