| 1 | # Folder.pm - access to PVCS Folders for the Perl PVCS module | ||
| 2 | # | ||
| 3 | # Copyright (c) 1998 Bill Middleton | ||
| 4 | # | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | VCS::PVCS::Folder - Folder class for for VCS::PVCS. | ||
| 9 | |||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | use VCS::PVCS::Project; | ||
| 14 | |||
| 15 | $project = new VCS::PVCS::Project("ProjectName"); | ||
| 16 | |||
| 17 | # return ref to array of all folders in the project with SCRIPTS in the name | ||
| 18 | |||
| 19 | $folds = $project->openFolders("SCRIPTS"); | ||
| 20 | foreach $folder (@$folds){ | ||
| 21 | $folder->checkout; # Checkout all files in the folder to the WD | ||
| 22 | } | ||
| 23 | |||
| 24 | =head1 DESCRIPTION | ||
| 25 | |||
| 26 | This class implements a set of methods for operating on the | ||
| 27 | directories, archive files, and workfiles which correspond to | ||
| 28 | PVCS folders. It should not ordinarily be loaded directly, but | ||
| 29 | rather, is an ISA to the VCS::PVCS::Project class, as shown | ||
| 30 | above. | ||
| 31 | |||
| 32 | =head1 METHODS | ||
| 33 | |||
| 34 | =over 5 | ||
| 35 | |||
| 36 | |||
| 37 | =item B<openFolders> | ||
| 38 | |||
| 39 | $folds = $project->openFolders("FOO"); # folders with FOO in the name | ||
| 40 | @folds = $project->openFolders(".*"); # ALL folders in the project | ||
| 41 | $folds = $project->openFolders("New Folder"); # create the folder | ||
| 42 | |||
| 43 | Return a ref to array (or an array) of all folders in the project with | ||
| 44 | FOO in the name. If no match is found, the folder is created. | ||
| 45 | The objects in this array are blessed into the | ||
| 46 | VCS::PVCS::Folder class. openFolders() accepts partial name matches | ||
| 47 | in the single argument. (Names are matched with grep(//)) | ||
| 48 | |||
| 49 | =item B<members> | ||
| 50 | |||
| 51 | @members = $folder->members("regexp"); | ||
| 52 | |||
| 53 | Return an array (or ref to array) of blessed Archive objects which | ||
| 54 | reside within the folder, and match the regexp. If no regexp is passed | ||
| 55 | in, then return all of the archives in the project. These objects | ||
| 56 | can then call the methods in the VCS::PVCS::Archive class. | ||
| 57 | |||
| 58 | =item B<newArchive > | ||
| 59 | |||
| 60 | $Folder->newArchive($file,$archivedir); | ||
| 61 | |||
| 62 | Create a new archive and place a copy into the folder. | ||
| 63 | |||
| 64 | =item B<getWD> | ||
| 65 | |||
| 66 | $WorkingDir = $folder->getWD; | ||
| 67 | |||
| 68 | Return the working directory for the folder. | ||
| 69 | |||
| 70 | =item B<getAttributes> | ||
| 71 | |||
| 72 | $Folder->getAttributes([vcs opts])'; | ||
| 73 | |||
| 74 | Populate the attributes object for each archive object member of the | ||
| 75 | folder. | ||
| 76 | |||
| 77 | =item B<get> | ||
| 78 | |||
| 79 | $Folder->get([get opts]); | ||
| 80 | |||
| 81 | Checkout all of the archive members in the folder | ||
| 82 | to the the folders' working directory. Use opts to change | ||
| 83 | default actions. | ||
| 84 | |||
| 85 | =item B<checkout> | ||
| 86 | |||
| 87 | Convenience routine calls $folder->get() | ||
| 88 | |||
| 89 | =item B<co> | ||
| 90 | |||
| 91 | Convenience routine calls $folder->get() | ||
| 92 | |||
| 93 | =item B<put> | ||
| 94 | |||
| 95 | $Folder->put([put opts]); | ||
| 96 | |||
| 97 | Checkin all of the archive members of the folder. Use opts to | ||
| 98 | change default actions. | ||
| 99 | |||
| 100 | =item B<checkin> | ||
| 101 | |||
| 102 | Convenience routine calls put() | ||
| 103 | |||
| 104 | =item B<ci> | ||
| 105 | |||
| 106 | Convenience routine calls put() | ||
| 107 | |||
| 108 | =item B<vlog> | ||
| 109 | |||
| 110 | $Folder->vlog([vlog opts]); | ||
| 111 | |||
| 112 | Takes a full vlog on all of the archive members in the folder. | ||
| 113 | Use opts to change default actions. Result in $PVCSOUTPUT. | ||
| 114 | |||
| 115 | =item B<log> | ||
| 116 | |||
| 117 | Convenience routine calls vlog() | ||
| 118 | |||
| 119 | =item B<history> | ||
| 120 | |||
| 121 | Convenience routine calls vlog() | ||
| 122 | |||
| 123 | =item B<lock> | ||
| 124 | |||
| 125 | $Folder->lock($label|$version,[vcs opts]); | ||
| 126 | |||
| 127 | Locks the named revision (or rev spec'd by label) for all | ||
| 128 | archive members in the folder. Use opts to change default action. | ||
| 129 | |||
| 130 | =item B<unlock> | ||
| 131 | |||
| 132 | $Folder->unlock($label|$version,[vcs opts]); | ||
| 133 | |||
| 134 | unlocks the named revision (or rev spec'd by label) for all | ||
| 135 | archive members of the folder. Use opts to change default action. | ||
| 136 | |||
| 137 | =item B<addVersionLabel> | ||
| 138 | |||
| 139 | $Folder->addVersionLabel($label,[vcs opts]); | ||
| 140 | |||
| 141 | Create a new sticky version label for the all of the archive | ||
| 142 | members of the folder (optionally with :<rev>). Use opts | ||
| 143 | for additonal params. | ||
| 144 | |||
| 145 | =item B<deleteVersionLabel> | ||
| 146 | |||
| 147 | $Folder->deleteVersionLabel($label,[vcs opts]); | ||
| 148 | |||
| 149 | Delete a version label from all of the archive members of the folder. | ||
| 150 | |||
| 151 | =item B<replaceVersionLabel> | ||
| 152 | |||
| 153 | $Folder->replaceVersionLabel($newlabel,$oldlabel,[vcs opts]); | ||
| 154 | |||
| 155 | Rename a version label in all of the archive members of the folder. | ||
| 156 | |||
| 157 | =item B<addFloatingVersionLabel> | ||
| 158 | |||
| 159 | $Folder->addFloatingVersionLabel($label,[vcs opts]); | ||
| 160 | |||
| 161 | Create a floating version label for all of the archive members | ||
| 162 | of the folder. | ||
| 163 | |||
| 164 | =item B<transformVersionLabel> | ||
| 165 | |||
| 166 | $Folder->transformVersionLabel($label,[vcs opts])'; | ||
| 167 | |||
| 168 | Transform a specified version label to a floating version label | ||
| 169 | for all of the archive members of the folder. | ||
| 170 | |||
| 171 | =item B<deletePromoGroup> | ||
| 172 | |||
| 173 | $Folder->deletePromoGroup($group,[vcs opts]); | ||
| 174 | |||
| 175 | Delete the promotion group from the archive for all archive | ||
| 176 | members in the folder. | ||
| 177 | |||
| 178 | =item B<addPromoGroup> | ||
| 179 | |||
| 180 | $Folder->deletePromoGroup($group:$rev,[vcs opts])'; | ||
| 181 | |||
| 182 | Add the archive, or promote it to, the named promotion group. | ||
| 183 | For all of the archive members in the folder. | ||
| 184 | |||
| 185 | Create a new archive | ||
| 186 | |||
| 187 | =item B<vcs> | ||
| 188 | |||
| 189 | $Folder->vcs([opts][files]); | ||
| 190 | |||
| 191 | Run vcs in the folder's CWD, with opts. | ||
| 192 | |||
| 193 | =item B<getAttributes> | ||
| 194 | |||
| 195 | $Folder->getAttributes(@_); | ||
| 196 | |||
| 197 | Populates and returns the archive object associated with the archive | ||
| 198 | for all archives in the folder. | ||
| 199 | |||
| 200 | This object is blessed into the VCS::PVCS::Attributes class. | ||
| 201 | |||
| 202 | =back | ||
| 203 | |||
| 204 | =head1 COPYRIGHT | ||
| 205 | |||
| 206 | The PVCS module is Copyright (c) 1998 Bill Middleton. | ||
| 207 | All rights reserved. | ||
| 208 | |||
| 209 | You may distribute under the terms of either the GNU General Public | ||
| 210 | License or the Artistic License, as specified in the Perl README file. | ||
| 211 | |||
| 212 | =head1 AUTHOR | ||
| 213 | |||
| 214 | Bill Middleton, wjm@metronet.com | ||
| 215 | |||
| 216 | =head1 SUPPORT / WARRANTY | ||
| 217 | |||
| 218 | The VCS::PVCS modules are free software. | ||
| 219 | |||
| 220 | B<THEY COME WITHOUT WARRANTY OF ANY KIND.> | ||
| 221 | |||
| 222 | Commercial support agreements for Perl can be arranged via | ||
| 223 | The Perl Clinic. See http://www.perl.co.uk/tpc for more details. | ||
| 224 | |||
| 225 | =head1 SEE ALSO | ||
| 226 | |||
| 227 | VCS::PVCS::Project | ||
| 228 | |||
| 229 | =cut | ||
| 230 | |||
| 231 | package VCS::PVCS::Folder; | ||
| 232 | use strict; | ||
| 233 | no strict qw(refs); | ||
| 234 | use vars qw($VERSION @EXPORT @EXPORT_OK @ISA); | ||
| 235 | use Carp; | ||
| 236 | use Cwd; | ||
| 237 | use VCS::PVCS; | ||
| 238 | require VCS::PVCS::Archive; | ||
| 239 | @ISA = qw(VCS::PVCS::Archive ); | ||
| 240 | $VERSION = "0.01"; | ||
| 241 | |||
| 242 | |||
| 243 | ################################################ | ||
| 244 | ## Constructor | ||
| 245 | ## | ||
| 246 | |||
| 247 | sub openFolders{ | ||
| 248 | my $type = shift; | ||
| 249 | my $class = ref($type); | ||
| 250 | ($class =~ /^VCS::PVCS::Project$/) or | ||
| 251 | croak "Must pass a Project object to new\n"; | ||
| 252 | (@_ >= 1) or croak "usage: new $class [Foldername]"; | ||
| 253 | my ($ret,$folder); | ||
| 254 | my $foldernamematch = shift; | ||
| 255 | my($args) = shift; | ||
| 256 | (defined($args)) or ($args = {}); | ||
| 257 | my($ref) = $type->{'folders'}; | ||
| 258 | my($self) = []; | ||
| 259 | my (@keys) = keys(%{$ref}); | ||
| 260 | my (@folders) = grep(/$foldernamematch/,@keys); | ||
| 261 | if(@folders){ | ||
| 262 | foreach $folder (@folders){ | ||
| 263 | $ret = VCS::PVCS::Folder::_parseFolder($type,$ref->{$folder},$folder) | ||
| 264 | or return undef; | ||
| 265 | push(@{$self},$ret); | ||
| 266 | } | ||
| 267 | } | ||
| 268 | else{ | ||
| 269 | warn "WARNING: Folder $foldernamematch does not exist, attempting to create" | ||
| 270 | if $PVCSDEBUG; | ||
| 271 | $ret = VCS::PVCS::Folder::_createFolder($type,$foldernamematch,$args) | ||
| 272 | or return undef; | ||
| 273 | push(@{$self},$ret); | ||
| 274 | } | ||
| 275 | (wantarray)? @$self : $self; | ||
| 276 | |||
| 277 | } | ||
| 278 | |||
| 279 | |||
| 280 | |||
| 281 | sub _parseFolder{ | ||
| 282 | my($self) = shift; | ||
| 283 | my $class = ref($self); | ||
| 284 | my($fref) = shift; | ||
| 285 | my($newfolder) = shift; | ||
| 286 | my($folder,$retval); | ||
| 287 | my($nextline,$tmp,$tmp2); | ||
| 288 | my($archdir,$archfile,$workdir,$workfile); | ||
| 289 | |||
| 290 | ($class =~ /^VCS::PVCS::Project$/) or | ||
| 291 | croak "Must pass a Project object to openFolder\n"; | ||
| 292 | |||
| 293 | $folder = $PVCSPROJ; | ||
| 294 | $folder .="/".$self->{'currentProject'}->{'DIR'}; | ||
| 295 | $folder .="/".$fref->{'DIR'}; | ||
| 296 | (open(FOLDER,"$folder/pvcsfold.pub")) | ||
| 297 | or (croak "Cant open pvcsfold.pub for $newfolder\n"); | ||
| 298 | |||
| 299 | while(<FOLDER>){ | ||
| 300 | if(/^\[DOCUMENT=(.*)\]/){ | ||
| 301 | $tmp2 = $1; | ||
| 302 | ($archdir,$archfile,$workdir,$workfile) = split(/;/,$1); | ||
| 303 | my $tmp = "$workdir/$workfile"; | ||
| 304 | if(! defined($self->{'documents'}->{"$archdir\\$archfile"})){ | ||
| 305 | warn "WARNING: No document in project\'s pvcsfold.pub for project $self->{'NAME'}: $archdir\\$archfile in $folder/pvcsfold.pub\n" if($PVCSDEBUG); | ||
| 306 | $self->{'documents'}->{"$archdir\\$archfile"} = {}; | ||
| 307 | bless($self->{'documents'}->{"$archdir\\$archfile"},"VCS::PVCS::Archive"); | ||
| 308 | $self->{'documents'}->{"$archdir\\$archfile"}->{'arpath'} = "$archdir/$archfile"; | ||
| 309 | $self->{'documents'}->{"$archdir\\$archfile"}->{'workfiles'}->{'MASTER'} = $tmp; | ||
| 310 | } | ||
| 311 | if($tmp ne $self->{'documents'}->{"$archdir\\$archfile"}->{'workfiles'}->{'MASTER'}) | ||
| 312 | { | ||
| 313 | warn "WARNING: Workfile $tmp differs from Master Workfile ".$self->{'documents'}->{"$archdir\\$archfile"}->{'workfiles'}->{'MASTER'}."\n" if $PVCSDEBUG; | ||
| 314 | $self->{'documents'}->{"$archdir\\$archfile"}-> | ||
| 315 | {'workfiles'}->{$self->{'NAME'}} = $tmp; | ||
| 316 | |||
| 317 | } | ||
| 318 | if($PVCSDEBUG){ # Check for existence of archive if debugging | ||
| 319 | $tmp = "$archdir\\$archfile"; | ||
| 320 | ($^O ne "MSWin32") ? translatePath2Unix(\$tmp) : | ||
| 321 | translatePath2Win(\$tmp); | ||
| 322 | warn "$tmp does not exist!" unless (-e $tmp); | ||
| 323 | } | ||
| 324 | # push the hashref onto the members array | ||
| 325 | # Another circular reference here | ||
| 326 | push(@{$fref->{'members'}}, | ||
| 327 | $self->{'documents'}->{"$archdir\\$archfile"}); | ||
| 328 | |||
| 329 | } | ||
| 330 | } | ||
| 331 | $retval = $fref; | ||
| 332 | $retval->{'PROJECT'} = $self->{'currentProject'}; | ||
| 333 | bless($retval,"VCS::PVCS::Folder"); | ||
| 334 | |||
| 335 | } | ||
| 336 | |||
| 337 | sub _createFolder{ | ||
| 338 | my $type = shift; | ||
| 339 | my $class = ref($type); | ||
| 340 | ($class =~ /^VCS::PVCS::Project$/) or | ||
| 341 | croak "Must pass a Project object to new\n"; | ||
| 342 | (@_ >= 1) or croak "usage: _createFolder Foldername, [{WKDIR => workdir}]"; | ||
| 343 | my($name) = shift; | ||
| 344 | my($args) = shift; | ||
| 345 | my($retval) = {}; | ||
| 346 | |||
| 347 | my($ref,$shortname); | ||
| 348 | my($nomatch) = 1; | ||
| 349 | my($folder); | ||
| 350 | |||
| 351 | # Get a good name for the project config folder | ||
| 352 | ($shortname = $name) =~ s/\s*//g; | ||
| 353 | if(length($shortname) > 8){ | ||
| 354 | $shortname = substr($shortname,0,8); | ||
| 355 | } | ||
| 356 | while($nomatch){ | ||
| 357 | if(-e "$PVCSPROJ/$type->{'DIR'}/$shortname.fld"){ | ||
| 358 | $shortname++; | ||
| 359 | next; | ||
| 360 | } | ||
| 361 | $nomatch=0; | ||
| 362 | } | ||
| 363 | $folder = "$PVCSPROJ/$type->{'DIR'}/$shortname.fld"; | ||
| 364 | |||
| 365 | unless($PVCSSHOWMODE){ | ||
| 366 | croak "cant create $folder for folder $name" unless | ||
| 367 | (mkdir("$folder",0755)); | ||
| 368 | } | ||
| 369 | |||
| 370 | |||
| 371 | if(length($args->{'WKDIR'})){ | ||
| 372 | ($PVCSMULTIPLATFORM) && translatePath2Win(\$args->{'WKDIR'}); | ||
| 373 | $type->{'folders'}->{$name}->{'WKDIR'} = $args->{'WKDIR'}; | ||
| 374 | } | ||
| 375 | else{ | ||
| 376 | $ref->{$name}->{'WKDIR'} = $type->{'WKDIR'}; | ||
| 377 | } | ||
| 378 | $type->{'folders'}->{$name}->{'DIR'} = "$shortname.fld"; | ||
| 379 | |||
| 380 | # Create folder config file | ||
| 381 | unless($PVCSSHOWMODE){ | ||
| 382 | croak "cant open $folder/pvcsfold.pub for $name" unless | ||
| 383 | open(PVCSFOLD,">>$folder/pvcsfold.pub"); | ||
| 384 | print PVCSFOLD "[FORMAT=PVCS_GUI]\nVersion=5.2\n"; | ||
| 385 | close PVCSFOLD; | ||
| 386 | } | ||
| 387 | # Update the project master pvcsfold.pub | ||
| 388 | $folder = "$PVCSPROJ/$type->{'DIR'}"; | ||
| 389 | unless($PVCSSHOWMODE){ | ||
| 390 | croak "cant open $folder/pvcsfold.pub for $name" unless | ||
| 391 | open(PVCSFOLD,">>$folder/pvcsfold.pub"); | ||
| 392 | print PVCSFOLD "\n[FOLDER=$name]\nDIR=$shortname.fld\n"; | ||
| 393 | print PVCSFOLD "WKDIR=".$type->{'folders'}->{$name}->{'WKDIR'}."\n"; | ||
| 394 | close PVCSFOLD; | ||
| 395 | } | ||
| 396 | |||
| 397 | $retval = $type->{'folders'}->{$name}; | ||
| 398 | $retval->{'PROJECT'} = $type->{'currentProject'}; | ||
| 399 | bless($retval,"VCS::PVCS::Folder"); | ||
| 400 | } | ||
| 401 | |||
| 402 | ##################################################################### | ||
| 403 | # newArchive - Create a new archive and add it to the folder | ||
| 404 | ##################################################################### | ||
| 405 | sub newArchive { | ||
| 406 | my $type = shift; | ||
| 407 | my $class = ref($type); | ||
| 408 | my($newarchive,$folder); | ||
| 409 | my($fullapath,$fullwpath,$a,$b,$c,$d); | ||
| 410 | ($class =~ /VCS::PVCS::Folder/) or | ||
| 411 | croak "must pass project object to newArchive\n"; | ||
| 412 | (@_ >= 2) or croak 'usage: $Project->newArchive(workfile, archivedir, | ||
| 413 | [workingdir], [checkincomment], [workfilecomment]'; | ||
| 414 | my($workfile,$archdir,$workingdir,$cicomment,$workcomment) = @_; | ||
| 415 | |||
| 416 | if(! $workingdir){ | ||
| 417 | $workingdir = $type->{'WKDIR'}; | ||
| 418 | (($^O ne "MSWin32") and ($PVCSMULTIPLATFORM)) and | ||
| 419 | translatePath2Unix(\$workingdir); | ||
| 420 | $workingdir = (-d $workingdir) ? $workingdir : "./"; # revert to cwd()! | ||
| 421 | } | ||
| 422 | my($entry,$archive) = | ||
| 423 | VCS::PVCS::Project::newArchive($type->{'PROJECT'},$workfile,$archdir,$workingdir,$cicomment,$workcomment); | ||
| 424 | if($entry and (! $PVCSSHOWMODE)){ | ||
| 425 | $folder = $PVCSPROJ."/".$type->{'PROJECT'}->{'DIR'}."/".$type->{'DIR'}."/pvcsfold.pub"; | ||
| 426 | open(FOLDER,">>$folder") || | ||
| 427 | croak "Cant open $folder for new archive\n"; | ||
| 428 | print FOLDER $entry; | ||
| 429 | close FOLDER ; | ||
| 430 | push(@{$type->{'members'}},$archive); | ||
| 431 | return($entry); | ||
| 432 | } | ||
| 433 | return undef; | ||
| 434 | } | ||
| 435 | |||
| 436 | ################################################################### | ||
| 437 | # Return the members of the folder, names matched against parameter | ||
| 438 | ################################################################### | ||
| 439 | sub members{ | ||
| 440 | @_ >= 1 or croak 'usage: $Folder->members("regexp")'; | ||
| 441 | my($type) = shift; | ||
| 442 | my($class) = ref($type); | ||
| 443 | my($match) = shift; | ||
| 444 | my($retval) = []; | ||
| 445 | my($member); | ||
| 446 | |||
| 447 | if($class eq "VCS::PVCS::Folder"){ | ||
| 448 | if($match){ | ||
| 449 | foreach $member (@{$type->{'members'}}){ | ||
| 450 | if( grep(/$match/, (values %{$member->{'workfiles'}})) ){ | ||
| 451 | push(@{$retval},$member); | ||
| 452 | } | ||
| 453 | } | ||
| 454 | return (wantarray) ? @{$retval} : $retval; | ||
| 455 | } | ||
| 456 | else{ | ||
| 457 | return (wantarray) ? @{$type->{'members'}} : $type->{'members'}; | ||
| 458 | } | ||
| 459 | } | ||
| 460 | |||
| 461 | } | ||
| 462 | |||
| 463 | ############################################################################## | ||
| 464 | # Folder utility methods | ||
| 465 | ############################################################################## | ||
| 466 | sub getWD{ | ||
| 467 | my($self) = shift; | ||
| 468 | my($WD); | ||
| 469 | $WD = $self->{'WKDIR'}; | ||
| 470 | (($^O ne "MSWin32") && $PVCSMULTIPLATFORM) && translatePath2Unix(\$WD); | ||
| 471 | return $WD; | ||
| 472 | } | ||
| 473 | |||
| 474 | ############################################################################## | ||
| 475 | # Folder Checkout methods | ||
| 476 | ############################################################################## | ||
| 477 | |||
| 478 | sub get{ | ||
| 479 | @_ >= 1 or croak 'usage: $Folder->get([get opts])'; | ||
| 480 | my($type) = shift; | ||
| 481 | my($class) = ref($type); | ||
| 482 | my($member,$error); | ||
| 483 | my($curdir) = cwd(); | ||
| 484 | $error=1; | ||
| 485 | if($class eq "VCS::PVCS::Folder"){ | ||
| 486 | $PVCSOUTPUT = ""; | ||
| 487 | my($wkdir) = $type->{'WKDIR'}; | ||
| 488 | ($^O ne "MSWin32") ? translatePath2Unix(\$wkdir) : | ||
| 489 | translatePath2Win(\$wkdir); | ||
| 490 | chdir($wkdir) or | ||
| 491 | (croak "Cant chdir to $wkdir to check out folder $type->{'NAME'}\n"); | ||
| 492 | foreach $member (@{$type->{'members'}}){ | ||
| 493 | unless($member->get(@_)){ | ||
| 494 | (warn "GET error: $PVCSCURROUTPUT") if $PVCSDEBUG; | ||
| 495 | $error=0; | ||
| 496 | } | ||
| 497 | } | ||
| 498 | } | ||
| 499 | else{ | ||
| 500 | croak "Must invoke Folder::get passing folder object"; | ||
| 501 | } | ||
| 502 | chdir($curdir); | ||
| 503 | $error; | ||
| 504 | } | ||
| 505 | |||
| 506 | sub checkout{ | ||
| 507 | get(@_); | ||
| 508 | } | ||
| 509 | |||
| 510 | sub co{ | ||
| 511 | get(@_); | ||
| 512 | } | ||
| 513 | |||
| 514 | ############################################################################## | ||
| 515 | # Folder Checkin methods | ||
| 516 | ############################################################################## | ||
| 517 | |||
| 518 | sub put{ | ||
| 519 | @_ >= 1 or croak 'usage: $Folder->put([put opts])'; | ||
| 520 | my($type) = shift; | ||
| 521 | my($class) = ref($type); | ||
| 522 | my($member,$error); | ||
| 523 | my($curdir) = cwd(); | ||
| 524 | $error=1; | ||
| 525 | if($class eq "VCS::PVCS::Folder"){ | ||
| 526 | $PVCSOUTPUT = ""; | ||
| 527 | my($wkdir) = $type->{'WKDIR'}; | ||
| 528 | ($^O ne "MSWin32") ? translatePath2Unix(\$wkdir) : | ||
| 529 | translatePath2Win(\$wkdir); | ||
| 530 | chdir($wkdir) or | ||
| 531 | (croak "Cant chdir to $wkdir to check in folder $type->{'NAME'}\n"); | ||
| 532 | foreach $member (@{$type->{'members'}}){ | ||
| 533 | unless($member->put(@_)){ | ||
| 534 | (warn "PUT error: $PVCSCURROUTPUT") if $PVCSDEBUG; | ||
| 535 | $error=0; | ||
| 536 | } | ||
| 537 | } | ||
| 538 | } | ||
| 539 | else{ | ||
| 540 | croak "Must invoke Folder::put passing folder object"; | ||
| 541 | } | ||
| 542 | $error; | ||
| 543 | } | ||
| 544 | |||
| 545 | # aliases | ||
| 546 | sub checkin{ | ||
| 547 | put(@_); | ||
| 548 | } | ||
| 549 | |||
| 550 | sub ci{ | ||
| 551 | put(@_); | ||
| 552 | } | ||
| 553 | |||
| 554 | |||
| 555 | ############################################################################## | ||
| 556 | # history methods | ||
| 557 | ############################################################################## | ||
| 558 | sub vlog{ | ||
| 559 | @_ >= 1 or croak 'usage: $Folder->vlog([vlog opts])'; | ||
| 560 | my($type) = shift; | ||
| 561 | my($class) = ref($type); | ||
| 562 | my($member,$error); | ||
| 563 | my($curdir) = cwd(); | ||
| 564 | $error=1; | ||
| 565 | if($class eq "VCS::PVCS::Folder"){ | ||
| 566 | $PVCSOUTPUT = ""; | ||
| 567 | my($wkdir) = $type->{'WKDIR'}; | ||
| 568 | ($^O ne "MSWin32") ? translatePath2Unix(\$wkdir) : | ||
| 569 | translatePath2Win(\$wkdir); | ||
| 570 | chdir($wkdir) or | ||
| 571 | (croak "Cant chdir to $wkdir to vlog folder $type->{'NAME'}\n"); | ||
| 572 | foreach $member (@{$type->{'members'}}){ | ||
| 573 | unless($member->vlog(@_)){ | ||
| 574 | (warn "VLOG error: $PVCSCURROUTPUT") if $PVCSDEBUG; | ||
| 575 | $error=0; | ||
| 576 | } | ||
| 577 | } | ||
| 578 | } | ||
| 579 | else{ | ||
| 580 | croak "Must invoke Folder::vlog passing folder object"; | ||
| 581 | } | ||
| 582 | $error; | ||
| 583 | } | ||
| 584 | |||
| 585 | sub log{ | ||
| 586 | VCS::PVCS::Folder::vlog(@_); | ||
| 587 | } | ||
| 588 | |||
| 589 | sub history{ | ||
| 590 | VCS::PVCS::Folder::vlog(@_); | ||
| 591 | } | ||
| 592 | |||
| 593 | ###################################################################### | ||
| 594 | # locking methods | ||
| 595 | ###################################################################### | ||
| 596 | |||
| 597 | sub lock{ | ||
| 598 | @_ >= 2 or croak 'usage: $Folder->lock($label|$version,[vcs opts])'; | ||
| 599 | my($type) = shift; | ||
| 600 | my($version) = shift; | ||
| 601 | |||
| 602 | vcs($type,@_,"-L$version"); | ||
| 603 | } | ||
| 604 | |||
| 605 | sub unlock{ | ||
| 606 | @_ >= 2 or croak 'usage: $Folder->unlock($label|$version,[vcs opts])'; | ||
| 607 | my($type) = shift; | ||
| 608 | my($version) = shift; | ||
| 609 | |||
| 610 | vcs($type,@_,"-U$version"); | ||
| 611 | } | ||
| 612 | |||
| 613 | ###################################################################### | ||
| 614 | # Version label methods | ||
| 615 | ###################################################################### | ||
| 616 | sub addVersionLabel{ | ||
| 617 | @_ >= 2 or croak 'usage: $Folder->addVersionLabel($label,[vcs opts])'; | ||
| 618 | my($type) = shift; | ||
| 619 | my($label) = shift; | ||
| 620 | |||
| 621 | vcs($type,@_,"-V$label"); | ||
| 622 | } | ||
| 623 | |||
| 624 | sub deleteVersionLabel{ | ||
| 625 | @_ >= 2 or croak 'usage: $Folder->deleteVersionLabel($label,[vcs opts])'; | ||
| 626 | my($type) = shift; | ||
| 627 | my($label) = shift; | ||
| 628 | |||
| 629 | ($label .= ":delete") unless ($label =~ /:delete$/); | ||
| 630 | vcs($type,@_,"-V$label"); | ||
| 631 | } | ||
| 632 | |||
| 633 | sub replaceVersionLabel{ | ||
| 634 | @_ >= 3 or croak 'usage: $Folder->replaceVersionLabel($newlabel,$oldlabel,[vcs opts])'; | ||
| 635 | my($type) = shift; | ||
| 636 | my($newlabel) = shift; | ||
| 637 | my($oldlabel) = shift; | ||
| 638 | |||
| 639 | vcs($type,@_,"-V$newlabel\:\:$oldlabel"); | ||
| 640 | } | ||
| 641 | |||
| 642 | sub addFloatingVersionLabel{ | ||
| 643 | @_ >= 2 or croak 'usage: $Folder->addFloatingVersionLabel($label,[vcs opts])'; | ||
| 644 | my($type) = shift; | ||
| 645 | my($label) = shift; | ||
| 646 | ($label .= ":\\*") unless ($label =~ /:\*$/); | ||
| 647 | vcs($type,@_,"-V$label"); | ||
| 648 | } | ||
| 649 | |||
| 650 | sub transformVersionLabel{ | ||
| 651 | @_ >= 2 or croak 'usage: $Folder->transformVersionLabel($label,[vcs opts])'; | ||
| 652 | my($type) = shift; | ||
| 653 | my($label) = shift; | ||
| 654 | ($label .= ":\\*") unless ($label =~ /:\*$/); | ||
| 655 | vcs($type,@_,"-V$label","-Y"); | ||
| 656 | } | ||
| 657 | |||
| 658 | |||
| 659 | ###################################################################### | ||
| 660 | # Promotion group methods | ||
| 661 | ###################################################################### | ||
| 662 | |||
| 663 | sub deletePromoGroup{ | ||
| 664 | @_ >= 2 or croak 'usage: $Folder->deletePromoGroup($group,[vcs opts])'; | ||
| 665 | my($type) = shift; | ||
| 666 | my($label) = shift; | ||
| 667 | |||
| 668 | ($label .= ":delete") unless ($label =~ /:delete$/); | ||
| 669 | vcs($type,@_,"-G$label"); | ||
| 670 | |||
| 671 | } | ||
| 672 | |||
| 673 | sub addPromoGroup{ | ||
| 674 | @_ >= 2 or croak 'usage: $Folder->addPromoGroup($group:$rev,[vcs opts])'; | ||
| 675 | my($type) = shift; | ||
| 676 | my($label) = shift; | ||
| 677 | |||
| 678 | vcs($type,@_,"-G$label"); | ||
| 679 | } | ||
| 680 | |||
| 681 | sub createArchive{ | ||
| 682 | @_ >= 2 or croak 'usage: $Folder->createArchive($archive,[vcs opts])'; | ||
| 683 | my($type) = shift; | ||
| 684 | my($tmpopt) = $VCS::PVCS::Commands::vcsopts->{'I'}; | ||
| 685 | |||
| 686 | vcs($type,@_,"-I"); | ||
| 687 | } | ||
| 688 | |||
| 689 | |||
| 690 | ########################################################################## | ||
| 691 | # The VCS utility command for augmentation for folder objects | ||
| 692 | ########################################################################## | ||
| 693 | sub vcs{ | ||
| 694 | @_ >= 1 or croak 'usage: vcs([opts][files])'; | ||
| 695 | my($type) = shift; | ||
| 696 | my($class) = ref($type); | ||
| 697 | my($member,$error); | ||
| 698 | my($curdir) = cwd(); | ||
| 699 | $error=1; | ||
| 700 | if($class eq "VCS::PVCS::Folder"){ | ||
| 701 | $PVCSOUTPUT = ""; | ||
| 702 | my($wkdir) = $type->{'WKDIR'}; | ||
| 703 | ($^O ne "MSWin32") ? translatePath2Unix(\$wkdir) : | ||
| 704 | translatePath2Win(\$wkdir); | ||
| 705 | chdir($wkdir) or | ||
| 706 | (croak "Cant chdir to $wkdir to vlog folder $type->{'NAME'}\n"); | ||
| 707 | |||
| 708 | # If we are not creating a new archive, then call for all members | ||
| 709 | if(! $VCS::PVCS::Commands::vcsopts->{'I'}){ | ||
| 710 | foreach $member (@{$type->{'members'}}){ | ||
| 711 | unless($member->vcs(@_)){ | ||
| 712 | (warn "VCS error: $PVCSCURROUTPUT") if $PVCSDEBUG; | ||
| 713 | $error=0; | ||
| 714 | } | ||
| 715 | } | ||
| 716 | } | ||
| 717 | else{ | ||
| 718 | unless(VCS::PVCS::Commands::vcs(@_)){ | ||
| 719 | (warn "VCS error: $PVCSCURROUTPUT") if $PVCSDEBUG; | ||
| 720 | $error=0; | ||
| 721 | } | ||
| 722 | # TODO Add the new archive to this folder! | ||
| 723 | } | ||
| 724 | } | ||
| 725 | else{ | ||
| 726 | croak "Must invoke Folder::vcs passing folder object"; | ||
| 727 | } | ||
| 728 | $error; | ||
| 729 | } | ||
| 730 | ############################################################################## | ||
| 731 | # attributes | ||
| 732 | ############################################################################## | ||
| 733 | sub getAttributes{ | ||
| 734 | @_ >= 1 or croak 'usage: $Folder->getAttributes([vcs opts])'; | ||
| 735 | my($type) = shift; | ||
| 736 | my($class) = ref($type); | ||
| 737 | my($member,$error); | ||
| 738 | my($curdir) = cwd(); | ||
| 739 | $error=1; | ||
| 740 | if($class eq "VCS::PVCS::Folder"){ | ||
| 741 | $PVCSOUTPUT = ""; | ||
| 742 | foreach $member (@{$type->{'members'}}){ | ||
| 743 | unless($member->getAttributes(@_)){ | ||
| 744 | (warn "getAttributes error: $PVCSCURROUTPUT") if $PVCSDEBUG; | ||
| 745 | $error=0; | ||
| 746 | } | ||
| 747 | } | ||
| 748 | } | ||
| 749 | else{ | ||
| 750 | croak "Must invoke Folder::getAttributes passing folder object"; | ||
| 751 | } | ||
| 752 | $error; | ||
| 753 | } | ||
| 754 | |||
| 755 | |||
| 756 | |||
| 757 | 1; | ||
| 758 | __END__ |