@ -2399,10 +2399,15 @@ sub rev_db_get {
$ret;
$ret;
}
}
# Finds the first svn revision that exists on (if $eq_ok is true) or
# before $rev for the current branch. It will not search any lower
# than $min_rev. Returns the git commit hash and svn revision number
# if found, else (undef, undef).
sub find_rev_before {
sub find_rev_before {
my ($self, $rev, $eq_ok) = @_;
my ($self, $rev, $eq_ok, $min_rev) = @_;
--$rev unless $eq_ok;
--$rev unless $eq_ok;
while ($rev > 0) {
$min_rev ||= 1;
while ($rev >= $min_rev) {
if (my $c = $self->rev_db_get($rev)) {
if (my $c = $self->rev_db_get($rev)) {
return ($rev, $c);
return ($rev, $c);
}
}
@ -2411,6 +2416,23 @@ sub find_rev_before {
return (undef, undef);
return (undef, undef);
}
}
# Finds the first svn revision that exists on (if $eq_ok is true) or
# after $rev for the current branch. It will not search any higher
# than $max_rev. Returns the git commit hash and svn revision number
# if found, else (undef, undef).
sub find_rev_after {
my ($self, $rev, $eq_ok, $max_rev) = @_;
++$rev unless $eq_ok;
$max_rev ||= $self->rev_db_max();
while ($rev <= $max_rev) {
if (my $c = $self->rev_db_get($rev)) {
return ($rev, $c);
}
++$rev;
}
return (undef, undef);
}
sub _new {
sub _new {
my ($class, $repo_id, $ref_id, $path) = @_;
my ($class, $repo_id, $ref_id, $path) = @_;
unless (defined $repo_id && length $repo_id) {
unless (defined $repo_id && length $repo_id) {
@ -3701,6 +3723,7 @@ package Git::SVN::Log;
use strict;
use strict;
use warnings;
use warnings;
use POSIX qw/strftime/;
use POSIX qw/strftime/;
use constant commit_log_separator => ('-' x 72) . "\n";
use vars qw/$TZ $limit $color $pager $non_recursive $verbose $oneline
use vars qw/$TZ $limit $color $pager $non_recursive $verbose $oneline
%rusers $show_commit $incremental/;
%rusers $show_commit $incremental/;
my $l_fmt;
my $l_fmt;
@ -3794,19 +3817,19 @@ sub git_svn_log_cmd {
push @cmd, $c;
push @cmd, $c;
}
}
} elsif (defined $r_max) {
} elsif (defined $r_max) {
my ($c_min, $c_max);
if ($r_max < $r_min) {
$c_max = $gs->rev_db_get($r_max);
($r_min, $r_max) = ($r_max, $r_min);
$c_min = $gs->rev_db_get($r_min);
}
if (defined $c_min && defined $c_max) {
my (undef, $c_max) = $gs->find_rev_before($r_max, 1, $r_min);
if ($r_max > $r_min) {
my (undef, $c_min) = $gs->find_rev_after($r_min, 1, $r_max);
push @cmd, "--boundary", "$c_min..$c_max";
# If there are no commits in the range, both $c_max and $c_min
} else {
# will be undefined. If there is at least 1 commit in the
push @cmd, "--boundary", "$c_max..$c_min";
# range, both will be defined.
}
return () if !defined $c_min || !defined $c_max;
} elsif ($r_max > $r_min) {
if ($c_min eq $c_max) {
push @cmd, $c_max;
push @cmd, '--max-count=1', $c_min;
} else {
} else {
push @cmd, $c_min;
push @cmd, '--boundary', "$c_min..$c_max";
}
}
}
}
return (@cmd, @files);
return (@cmd, @files);
@ -3914,7 +3937,7 @@ sub show_commit_changed_paths {
sub show_commit_normal {
sub show_commit_normal {
my ($c) = @_;
my ($c) = @_;
print '-' x72, "\nr$c->{r} | ";
print commit_log_separator, "r$c->{r} | ";
print "$c->{c} | " if $show_commit;
print "$c->{c} | " if $show_commit;
print "$c->{a} | ", strftime("%Y-%m-%d %H:%M:%S %z (%a, %d %b %Y)",
print "$c->{a} | ", strftime("%Y-%m-%d %H:%M:%S %z (%a, %d %b %Y)",
localtime($c->{t_utc})), ' | ';
localtime($c->{t_utc})), ' | ';
@ -3975,6 +3998,10 @@ sub cmd_show_log {
config_pager();
config_pager();
@args = git_svn_log_cmd($r_min, $r_max, @args);
@args = git_svn_log_cmd($r_min, $r_max, @args);
if (!@args) {
print commit_log_separator unless $incremental || $oneline;
return;
}
my $log = command_output_pipe(@args);
my $log = command_output_pipe(@args);
run_pager();
run_pager();
my (@k, $c, $d, $stat);
my (@k, $c, $d, $stat);
@ -4023,14 +4050,12 @@ sub cmd_show_log {
process_commit($c, $r_min, $r_max, \@k);
process_commit($c, $r_min, $r_max, \@k);
}
}
if (@k) {
if (@k) {
my $swap = $r_max;
($r_min, $r_max) = ($r_max, $r_min);
$r_max = $r_min;
$r_min = $swap;
process_commit($_, $r_min, $r_max) foreach reverse @k;
process_commit($_, $r_min, $r_max) foreach reverse @k;
}
}
out:
out:
close $log;
close $log;
print '-' x72,"\n" unless $incremental || $oneline;
print commit_log_separator unless $incremental || $oneline;
}
}
package Git::SVN::Migration;
package Git::SVN::Migration;