VCI/VCS/Hg/History.pm

filter: Statementstmt 26.4% 9 / 34 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 50.0% 2 / 4 Podpod 0.0% 0 / 1 totaltotal 20.3% 11 / 54 CC 8 SCAR 36.1
CC
8
Cov
19%
_x_get_rss_commits
56.0
x_from_rss
6.0
BEGIN
1.0
CRAP 36.9
« VCI/VCS/Svn/Directory.pm ↑ Summary VCI/VCS/Git/Directory.pm »
1 package VCI::VCS::Hg::History;
2 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use XML::Simple qw(:strict);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 extends 'VCI::Abstract::History';
7  
8 0 ▶sub x_from_rss {
Subroutine x_from_rss: not called CC=2 SCAR=17.9
Pod undocumented
9 0 my ($class, $file, $project) = @_;
10 0 my $xs = XML::Simple->new(ForceArray => [qw(item)],
11 KeyAttr => []);
12
13 0 my (@commits, $last_rev_id);
14 0 while (1) {
15 0 my $these_commits = _x_get_rss_commits($project, $xs, $last_rev_id, $file);
16 0 ▶ last if !scalar @$these_commits;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @$these_commits 0 0 0
17 0 $last_rev_id = $these_commits->[-1]->revision;
18 0 push(@commits, @$these_commits);
19 }
20 0 @commits = reverse @commits;
21
22 0 return $class->new(commits => \@commits, project => $project);
23 }
24  
25 0 ▶sub _x_get_rss_commits {
Subroutine _x_get_rss_commits: not called CC=7 SCAR=40.3
26 0 my ($project, $xs, $rev_id, $file) = @_;
27 0 ▶ $rev_id ||= 'tip';
Condition0%0/2
$rev_id ||= "tip"
l!l
00
MC/DC0%0/1
$rev_id ||= "tip"
$rev_id
Truth table0%0/2
A
A= $rev_id
Aresult
11
00
28 0 my @path = ('rss-log', $rev_id);
29 0 ▶ push(@path, $file) if defined $file;
Branch: 1 branch
BranchTrueFalseTotal
if defined $file 0 0 0
30 0 my $rss = $project->x_get(\@path);
31 0 my $xml = $xs->xml_in($rss);
32 0 my $items = $xml->{channel}->{item};
33 0 ▶ if ($rev_id ne 'tip') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rev_id ne "tip") 0 0 0
34 # We always get the $rev_id we requested as the first item, except
35 # on the last page, where it could be the first, second, third, etc.
36 # This code works correctly in all situations.
37 0 ▶ while (my $first_item = shift(@$items)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $first_item = shift @$items) 0 0 0
38 0 my $link = $first_item->{'guid'}->{'content'};
39 # Older versions of hgweb have the link in "link"
40 0 ▶ if (!$link) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($link) 0 0 0
41 0 $link = $first_item->{'link'};
42 }
43 0 ▶ last if $link =~ /\Q$rev_id\E/;
Branch: 1 branch
BranchTrueFalseTotal
if $link =~ /\Q$rev_id\E/ 0 0 0
44 }
45 }
46 0 return [map { $project->commit_class->x_from_rss_item($_, $project) }
47 @$items];
48 }
49  
50 1 __PACKAGE__->meta->make_immutable;
51  
52 1 1;
« VCI/VCS/Svn/Directory.pm ↑ Summary VCI/VCS/Git/Directory.pm »