| 1 | package VCfs; | ||||||||||||||||||||
| 2 | 1 | $VERSION = v0.0.1; | |||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 1 | ▶ | use File::Basename qw( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | dirname | ||||||||||||||||||||
| 10 | 1 | ); | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | ▶ | use IPC::Run (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 1 | ▶ | use Class::Accessor::Classy; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 1 | ro qw( | |||||||||||||||||||
| 16 | dir | ||||||||||||||||||||
| 17 | vcs | ||||||||||||||||||||
| 18 | vcs_cmd | ||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||
| 20 | 1 | ▶ | no Class::Accessor::Classy; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | =head1 NAME | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | VCfs - Version Control agnostic interface on the local system | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | =head1 Synopsis | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | my $vc = VCfs->new("."); | ||||||||||||||||||||
| 29 | my %status = $vc->status; | ||||||||||||||||||||
| 30 | my @tags = $vc->taglist; | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =head1 About | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | I need somewhere to put all of this repeated code. There are probably | ||||||||||||||||||||
| 35 | other modules on the CPAN which do this sort of thing differently. The | ||||||||||||||||||||
| 36 | basic idea is to just capture output from shelling-out to the | ||||||||||||||||||||
| 37 | appropriate frontend command for a given version control tool. Examples | ||||||||||||||||||||
| 38 | of usage can be found in the 'bin/' directory of this distribution. | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | Where necessary, assumes a typical "trunk,branches,tags" layout. | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | This currently supports svn and svk. Your help and input is welcome. | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | =cut | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =head1 Constructor | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | =head2 new | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | $vc = VCfs->new($dir|$file, \%options); | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||
| 55 | 0 | my $caller = shift; | |||||||||||||||||||
| 56 | 0 | my ($dir, $opts) = @_; | |||||||||||||||||||
| 57 | 0 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||
|
Condition0%0/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table0%0/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||
| 58 | 0 | ▶ | my $self = {$opts ? %$opts : ()}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 0 | ▶ | $dir or croak("constructor must have a directory or file"); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 61 | 0 | ▶ | unless(-d $dir) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | 0 | $dir = dirname($dir); | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | 0 | ▶ | (-d $dir) or croak("eek"); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 65 | 0 | $self->{dir} = $dir; | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | bless($self, $class); | |||||||||||||||||||
| 68 | 0 | $self->detect; | |||||||||||||||||||
| 69 | 0 | return($self); | |||||||||||||||||||
| 70 | } # end subroutine new definition | ||||||||||||||||||||
| 71 | ######################################################################## | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | =head1 Methods | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | =head2 detect | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | Tries to guess at what sort of VCS by examining the directory. | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | $vc->detect; | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | =cut | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 0 | ▶ | sub detect { | ||||||||||||||||||
|
Subroutine
detect: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 84 | 0 | my $self = shift; | |||||||||||||||||||
| 85 | 0 | my $dir = $self->{dir}; | |||||||||||||||||||
| 86 | 0 | ▶ | (-d $dir) or croak("eek"); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 87 | 0 | my %dmatches = ( | |||||||||||||||||||
| 88 | svn => "$dir/.svn", | ||||||||||||||||||||
| 89 | darcs => "$dir/_darcs", | ||||||||||||||||||||
| 90 | cvs => "$dir/CVS", | ||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||
| 92 | 0 | foreach my $k (keys(%dmatches)) { | |||||||||||||||||||
| 93 | 0 | ▶ | (-d $dmatches{$k}) and ($self->{vcs} = $k); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | 0 | ▶ | $self->{vcs} ||= 'svk'; # the oddball | ||||||||||||||||||
|
Condition0%0/2
$self->{"vcs"} ||= "svk"
MC/DC0%0/1
$self->{"vcs"} ||= "svk"
$self->{"vcs"}
Truth table0%0/2
A
A= $self->{"vcs"}
| |||||||||||||||||||||
| 96 | 0 | $self->{vcs_cmd} = $self->{vcs}; # XXX for now; | |||||||||||||||||||
| 97 | } # end subroutine detect definition | ||||||||||||||||||||
| 98 | ######################################################################## | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | =head2 _do_run | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | %res = $vc->_do_run(@command); | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =cut | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 0 | ▶ | sub _do_run { | ||||||||||||||||||
|
Subroutine
_do_run: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 107 | 0 | my $self = shift; | |||||||||||||||||||
| 108 | 0 | my @command = @_; | |||||||||||||||||||
| 109 | 0 | my ($in, $out, $err); | |||||||||||||||||||
| 110 | 0 | 0 and warn "run $self->{vcs_cmd} @command\n"; | |||||||||||||||||||
| 111 | 0 | my $ret = IPC::Run::run([$self->vcs_cmd, @command], \$in, \$out, \$err); | |||||||||||||||||||
| 112 | 0 | ▶ | $ret or die "command died $err"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 113 | 0 | return(out => $out, err => $err, status => ($? >> 8), ret => $ret); | |||||||||||||||||||
| 114 | } # end subroutine _do_run definition | ||||||||||||||||||||
| 115 | ######################################################################## | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | =head2 is_<type> | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | Returns true if the underlying VCS is <type>. | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | These are mostly used internally to handle special cases. | ||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | =over | ||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | =item is_svn | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | =item is_svk | ||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | =item is_cvs | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | =item is_darcs | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | =back | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | =cut | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | 1 | foreach my $type (qw(svn svk cvs darcs)) { | |||||||||||||||||||
| 138 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 139 | 4 | ▶ | *{__PACKAGE__ . "::is_$type"} = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||
| 140 | 0 | my $self = shift; | |||||||||||||||||||
| 141 | 0 | return($self->{vcs} eq $type); | |||||||||||||||||||
| 142 | 4 | }; # end sub | |||||||||||||||||||
| 143 | } | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | =head2 get_log | ||||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | $vc->get_log($target); | ||||||||||||||||||||
| 148 | |||||||||||||||||||||
| 149 | =cut | ||||||||||||||||||||
| 150 | |||||||||||||||||||||
| 151 | 0 | ▶ | sub get_log { | ||||||||||||||||||
|
Subroutine
get_log: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 152 | 0 | my $self = shift; | |||||||||||||||||||
| 153 | 0 | my ($target, %opts) = @_; | |||||||||||||||||||
| 154 | |||||||||||||||||||||
| 155 | 0 | ▶ | my @args = $opts{args} ? @{$opts{args}} : (); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 156 | |||||||||||||||||||||
| 157 | 0 | my ($in, $out, $err); | |||||||||||||||||||
| 158 | 0 | ▶ | IPC::Run::run( | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 159 | [$self->vcs_cmd, 'log', ($self->is_svk ? '-x' : ()), @args, $target], | ||||||||||||||||||||
| 160 | \$in, \$out, \$err | ||||||||||||||||||||
| 161 | ); | ||||||||||||||||||||
| 162 | 0 | ▶ | $err and warn "eek! $err "; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 163 | # warn "see: $out"; | ||||||||||||||||||||
| 164 | # XXX error checking? | ||||||||||||||||||||
| 165 | # XXX wantarray? | ||||||||||||||||||||
| 166 | 0 | return(split(/\n/, $out)); | |||||||||||||||||||
| 167 | } # end subroutine get_log definition | ||||||||||||||||||||
| 168 | ######################################################################## | ||||||||||||||||||||
| 169 | |||||||||||||||||||||
| 170 | =head2 get_log_times | ||||||||||||||||||||
| 171 | |||||||||||||||||||||
| 172 | $vc->get_log_times($target); | ||||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | =cut | ||||||||||||||||||||
| 175 | |||||||||||||||||||||
| 176 | 0 | ▶ | sub get_log_times { | ||||||||||||||||||
|
Subroutine
get_log_times: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 177 | 0 | my $self = shift; | |||||||||||||||||||
| 178 | # XXX maybe want this regex for other things? - get_summary_lines ? | ||||||||||||||||||||
| 179 | 0 | my @l = grep(/^r\d+:?.*\|\s/, | |||||||||||||||||||
| 180 | $self->get_log(@_) | ||||||||||||||||||||
| 181 | ); | ||||||||||||||||||||
| 182 | 0 | my @times; | |||||||||||||||||||
| 183 | 0 | foreach my $s (@l) { # XXX also, usable in other areas | |||||||||||||||||||
| 184 | 0 | ▶ | if($self->is_svk) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 185 | 0 | $s =~ s/^(r\d+):\s*/$1 | /; | |||||||||||||||||||
| 186 | } | ||||||||||||||||||||
| 187 | 0 | my ($r, $u, $d, $else) = split(/\s\|\s/, $s, 4); | |||||||||||||||||||
| 188 | 0 | ▶ | $else ||= ''; | ||||||||||||||||||
|
Condition0%0/2
$else ||= ""
MC/DC0%0/1
$else ||= ""
$else
Truth table0%0/2
A
A= $else
| |||||||||||||||||||||
| 189 | #warn "split into ", join("#", $r, $u, $d, $else), "\n"; | ||||||||||||||||||||
| 190 | 0 | push(@times, $d); | |||||||||||||||||||
| 191 | } | ||||||||||||||||||||
| 192 | 0 | return(@times); | |||||||||||||||||||
| 193 | } # end subroutine get_log_times definition | ||||||||||||||||||||
| 194 | ######################################################################## | ||||||||||||||||||||
| 195 | |||||||||||||||||||||
| 196 | =head2 get_info | ||||||||||||||||||||
| 197 | |||||||||||||||||||||
| 198 | my %vals = $vc->get_info; | ||||||||||||||||||||
| 199 | |||||||||||||||||||||
| 200 | =cut | ||||||||||||||||||||
| 201 | |||||||||||||||||||||
| 202 | 0 | ▶ | sub get_info { | ||||||||||||||||||
|
Subroutine
get_info: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 203 | 0 | my $self = shift; | |||||||||||||||||||
| 204 | |||||||||||||||||||||
| 205 | 0 | my %ans = $self->_do_run('info', $self->dir); | |||||||||||||||||||
| 206 | 0 | my %info; | |||||||||||||||||||
| 207 | 0 | foreach my $line (split(/\n/, $ans{out})) { | |||||||||||||||||||
| 208 | 0 | my ($key, $val) = split(/ *: */, $line, 2); | |||||||||||||||||||
| 209 | 0 | $key = lc($key); | |||||||||||||||||||
| 210 | 0 | $key =~ s/ +/_/g; | |||||||||||||||||||
| 211 | 0 | $key =~ s/__+/_/g; | |||||||||||||||||||
| 212 | 0 | $key =~ s/[^a-z0-9_]+//g; | |||||||||||||||||||
| 213 | 0 | ▶ | exists($info{$key}) and die "oops $key twice in $ans{out}"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 214 | 0 | $info{$key} = $val; | |||||||||||||||||||
| 215 | } | ||||||||||||||||||||
| 216 | 0 | return(%info); | |||||||||||||||||||
| 217 | } # end subroutine get_info definition | ||||||||||||||||||||
| 218 | ######################################################################## | ||||||||||||||||||||
| 219 | |||||||||||||||||||||
| 220 | =head2 taglist | ||||||||||||||||||||
| 221 | |||||||||||||||||||||
| 222 | my @tags = $vc->taglist; | ||||||||||||||||||||
| 223 | |||||||||||||||||||||
| 224 | =cut | ||||||||||||||||||||
| 225 | |||||||||||||||||||||
| 226 | 0 | ▶ | sub taglist { | ||||||||||||||||||
|
Subroutine
taglist: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 227 | 0 | my $self = shift; | |||||||||||||||||||
| 228 | 0 | return(map({s#/$##;$_} $self->list($self->tag_dir))); | |||||||||||||||||||
| 229 | } # end subroutine taglist definition | ||||||||||||||||||||
| 230 | ######################################################################## | ||||||||||||||||||||
| 231 | |||||||||||||||||||||
| 232 | =head2 tag_dir | ||||||||||||||||||||
| 233 | |||||||||||||||||||||
| 234 | my $dir = $vc->tag_dir; | ||||||||||||||||||||
| 235 | |||||||||||||||||||||
| 236 | =cut | ||||||||||||||||||||
| 237 | |||||||||||||||||||||
| 238 | 0 | ▶ | sub tag_dir { | ||||||||||||||||||
|
Subroutine
tag_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 239 | 0 | my $self = shift; | |||||||||||||||||||
| 240 | |||||||||||||||||||||
| 241 | 0 | my %info = $self->get_info; | |||||||||||||||||||
| 242 | 0 | my $url = $info{url}; | |||||||||||||||||||
| 243 | 0 | my $tagdir = $url; | |||||||||||||||||||
| 244 | 0 | ▶ | $tagdir =~ s/trunk$/tags\// or die "eek, $url not trunk?"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 245 | 0 | return($tagdir); | |||||||||||||||||||
| 246 | } # end subroutine tag_dir definition | ||||||||||||||||||||
| 247 | ######################################################################## | ||||||||||||||||||||
| 248 | |||||||||||||||||||||
| 249 | =head2 taggit | ||||||||||||||||||||
| 250 | |||||||||||||||||||||
| 251 | (Currently) assumes a proj/trunk, proj/tags layout and that we're | ||||||||||||||||||||
| 252 | looking at trunk. I guess you could tag a branch, but, uh... | ||||||||||||||||||||
| 253 | |||||||||||||||||||||
| 254 | $vc->taggit($tagname, message => $message); | ||||||||||||||||||||
| 255 | |||||||||||||||||||||
| 256 | Big issue: There is no syntax of copy that prevents writing into an | ||||||||||||||||||||
| 257 | existing tag directory. The subversion developers seem to think this | ||||||||||||||||||||
| 258 | should be handled via pre-commit hooks (see | ||||||||||||||||||||
| 259 | http://svn.haxx.se/users/archive-2005-11/0056.shtml for details.) | ||||||||||||||||||||
| 260 | |||||||||||||||||||||
| 261 | =cut | ||||||||||||||||||||
| 262 | |||||||||||||||||||||
| 263 | 0 | ▶ | sub taggit { | ||||||||||||||||||
|
Subroutine
taggit: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||
| 264 | 0 | my $self = shift; | |||||||||||||||||||
| 265 | 0 | my ($name, %opts) = @_; | |||||||||||||||||||
| 266 | 0 | ▶ | ($name =~ m#/#) and die "improper tagname $name"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 267 | |||||||||||||||||||||
| 268 | 0 | my %info = $self->get_info; | |||||||||||||||||||
| 269 | 0 | my $url = $info{url}; | |||||||||||||||||||
| 270 | 0 | ▶ | die "I can't taggit() on type ", $self->vcs_command, " yet" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 271 | unless($url); | ||||||||||||||||||||
| 272 | |||||||||||||||||||||
| 273 | # TODO svk support | ||||||||||||||||||||
| 274 | # TODO config-file and/or propval layout? | ||||||||||||||||||||
| 275 | |||||||||||||||||||||
| 276 | 0 | my $trunk = $url; # could also be a branch I guess | |||||||||||||||||||
| 277 | 0 | my $tagdir = $url; | |||||||||||||||||||
| 278 | 0 | ▶ | $tagdir =~ s{(?:trunk|branches/[^/]+)/?$}{tags/} or | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 279 | croak("eek, $url not trunk|branches?"); | ||||||||||||||||||||
| 280 | 0 | my $tagdest = $tagdir . $name; | |||||||||||||||||||
| 281 | |||||||||||||||||||||
| 282 | # Bah! svn doesn't prevent copying into an existing tag directory (at | ||||||||||||||||||||
| 283 | # least not in any form that I can see.) | ||||||||||||||||||||
| 284 | #warn $self->list($tagdir); | ||||||||||||||||||||
| 285 | 0 | my @has = grep(/^\Q$name\E\/$/, $self->list($tagdir)); | |||||||||||||||||||
| 286 | 0 | ▶ | @has and die "tag '$name' already exists in $tagdir"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 287 | |||||||||||||||||||||
| 288 | 0 | my $message = $opts{message}; | |||||||||||||||||||
| 289 | 0 | ▶ | $message = "tagging $name" unless(defined($message)); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 290 | |||||||||||||||||||||
| 291 | 0 | $self->_do_run('copy', $trunk, $tagdest, '--message', $message); | |||||||||||||||||||
| 292 | } # end subroutine taggit definition | ||||||||||||||||||||
| 293 | ######################################################################## | ||||||||||||||||||||
| 294 | |||||||||||||||||||||
| 295 | =head1 normal methods | ||||||||||||||||||||
| 296 | |||||||||||||||||||||
| 297 | Just abstraction for standard commands. | ||||||||||||||||||||
| 298 | |||||||||||||||||||||
| 299 | |||||||||||||||||||||
| 300 | =head2 add | ||||||||||||||||||||
| 301 | |||||||||||||||||||||
| 302 | $vc->add(@files); | ||||||||||||||||||||
| 303 | |||||||||||||||||||||
| 304 | =cut | ||||||||||||||||||||
| 305 | |||||||||||||||||||||
| 306 | 0 | ▶ | sub add { | ||||||||||||||||||
|
Subroutine
add: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 307 | 0 | my $self = shift; | |||||||||||||||||||
| 308 | 0 | my @files = @_; | |||||||||||||||||||
| 309 | 0 | my %r = $self->_do_run('add', @files); | |||||||||||||||||||
| 310 | 0 | ▶ | $r{err} and warn "eek! $r{err} ($r{status})"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 311 | 0 | ▶ | $r{ret} or warn "eek"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 312 | # XXX or should parse output and return number of added files? | ||||||||||||||||||||
| 313 | 0 | return($r{ret}); | |||||||||||||||||||
| 314 | } # end subroutine add definition | ||||||||||||||||||||
| 315 | ######################################################################## | ||||||||||||||||||||
| 316 | |||||||||||||||||||||
| 317 | =head2 remove | ||||||||||||||||||||
| 318 | |||||||||||||||||||||
| 319 | $vc->remove(@files); | ||||||||||||||||||||
| 320 | |||||||||||||||||||||
| 321 | =cut | ||||||||||||||||||||
| 322 | |||||||||||||||||||||
| 323 | 0 | ▶ | sub remove { | ||||||||||||||||||
|
Subroutine
remove: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 324 | 0 | my $self = shift; | |||||||||||||||||||
| 325 | 0 | my @files = @_; | |||||||||||||||||||
| 326 | 0 | my %r = $self->_do_run('remove', @files); | |||||||||||||||||||
| 327 | 0 | ▶ | $r{err} and warn "eek! $r{err} ($r{status})"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 328 | 0 | ▶ | $r{ret} or warn "eek"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 329 | # XXX or should parse output and return number of added files? | ||||||||||||||||||||
| 330 | 0 | return($r{ret}); | |||||||||||||||||||
| 331 | } # end subroutine remove definition | ||||||||||||||||||||
| 332 | ######################################################################## | ||||||||||||||||||||
| 333 | |||||||||||||||||||||
| 334 | =head2 commit | ||||||||||||||||||||
| 335 | |||||||||||||||||||||
| 336 | $vc->commit($message, @files); | ||||||||||||||||||||
| 337 | |||||||||||||||||||||
| 338 | =cut | ||||||||||||||||||||
| 339 | |||||||||||||||||||||
| 340 | 0 | ▶ | sub commit { | ||||||||||||||||||
|
Subroutine
commit: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 341 | 0 | my $self = shift; | |||||||||||||||||||
| 342 | 0 | my ($message, @files) = @_; | |||||||||||||||||||
| 343 | 0 | ▶ | @files or die; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 344 | 0 | my %r = $self->_do_run('commit', @files, '-m', $message); | |||||||||||||||||||
| 345 | 0 | ▶ | $r{err} and warn "eek! $r{err} ($r{status})"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 346 | 0 | ▶ | $r{ret} or warn "eek"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 347 | # XXX or should return what? | ||||||||||||||||||||
| 348 | 0 | return($r{ret}); | |||||||||||||||||||
| 349 | } # end subroutine commit definition | ||||||||||||||||||||
| 350 | ######################################################################## | ||||||||||||||||||||
| 351 | |||||||||||||||||||||
| 352 | =head2 update | ||||||||||||||||||||
| 353 | |||||||||||||||||||||
| 354 | $vc->update; | ||||||||||||||||||||
| 355 | |||||||||||||||||||||
| 356 | =cut | ||||||||||||||||||||
| 357 | |||||||||||||||||||||
| 358 | 0 | ▶ | sub update { | ||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 359 | 0 | my $self = shift; | |||||||||||||||||||
| 360 | |||||||||||||||||||||
| 361 | 0 | my %r = $self->_do_run('update'); | |||||||||||||||||||
| 362 | } # end subroutine update definition | ||||||||||||||||||||
| 363 | ######################################################################## | ||||||||||||||||||||
| 364 | |||||||||||||||||||||
| 365 | =head2 list | ||||||||||||||||||||
| 366 | |||||||||||||||||||||
| 367 | my @list = $vc->list($path); | ||||||||||||||||||||
| 368 | |||||||||||||||||||||
| 369 | =cut | ||||||||||||||||||||
| 370 | |||||||||||||||||||||
| 371 | 0 | ▶ | sub list { | ||||||||||||||||||
|
Subroutine
list: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 372 | 0 | my $self = shift; | |||||||||||||||||||
| 373 | 0 | my ($path) = @_; | |||||||||||||||||||
| 374 | 0 | ▶ | $path or die; # XXX ? | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 375 | 0 | my %r = $self->_do_run('list', $path); | |||||||||||||||||||
| 376 | #$r{err} and warn "eek! $r{err} ($r{status})"; | ||||||||||||||||||||
| 377 | #$r{ret} or warn "eek"; | ||||||||||||||||||||
| 378 | #$r{out} or warn "that's a problem"; | ||||||||||||||||||||
| 379 | 0 | return(split(/\n/, $r{out})); | |||||||||||||||||||
| 380 | } # end subroutine list definition | ||||||||||||||||||||
| 381 | ######################################################################## | ||||||||||||||||||||
| 382 | |||||||||||||||||||||
| 383 | =head2 revert | ||||||||||||||||||||
| 384 | |||||||||||||||||||||
| 385 | $vc->revert(@files); | ||||||||||||||||||||
| 386 | |||||||||||||||||||||
| 387 | =cut | ||||||||||||||||||||
| 388 | |||||||||||||||||||||
| 389 | 0 | ▶ | sub revert { | ||||||||||||||||||
|
Subroutine
revert: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 390 | 0 | my $self = shift; | |||||||||||||||||||
| 391 | 0 | my (@files) = @_; | |||||||||||||||||||
| 392 | 0 | ▶ | @files or die "need files"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 393 | 0 | my %r = $self->_do_run('revert', @files); | |||||||||||||||||||
| 394 | # TODO read the qr/Reverted '([^']+)'/ lines? | ||||||||||||||||||||
| 395 | 0 | warn $r{out}; | |||||||||||||||||||
| 396 | } # end subroutine revert definition | ||||||||||||||||||||
| 397 | ######################################################################## | ||||||||||||||||||||
| 398 | |||||||||||||||||||||
| 399 | =head2 status | ||||||||||||||||||||
| 400 | |||||||||||||||||||||
| 401 | Returns a hash of files and their status codes. | ||||||||||||||||||||
| 402 | |||||||||||||||||||||
| 403 | %status = $vc->status(@files); | ||||||||||||||||||||
| 404 | |||||||||||||||||||||
| 405 | =cut | ||||||||||||||||||||
| 406 | |||||||||||||||||||||
| 407 | 0 | ▶ | sub status { | ||||||||||||||||||
|
Subroutine
status: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 408 | 0 | my $self = shift; | |||||||||||||||||||
| 409 | 0 | my @files = @_; | |||||||||||||||||||
| 410 | 0 | my %r = $self->_do_run('status', @files); | |||||||||||||||||||
| 411 | 0 | ▶ | $r{err} and warn "eek! $r{err} ($r{status})"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 412 | 0 | ▶ | $r{ret} or warn "eek"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 413 | 0 | ▶ | $r{out} or return(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 414 | 0 | return(map({reverse(split(/\s+/, $_, 2))} | |||||||||||||||||||
| 415 | split(/\n/, $r{out}) | ||||||||||||||||||||
| 416 | 0 | )); | |||||||||||||||||||
| 417 | } # end subroutine status definition | ||||||||||||||||||||
| 418 | ######################################################################## | ||||||||||||||||||||
| 419 | |||||||||||||||||||||
| 420 | =head2 propget | ||||||||||||||||||||
| 421 | |||||||||||||||||||||
| 422 | $vc->propget($propname, $url||$file); | ||||||||||||||||||||
| 423 | |||||||||||||||||||||
| 424 | =cut | ||||||||||||||||||||
| 425 | |||||||||||||||||||||
| 426 | 0 | ▶ | sub propget { | ||||||||||||||||||
|
Subroutine
propget: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 427 | 0 | my $self = shift; | |||||||||||||||||||
| 428 | 0 | my ($prop, $file) = @_; | |||||||||||||||||||
| 429 | |||||||||||||||||||||
| 430 | 0 | my %r = $self->_do_run('propget', $prop, $file); | |||||||||||||||||||
| 431 | 0 | ▶ | defined(my $string = $r{out}) or croak("nothing there"); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 432 | |||||||||||||||||||||
| 433 | 0 | die "this is unfinished"; | |||||||||||||||||||
| 434 | |||||||||||||||||||||
| 435 | |||||||||||||||||||||
| 436 | } # end subroutine propget definition | ||||||||||||||||||||
| 437 | ######################################################################## | ||||||||||||||||||||
| 438 | |||||||||||||||||||||
| 439 | =head2 propset | ||||||||||||||||||||
| 440 | |||||||||||||||||||||
| 441 | Takes an array reference or string for propvals. | ||||||||||||||||||||
| 442 | |||||||||||||||||||||
| 443 | $vc->propset($propname, \@vals, @files); | ||||||||||||||||||||
| 444 | |||||||||||||||||||||
| 445 | $vc->propset($propname, $valstring, @files); | ||||||||||||||||||||
| 446 | |||||||||||||||||||||
| 447 | =cut | ||||||||||||||||||||
| 448 | |||||||||||||||||||||
| 449 | 0 | ▶ | sub propset { | ||||||||||||||||||
|
Subroutine
propset: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 450 | 0 | my $self = shift; | |||||||||||||||||||
| 451 | 0 | my ($prop, $val, @files) = @_; | |||||||||||||||||||
| 452 | 0 | ▶ | if(ref($val)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 453 | 0 | ▶ | UNIVERSAL::isa($val, 'ARRAY') or die; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 454 | 0 | $val = join("\n", @$val); | |||||||||||||||||||
| 455 | } | ||||||||||||||||||||
| 456 | 0 | my %r = $self->_do_run('propset', $prop, $val, @files); | |||||||||||||||||||
| 457 | 0 | ▶ | $r{err} and warn "eek! $r{err} ($r{status})"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 458 | 0 | ▶ | $r{ret} or warn "eek"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 459 | 0 | return($r{ret}); | |||||||||||||||||||
| 460 | } # end subroutine propset definition | ||||||||||||||||||||
| 461 | ######################################################################## | ||||||||||||||||||||
| 462 | |||||||||||||||||||||
| 463 | =head1 AUTHOR | ||||||||||||||||||||
| 464 | |||||||||||||||||||||
| 465 | Eric Wilhelm @ <ewilhelm at cpan dot org> | ||||||||||||||||||||
| 466 | |||||||||||||||||||||
| 467 | http://scratchcomputing.com/ | ||||||||||||||||||||
| 468 | |||||||||||||||||||||
| 469 | =head1 BUGS | ||||||||||||||||||||
| 470 | |||||||||||||||||||||
| 471 | If you found this module on CPAN, please report any bugs or feature | ||||||||||||||||||||
| 472 | requests through the web interface at L<http://rt.cpan.org>. I will be | ||||||||||||||||||||
| 473 | notified, and then you'll automatically be notified of progress on your | ||||||||||||||||||||
| 474 | bug as I make changes. | ||||||||||||||||||||
| 475 | |||||||||||||||||||||
| 476 | If you pulled this development version from my /svn/, please contact me | ||||||||||||||||||||
| 477 | directly. | ||||||||||||||||||||
| 478 | |||||||||||||||||||||
| 479 | =head1 COPYRIGHT | ||||||||||||||||||||
| 480 | |||||||||||||||||||||
| 481 | Copyright (C) 2004-2009 Eric L. Wilhelm, All Rights Reserved. | ||||||||||||||||||||
| 482 | |||||||||||||||||||||
| 483 | =head1 NO WARRANTY | ||||||||||||||||||||
| 484 | |||||||||||||||||||||
| 485 | Absolutely, positively NO WARRANTY, neither express or implied, is | ||||||||||||||||||||
| 486 | offered with this software. You use this software at your own risk. In | ||||||||||||||||||||
| 487 | case of loss, no person or entity owes you anything whatsoever. You | ||||||||||||||||||||
| 488 | have been warned. | ||||||||||||||||||||
| 489 | |||||||||||||||||||||
| 490 | =head1 LICENSE | ||||||||||||||||||||
| 491 | |||||||||||||||||||||
| 492 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||
| 493 | under the same terms as Perl itself. | ||||||||||||||||||||
| 494 | |||||||||||||||||||||
| 495 | =cut | ||||||||||||||||||||
| 496 | |||||||||||||||||||||
| 497 | # vi:sw=2:ts=2:et:sta | ||||||||||||||||||||
| 498 | 1 | 1; | |||||||||||||||||||