| 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
| |||||||||||||
| 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"
MC/DC0%0/1
$rev_id ||= "tip"
$rev_id
Truth table0%0/2
A
A= $rev_id
| |||||||||||||
| 28 | 0 | my @path = ('rss-log', $rev_id); | |||||||||||
| 29 | 0 | ▶ | push(@path, $file) if defined $file; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 41 | 0 | $link = $first_item->{'link'}; | |||||||||||
| 42 | } | ||||||||||||
| 43 | 0 | ▶ | last if $link =~ /\Q$rev_id\E/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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; | |||||||||||