ShipIt/VC/Mercurial.pm

filter: Statementstmt 25.6% 10 / 39 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 30.0% 3 / 10 Podpod 71.4% 5 / 7 totaltotal 26.8% 18 / 67 CC 6 SCAR 20.4
CC
6
Cov
20%
tag_version
20.0
commit
6.0
are_local_diffs
6.0
CRAP 7.7
« ShipIt/Step/DistTest.pm ↑ Summary ShipIt/Conf.pm »
1 package ShipIt::VC::Mercurial;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use base 'ShipIt::VC';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use File::Temp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 0 ▶sub command { 'hg' }
Subroutine command: not called CC=1 SCAR=6.9
Pod undocumented
7  
8 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
9 0 my ($class, $conf) = @_;
10 0 my $self = bless {}, $class;
11 0 $self->{push_to} = $conf->value( $self->command . ".push_to" );
12 0 return $self;
13 }
14  
15 =head1 NAME
16  
17 ShipIt::VC::Mercurial -- ShipIt's Mercurial support
18  
19 =head1 CONFIGURATION
20  
21 In your .shipit configuration file, the following options are recognized:
22  
23 =over
24  
25 =item B<hg.push_to>
26  
27 If you want the newly created to be pushed elsewhere (for instance in your
28 public Mercurial repository), then you can specify the destination in this variable
29  
30 =back
31  
32 =cut
33  
34 0 ▶sub exists_tagged_version {
Subroutine exists_tagged_version: not called CC=1 SCAR=6.9
Pod documented
35 0 my ($self, $ver) = @_;
36  
37 0 my $command = $self->command;
38 0 my $x = `$command tags`;
39 0 return $x =~ m/^$ver\s/m;
40 }
41  
42 0 ▶sub commit {
Subroutine commit: not called CC=2 SCAR=17.9
Pod documented
43 0 my ($self, $msg) = @_;
44  
45 0 my $command = $self->command;
46  
47 0 ▶ if ( my $unk = `$command status -u` ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $unk = `$command status -u`) 0 0 0
48 0 die "Unknown local files:\n$unk\n\nUpdate .hgignore, or $command add them";
49 0 exit(1);
50 }
51  
52 # commit
53 0 system($command, "commit", "-m", $msg);
54 }
55  
56 0 ▶sub local_diff {
Subroutine local_diff: not called CC=1 SCAR=6.9
Pod documented
57 0 my ($self, $file) = @_;
58 0 my $command = $self->command;
59 0 return `$command diff $file`;
60 }
61  
62 0 ▶sub tag_version {
Subroutine tag_version: not called CC=4 SCAR=30.0
Pod documented
63 0 my ($self, $ver, $msg) = @_;
64 0 ▶ $msg ||= "Tagging version $ver.\n";
Condition0%0/2
$msg ||= "Tagging version $ver.\n"
l!l
00
MC/DC0%0/1
$msg ||= "Tagging version $ver.\n"
$msg
Truth table0%0/2
A
A= $msg
Aresult
11
00
65  
66 0 warn "TAG: $msg, $ver";
67  
68 0 ▶ system($self->command, "tag", "-m", $msg, $ver)
Branch: 1 branch
BranchTrueFalseTotal
system $self->command, "tag", "-m", $msg, $ver and die "Tagging of version '${ver}' failed.\n" 0 0 0
69 and die "Tagging of version '$ver' failed.\n";
70  
71 0 ▶ if (my $where = $self->{push_to}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $where = $self->{"push_to"}) 0 0 0
72 0 warn "pushing to $where";
73 0 system($self->command, "push", $where);
74 }
75 }
76  
77 0 ▶sub are_local_diffs {
Subroutine are_local_diffs: not called CC=2 SCAR=17.9
Pod documented
78 0 my ($self) = @_;
79 0 my $command = $self->command;
80 0 my $diff = `$command status`;
81 0 ▶ return $diff =~ /\S/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$diff =~ /\S/ ? : 0 0 0
82 }
83  
84 2 1;
« ShipIt/Step/DistTest.pm ↑ Summary ShipIt/Conf.pm »