git-svn: use git-log rather than rev-list | xargs cat-file
This saves a bit of time when rebuilding the git-svn index. Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz> Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
06f59e9f5d
commit
3dfab993c8
36
git-svn.perl
36
git-svn.perl
@ -787,12 +787,12 @@ sub read_repo_config {
|
|||||||
|
|
||||||
sub extract_metadata {
|
sub extract_metadata {
|
||||||
my $id = shift or return (undef, undef, undef);
|
my $id = shift or return (undef, undef, undef);
|
||||||
my ($url, $rev, $uuid) = ($id =~ /^git-svn-id:\s(\S+?)\@(\d+)
|
my ($url, $rev, $uuid) = ($id =~ /^\s*git-svn-id:\s+(.*)\@(\d+)
|
||||||
\s([a-f\d\-]+)$/x);
|
\s([a-f\d\-]+)$/x);
|
||||||
if (!defined $rev || !$uuid || !$url) {
|
if (!defined $rev || !$uuid || !$url) {
|
||||||
# some of the original repositories I made had
|
# some of the original repositories I made had
|
||||||
# identifiers like this:
|
# identifiers like this:
|
||||||
($rev, $uuid) = ($id =~/^git-svn-id:\s(\d+)\@([a-f\d\-]+)/);
|
($rev, $uuid) = ($id =~/^\s*git-svn-id:\s(\d+)\@([a-f\d\-]+)/);
|
||||||
}
|
}
|
||||||
return ($url, $rev, $uuid);
|
return ($url, $rev, $uuid);
|
||||||
}
|
}
|
||||||
@ -804,10 +804,16 @@ sub cmt_metadata {
|
|||||||
|
|
||||||
sub working_head_info {
|
sub working_head_info {
|
||||||
my ($head, $refs) = @_;
|
my ($head, $refs) = @_;
|
||||||
my ($fh, $ctx) = command_output_pipe('rev-list', $head);
|
my ($fh, $ctx) = command_output_pipe('log', $head);
|
||||||
while (my $hash = <$fh>) {
|
my $hash;
|
||||||
chomp($hash);
|
while (<$fh>) {
|
||||||
my ($url, $rev, $uuid) = cmt_metadata($hash);
|
if ( m{^commit ($::sha1)$} ) {
|
||||||
|
unshift @$refs, $hash if $hash and $refs;
|
||||||
|
$hash = $1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
next unless s{^\s*(git-svn-id:)}{$1};
|
||||||
|
my ($url, $rev, $uuid) = extract_metadata($_);
|
||||||
if (defined $url && defined $rev) {
|
if (defined $url && defined $rev) {
|
||||||
if (my $gs = Git::SVN->find_by_url($url)) {
|
if (my $gs = Git::SVN->find_by_url($url)) {
|
||||||
my $c = $gs->rev_db_get($rev);
|
my $c = $gs->rev_db_get($rev);
|
||||||
@ -817,7 +823,6 @@ sub working_head_info {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unshift @$refs, $hash if $refs;
|
|
||||||
}
|
}
|
||||||
command_close_pipe($fh, $ctx);
|
command_close_pipe($fh, $ctx);
|
||||||
(undef, undef, undef, undef);
|
(undef, undef, undef, undef);
|
||||||
@ -1966,16 +1971,19 @@ sub rebuild {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print "Rebuilding $db_path ...\n";
|
print "Rebuilding $db_path ...\n";
|
||||||
my ($rev_list, $ctx) = command_output_pipe("rev-list", $self->refname);
|
my ($log, $ctx) = command_output_pipe("log", $self->refname);
|
||||||
my $latest;
|
my $latest;
|
||||||
my $full_url = $self->full_url;
|
my $full_url = $self->full_url;
|
||||||
remove_username($full_url);
|
remove_username($full_url);
|
||||||
my $svn_uuid;
|
my $svn_uuid;
|
||||||
while (<$rev_list>) {
|
my $c;
|
||||||
chomp;
|
while (<$log>) {
|
||||||
my $c = $_;
|
if ( m{^commit ($::sha1)$} ) {
|
||||||
die "Non-SHA1: $c\n" unless $c =~ /^$::sha1$/o;
|
$c = $1;
|
||||||
my ($url, $rev, $uuid) = ::cmt_metadata($c);
|
next;
|
||||||
|
}
|
||||||
|
next unless s{^\s*(git-svn-id:)}{$1};
|
||||||
|
my ($url, $rev, $uuid) = ::extract_metadata($_);
|
||||||
remove_username($url);
|
remove_username($url);
|
||||||
|
|
||||||
# ignore merges (from set-tree)
|
# ignore merges (from set-tree)
|
||||||
@ -1993,7 +2001,7 @@ sub rebuild {
|
|||||||
$self->rev_db_set($rev, $c);
|
$self->rev_db_set($rev, $c);
|
||||||
print "r$rev = $c\n";
|
print "r$rev = $c\n";
|
||||||
}
|
}
|
||||||
command_close_pipe($rev_list, $ctx);
|
command_close_pipe($log, $ctx);
|
||||||
print "Done rebuilding $db_path\n";
|
print "Done rebuilding $db_path\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user