App-SnerpVortex
view release on metacpan or search on metacpan
lib/SVN/Analysis.pm view on Meta::CPAN
my $tree = SVN::Analysis::TreeNode->new(
children => { },
parent => undef,
seq => 0,
ent_name => '',
ent_type => 'repository',
is_add => 0,
is_copy => 0,
name => "(repository)",
path => "",
path_lop => '',
path_prepend => '',
rel_path => '',
revision => 0,
src_path => "",
src_rev => 0,
);
my $sth_tree = $self->dbh()->prepare_cached("
SELECT path, max(rev_first)
FROM dir
WHERE rev_first <= ? AND rev_last >= ?
GROUP BY path
ORDER BY length(path) ASC, path ASC
") or die $self->dbh()->errstr();
# Build a tree from the flat nodes.
$sth_tree->execute($revision, $revision) or die $sth_tree->errstr();
$sth_tree->bind_columns(\my ($path, $rev)) or die $sth_tree->errstr();
while ($sth_tree->fetch()) {
my $sth_node = $self->dbh()->prepare_cached("
SELECT
seq,
is_active, is_add, is_copy, src_path, src_rev,
ent_type, ent_name, rel_path, path_lop, path_prepend
FROM dir
WHERE path = ? AND rev_first = ?
ORDER BY seq DESC
LIMIT 1
") or die $self->dbh()->errstr();
$sth_node->execute($path, $rev) or die $sth_node->errstr();
$sth_node->bind_columns(
\my (
$seq,
$is_active, $is_add, $is_copy, $src_path, $src_rev,
$ent_type, $ent_name, $rel_path, $path_lop, $path_prepend
)
) or die $sth_node->errstr();
$sth_node->fetch() or die $sth_node->errstr();
$sth_node->fetch() and die "more than one node for $path r$rev";
# Traverse to the new node.
my $iter = $tree;
my @segments = split m!/!, $path;
my $final = pop(@segments);
foreach (@segments) {
$iter = $iter->children()->{$_} or die(
"segment $_ from $path r$rev not found"
);
}
if (defined $final) {
die "duplicate segment $final in $path r$rev" if exists(
$iter->children()->{$final}
);
$iter->children()->{$final} = SVN::Analysis::TreeNode->new(
seq => $seq,
path => $path,
name => $final,
revision => $rev,
is_copy => $is_copy,
is_add => $is_add,
src_path => $src_path,
src_rev => $src_rev,
children => { },
parent => $iter,
ent_type => $ent_type,
ent_name => $ent_name,
path_lop => $path_lop,
path_prepend => $path_prepend,
rel_path => $rel_path,
);
}
elsif ($iter != $tree) {
die "wtf";
}
}
return $tree;
}
# Return the copy sources for a given revision, or an empty list for
# none.
sub get_copy_sources_for_revision {
my ($self, $revision) = @_;
my $sth = $self->dbh()->prepare_cached("
SELECT src_path, kind
FROM copy
WHERE src_rev = ?
") or die $self->dbh()->errstr();
$sth->execute($revision) or die $sth->errstr();
$sth->bind_columns(\my ($src_path, $kind)) or die $sth->errstr();
my @copy_sources;
while ($sth->fetch()) {
push @copy_sources, SVN::Analysis::Copy->new(
src_path => $src_path,
kind => $kind,
);
}
( run in 0.994 second using v1.01-cache-2.11-cpan-af0e5977854 )