File Coverage

blib/lib/Cvs/Command/Rtag.pm
Criterion Covered Total %
statement 35 44 79.5
branch 9 22 40.9
condition 2 6 33.3
subroutine 4 8 50.0
pod 0 1 0.0
total 50 81 61.7


line stmt bran cond sub pod time code
1             package Cvs::Command::Rtag;
2              
3 1     1   8 use strict;
  1         3  
  1         83  
4 1     1   771 use Cvs::Result::Rtag;
  1         2  
  1         13  
5 1     1   44 use base qw(Cvs::Command::Base);
  1         2  
  1         868  
6              
7             sub init
8             {
9 1     1 0 3 my($self, $tag, @modules) = @_;
10 1 50       8 $self->SUPER::init(@_) or return;
11              
12 1         4 my $param = {};
13 1 50 33     9 if(defined $modules[-1] && ref $modules[-1] eq 'HASH')
14             {
15 0         0 $param = pop @modules;
16             }
17              
18 1 50 33     8 return $self->error('Missing mandatory option for rtag.')
19             unless defined $tag && defined $modules[0];
20              
21 1         6 $self->default_params
22             (
23             delete => 0,
24             force => 0,
25             branch => 0,
26             release => undef,
27             date => undef,
28             recursive => 1,
29             );
30 1         8 $self->param($param);
31              
32 1         7 $self->command('rtag');
33 1 50       12 $self->push_arg('-d')
34             if $self->param->{delete};
35 1 50       4 $self->push_arg('-F')
36             if $self->param->{force};
37 1 50       3 $self->push_arg('-b')
38             if $self->param->{branch};
39 1 50       9 $self->push_arg('-r', $self->param->{release})
40             if $self->param->{release};
41 1 50       3 $self->push_arg('-D', $self->param->{date})
42             if $self->param->{date};
43 1 50       3 $self->push_arg('-l')
44             unless $self->param->{recursive};
45 1         8 $self->push_arg($tag, @modules);
46 1         3 $self->need_workdir(0);
47              
48 1         15 my $main = $self->new_context();
49 1         8 $self->initial_context($main);
50              
51 1         140 my $result = new Cvs::Result::Rtag;
52 1         7 $self->result($result);
53 1         12 my $current_directory = '';
54              
55             $main->push_handler
56             (
57             qr/^cvs rtag: (?:Unt|T)agging (.*)\n$/, sub
58             {
59 0     0   0 $current_directory = shift->[1];
60             }
61 1         8 );
62             $main->push_handler
63             (
64             qr/^T (.*)\n$/, sub
65             {
66 0     0   0 my($match) = @_;
67 0 0       0 my $file = $current_directory eq '.'
68             ? $match->[1] : $current_directory . '/'. $match->[1];
69 0         0 $result->push_tagged($file);
70             }
71 1         9 );
72             $main->push_handler
73             (
74             qr/^W (.*?) : (.*)\n$/, sub
75             {
76 0     0   0 my($match) = @_;
77 0         0 $result->push_warning($match->[1], $match->[2]);
78             }
79 1         7 );
80             $main->push_handler
81             (
82             qr/^D (.*)\n$/, sub
83             {
84 0 0   0   0 my $file = $current_directory eq '.'
85             ? shift->[1] : $current_directory . '/'. shift->[1];
86 0         0 $result->push_untagged($file);
87             }
88 1         6 );
89              
90 1         9 return $self;
91             }
92              
93             1;
94             =pod
95              
96             =head1 LICENCE
97              
98             This library is free software; you can redistribute it and/or modify
99             it under the terms of the GNU Lesser General Public License as
100             published by the Free Software Foundation; either version 2.1 of the
101             License, or (at your option) any later version.
102              
103             This library is distributed in the hope that it will be useful, but
104             WITHOUT ANY WARRANTY; without even the implied warranty of
105             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
106             Lesser General Public License for more details.
107              
108             You should have received a copy of the GNU Lesser General Public
109             License along with this library; if not, write to the Free Software
110             Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
111             USA
112              
113             =head1 COPYRIGHT
114              
115             Copyright (C) 2003 - Olivier Poitrey
116