TheOneRing/CVS.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 59 CC 2 SCAR 10.6
CC
2
Cov
0%
revert
6.0
init
2.0
info
2.0
CRAP 2.9
1 # Copyright (C) 2009 Wes Hardaker
2 # License: GNU GPLv2. See the COPYING file for details.
3 package TheOneRing::CVS;
4  
5 use strict;
6 use TheOneRing;
7 use IO::File;
8  
9 our @ISA = qw(TheOneRing);
10  
11 our $VERSION = '0.3';
12  
13 sub init {
14 my ($self) = @_;
15 $self->{'command'} = 'cvs';
16 $self->{'mapping'} =
17 {
18 # might be able to hack this through update
19 # 'status' =>
20 # {
21 # 'args' => { q => 'q' },
22 # },
23  
24 'commit' =>
25 {
26 'args' => { m => '-m',
27 N => 'l'},
28 },
29  
30 'update' =>
31 {
32 # need -D flag equiv
33 'args' => { r => '-r',
34 N => 'l'},
35 },
36  
37 'diff' =>
38 {
39 'args' => { r => '-r',
40 N => 'l'},
41 },
42  
43 'annotate' =>
44 {
45 args => { r => '-r',
46 'N' => 'l'}
47 },
48  
49 'export' =>
50 {
51 args => { N => 'l',
52 r => '-r'}
53 },
54  
55 'log' =>
56 {
57 args => { N => 'l',
58 r => '-r'}
59 },
60  
61 'add' =>
62 {
63 options => ['-m','adding files'],
64 args => { }
65 },
66  
67 'remove' =>
68 {
69 options => ['-f'],
70 args => { N => 'l' }
71 },
72  
73 };
74 }
75  
76 sub info {
77 my $fh = IO::File->new("<CVS/Repository");
78 my $repo = <$fh>;
79 $fh->close;
80  
81 $fh = IO::File->new("<CVS/Root");
82 my $root = <$fh>;
83 $fh->close;
84  
85 print "Root: $root";
86 print "Repository: $repo";
87 chomp($root);
88 print "Full Path: $root/$repo";
89 }
90  
91 sub revert {
92 my ($self, @args) = @_;
93  
94 # lame quick processing
95 my $quiet = 0;
96 while ($args[0] eq '-q') {
97 $quiet = 1;
98 shift @args;
99 }
100  
101 if ($#args == -1) {
102 $self->ERROR("CVS requires you manually specify which files to revert");
103 }
104  
105 foreach my $arg (@args) {
106 unlink($arg);
107 $self->System("cvs update $arg");
108 }
109 }
110  
111 sub ignore {
112 my ($self, @args) = @_;
113 $self->add_to_file(".cvsignore", @args);
114 }
115  
116 sub move {
117 my ($self, @args) = @_;
118 $self->move_by_adddel(@args);
119 }
120  
121 1;