Merge branch 'es/contacts-blame-L-multi'
* es/contacts-blame-L-multi: contacts: reduce git-blame invocations contacts: gather all blame sources prior to invoking git-blame contacts: validate hunk length earliermaint
commit
3b30ba55e4
|
@ -59,11 +59,11 @@ sub import_commits {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_blame {
|
sub get_blame {
|
||||||
my ($commits, $source, $start, $len, $from) = @_;
|
my ($commits, $source, $from, $ranges) = @_;
|
||||||
$len = 1 unless defined($len);
|
return unless @$ranges;
|
||||||
return if $len == 0;
|
|
||||||
open my $f, '-|',
|
open my $f, '-|',
|
||||||
qw(git blame --porcelain -C), '-L', "$start,+$len",
|
qw(git blame --porcelain -C),
|
||||||
|
map({"-L$_->[0],+$_->[1]"} @$ranges),
|
||||||
'--since', $since, "$from^", '--', $source or die;
|
'--since', $since, "$from^", '--', $source or die;
|
||||||
while (<$f>) {
|
while (<$f>) {
|
||||||
if (/^([0-9a-f]{40}) \d+ \d+ \d+$/) {
|
if (/^([0-9a-f]{40}) \d+ \d+ \d+$/) {
|
||||||
|
@ -76,8 +76,17 @@ sub get_blame {
|
||||||
close $f;
|
close $f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub blame_sources {
|
||||||
|
my ($sources, $commits) = @_;
|
||||||
|
for my $s (keys %$sources) {
|
||||||
|
for my $id (keys %{$sources->{$s}}) {
|
||||||
|
get_blame($commits, $s, $id, $sources->{$s}{$id});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub scan_patches {
|
sub scan_patches {
|
||||||
my ($commits, $id, $f) = @_;
|
my ($sources, $id, $f) = @_;
|
||||||
my $source;
|
my $source;
|
||||||
while (<$f>) {
|
while (<$f>) {
|
||||||
if (/^From ([0-9a-f]{40}) Mon Sep 17 00:00:00 2001$/) {
|
if (/^From ([0-9a-f]{40}) Mon Sep 17 00:00:00 2001$/) {
|
||||||
|
@ -90,7 +99,8 @@ sub scan_patches {
|
||||||
} elsif (/^--- /) {
|
} elsif (/^--- /) {
|
||||||
die "Cannot parse hunk source: $_\n";
|
die "Cannot parse hunk source: $_\n";
|
||||||
} elsif (/^@@ -(\d+)(?:,(\d+))?/ && $source) {
|
} elsif (/^@@ -(\d+)(?:,(\d+))?/ && $source) {
|
||||||
get_blame($commits, $source, $1, $2, $id);
|
my $len = defined($2) ? $2 : 1;
|
||||||
|
push @{$sources->{$source}{$id}}, [$1, $len] if $len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,13 +173,16 @@ for (@ARGV) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my %commits;
|
my %sources;
|
||||||
for (@files) {
|
for (@files) {
|
||||||
scan_patch_file(\%commits, $_);
|
scan_patch_file(\%sources, $_);
|
||||||
}
|
}
|
||||||
if (@rev_args) {
|
if (@rev_args) {
|
||||||
scan_rev_args(\%commits, \@rev_args)
|
scan_rev_args(\%sources, \@rev_args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my %commits;
|
||||||
|
blame_sources(\%sources, \%commits);
|
||||||
import_commits(\%commits);
|
import_commits(\%commits);
|
||||||
|
|
||||||
my $contacts = {};
|
my $contacts = {};
|
||||||
|
|
Loading…
Reference in New Issue