PVCS/Commands.pm untested

filter: Statementstmt 0.0% 0 / 257 Branchbran 0.0% 0 / 84 Conditioncond 0.0% 0 / 63 MC/DCmcdc 0.0% 0 / 37 Subroutinesub 0.0% 0 / 30 Podpod 0.0% 0 / 23 totaltotal 0.0% 0 / 494 CC 43 SCAR 54.4
CC
43
Cov
0%
_processOptions
650.0
_execute
20.0
put
12.0
CRAP 230.4
1 # Commands.pm - command interface for Perl PVCS module
2 #
3 # Copyright (c) 1998 Bill Middleton
4 #
5 #
6  
7 =head1 NAME
8  
9 VCS::PVCS::Commands - Command class for for VCS::PVCS
10  
11 =head1 SYNOPSIS
12  
13 use VCS::PVCS::Project;
14  
15 $proj = new VCS::PVCS::Project("ProjectName");
16  
17 # Operate on every member in the project
18  
19 $proj->checkout("-V 1.7 -Y");
20 $proj->checkin("-A foo,bar,baz -V 1.7");
21 $proj->vlog("-BG foo");
22 $proj->lock("mylabel");
23 $proj->addFloatingVersionLabel("mylabel6");
24  
25 # OR
26  
27 # Operate on every archive in each folder
28  
29 $proj = new VCS::PVCS::Project("ProjectName");
30 $folds = $proj->openFolders(".*");
31  
32 foreach $f (@$folds){
33 $f->co("-Y -P -V 1.7");
34 if(! $PVCSERR){
35 $f->put("-A foo,bar,baz -V 1.7");
36 }
37 else{
38 print $PVCSOUTPUT;
39 }
40 $f->put("-A foo,bar,baz -V 1.7");
41 $f->history("-D 071363-091298");
42 $f->unlock("1.7" );
43 $f->addVersionLabel("mylabel2");
44 }
45  
46 # OR
47  
48 # Operate on the projects archive objects separately
49  
50 $proj = new VCS::PVCS::Project("ProjectName");
51 $members = $proj->members(".*");
52  
53 foreach $f (@$members){
54 $f->co("-Y -P -V 1.7",$f->archive());
55  
56 if(! $PVCSERR){
57 $f->put("-A foo,bar,baz -V 1.7 /path/to/archive.c_v");
58 }
59 else{
60 print $PVCSOUTPUT;
61 }
62 $f->put("-A foo,bar,baz -V 1.7",$f->archive());
63 $f->history("-D 071363-091298",$f->archive());
64 $f->unlock("1.7" ,$f->archive());
65 $f->addVersionLabel("mylabel2",$f->archive());
66 }
67  
68 # OR
69  
70 # Operate on the folder's archive objects separately
71  
72 $folds = $proj->openFolders(".*");
73  
74 foreach $folder (@$folds){
75 $members = $folder->members(".*");
76 foreach $f (@$members){
77 $f->co("-Y -P -V 1.7",$f->archive());
78 if(! $PVCSERR){
79 put("-A foo,bar,baz -V 1.7 /path/to/archive.c_v");
80 }
81 else{
82 print $PVCSOUTPUT;
83 }
84 $f->co("-Y -P -V 1.7",$f->archive());
85 $f->put("-A foo,bar,baz -V 1.7",$f->archive());
86 $f->history("-D 071363-091298",$f->archive());
87 $f->unlock("1.7" ,$f->archive());
88 $f->addVersionLabel("mylabel2",$f->archive());
89 }
90 }
91  
92  
93 # OR
94  
95 # Simple use of only this module
96  
97 use VCS::PVCS; # You must still use the master module
98 use VCS::PVCS::Commands qw(:all);
99  
100 # You MUST set these when using Commands by itself
101 $VCS::PVCS::PVCSMASTERCFG = "../../MASTER.CFG";
102 $VCS::PVCS::PVCSCURRPROJCFG = "../../examples.cfg";
103  
104 # Note the arguments may be all in one string, or separated by quotes
105  
106 checkout("-L","-V 1.7","-Y", "/path/to/archive.c_v");
107 if(! $PVCSERR){
108 put("-A foo,bar,baz -V 1.7 /path/to/archive.c_v");
109 }
110 else{
111 print $PVCSOUTPUT;
112 }
113  
114  
115 =head1 DESCRIPTION
116  
117 Each time a command is run, the global values B<$PVCSERR> and
118 B<$PVCSOUTPUT> get set to errno and output respectively.
119  
120 This class can be used directly. But it is intended for use
121 as an ISA for VCS::PVCS::* classes. Folder, Project, and
122 Archive objects inherit Command methods, and augment them,
123 to implement the appropriate actions on each type of object.
124  
125 You B<MUST >set the C<$VCS::PVCS::PVCSMASTERCFG> and the
126 C<$VCS::PVCS::PVCSCURRPROJCFG> to be the master configuration
127 file, and the project configuration file, respectively, when
128 using this module by itself.
129  
130 If you wish to use this module directly, the Exporter makes most
131 of the symbols available when you C<use VCS::PVCS>. You should
132 see the test cases and the sample code above for more details.
133  
134 =head1 METHODS
135  
136 =over 5
137  
138 =item B<get>
139  
140 get([get opts] file(s));
141  
142 =item B<checkout>
143  
144 Convenience routine calls get();
145  
146 =item B<co>
147  
148 Convenience routine calls get();
149  
150 =item B<put>
151  
152 put([put opts] file(s));
153  
154 Checkin the named file.
155  
156 =item B<checkin>
157  
158 Convenience routine calls put();
159  
160 =item B<ci>
161  
162 Convenience routine calls put();
163  
164 =item B<vdiff>
165  
166 vdiff([vdiff opts]);
167  
168 =item B<vlog>
169  
170 vlog([vlog opts]);
171  
172 =item B<log>
173  
174 Convenience routine calls vlog();
175  
176 =item B<history>
177  
178 Convenience routine calls vlog();
179  
180 =item B<lock>
181  
182 lock([vcs opts] files)';
183  
184 Lock the named archive file(s).
185  
186 =item B<unlock>
187  
188 unlock([$label | $version],[vcs opts],file(s));
189  
190 Unlock the named files.
191  
192 =item B<addVersionLabel>
193  
194 addVersionLabel(label,[vcs opts],file(s));
195  
196 Add a version label to the named archive file(s).
197  
198 =item B<deleteVersionLabel>
199  
200 deleteVersionLabel(label,[vcs opts],file(s));
201  
202 Delete a version label to the named archive file(s).
203  
204 =item B<replaceVersionLabel>
205  
206 replaceVersionLabel($newlabel,$oldlabel,[vcs opts],files);
207  
208 Delete a version label to the named archive file(s).
209  
210 =item B<transformVersionLabel>
211  
212 transformVersionLabel(label,[vcs opts],file(s));
213  
214 Transform a version label to floating for the named archive file(s).
215  
216 =item B<addFloatingVersionLabel>
217  
218 addFloatingVersionLabel(label,[vcs opts],file(s));
219  
220 Create a floating version label for the named archive file(s).
221  
222 =item B<deletePromoGroup>
223  
224 deletePromoGroup($group,[vcs opts],file(s))';
225  
226 Delete the promotion group from the archive
227  
228 =item B<addPromoGroup>
229  
230 addPromoGroup(group:$rev,[vcs opts],files(s))';
231  
232 Add the promotion group to the archive (at rev)
233  
234 =item B<createArchive>
235  
236 createArchive([vcs opts],file(s))';
237  
238 Create a new archive in $file.
239  
240 =item B<vcs>
241  
242 vcs([opts][files])';
243  
244 Run vcs by itself.
245  
246 =back
247  
248 =head1 AUTHOR
249  
250 Bill Middleton, wjm@metronet.com
251  
252 =head1 COPYRIGHT
253  
254 The PVCS module is Copyright (c) 1998 Bill Middleton.
255 All rights reserved.
256  
257 You may distribute under the terms of either the GNU General Public
258 License or the Artistic License, as specified in the Perl README file.
259  
260 =head1 SUPPORT / WARRANTY
261  
262 The VCS::PVCS modules are free software.
263  
264 B<THEY COME WITHOUT WARRANTY OF ANY KIND.>
265  
266 Commercial support agreements for Perl can be arranged via
267 The Perl Clinic. See http://www.perl.co.uk/tpc for more details.
268  
269 =head1 SEE ALSO
270  
271 VCS::PVCS::Project
272  
273 =cut
274  
275  
276 package VCS::PVCS::Commands;
277 use strict;
278 use Carp;
279 use Cwd;
280 use Getopt::Long;
281 use Exporter;
282 use VCS::PVCS;
283 use vars qw($VERSION %EXPORT_TAGS @EXPORT_OK @ISA);
284 @ISA = qw(Exporter );
285 $VERSION = "0.02";
286  
287 @EXPORT_OK = (); # populated by export_ok_tags
288 %EXPORT_TAGS = (
289 all => [ qw( get checkout co put checkin ci vlog log history lock
290 unlock addVersionLabel deleteVersionLabel replaceVersionLabel
291 addFloatingVersionLabel transformVersionLabel deletePromoGroup
292 addPromoGroup createArchive changeAccessList vcs vdiff
293 )]
294 );
295 Exporter::export_ok_tags('all');
296  
297  
298 ##############################################################################
299 # Global options - with a few defaults for safety
300 ##############################################################################
301  
302 # Global options common to PVCS commands in use
303 my($globalopts) = {
304 '#' => "6", # pvcs command debug opt
305 'C' => "", # Config file
306 'G' => "", # promotion group
307 'R' => "", # Revision number
308 'S' => "", # Specify alternate suffix file
309 'V' => "", # Version label or floating versionlabel with *
310 'Y' => "", # Answer yes in advance to all prompts
311 'XO' => "", # Redirect STDOUT (also STDERR with +E) to FILE
312 'XE' => "" # Redirect STDERR to FILE
313 };
314  
315 # GET-specific defaults
316 my($getopts) = {
317 'D' => "", # checkout latest before Date/Time
318 'L' => "", # Lock against this revision or version_label
319 'P' => "", # GET to STDOUT
320 'Q' => "1", # Quiet mode AND overwrite
321 'QN' => "", # Quiet mode and DONT overwrite
322 'T' => "", # Assign current timestamp to checkedout files
323 'U' => "", # Checkout only if newer than existing workfile
324 'W' => "" # Checkout a writable workfile
325 };
326  
327 # VDIFF-specific defaults
328 my ($vdiffopts) = {
329 'A' => "", # specify access list
330 'B' => "", # Ignore leading and trailing space when comparing versions
331 'D' => "", # generate a delta script to stdout
332 'E' => "", # expand tabs to given number of characters per column
333 'L' => "", # display the given number of context lines around changes
334 'N' => "", # omit line number information in display
335 'Q' => "1", # Quiet mode and answer YES to any prompt
336 'T' => "", # test for difference only, do not display
337 };
338 my ($putopts) = {
339 'A' => "", # specify access list
340 'B' => "", # Ignore leading and trailing space when comparing versions
341 'F' => "", # Force checkin even if no changes
342 'FB' => "", # Force branch even if tip
343 'L' => "", # Force immediete checkout with lock
344 'M' => "", # Default checkin comment
345 'N' => "", # Answer NO in advance to any prompt
346 'Q' => "", # Quiet mode and answer YES to any prompt
347 'QO' => "", # Quiet mode
348 'T' => "", # Specify workfile description
349 'U' => "", # Store and immedietly checkout readonly
350 'W' => "" # Checkout a writable workfile
351 };
352  
353  
354 # VLOG-specific defaults
355 my ($vlogopts) = {
356 'A' => "", # specify access list
357 'B' => "", # Ignore leading and trailing space when comparing versions
358 'BC' => "", # Display archives containing Tips != RevNumber|VerLabel
359 'BG' => "", # Display revs containing Tips != RevNumber|VerLabel
360 'BL' => "", # Display archive info for locked by USER
361 'BN' => "", # Display newest rev on branch
362 'BR' => "", # Display info about specified rev
363 'BV' => "", # Display info about specified version_label
364 'D' => "", # Display revs in within the daterange
365 'I' => "", # Turn off indentation
366 'L' => "", # Display info about archives locked by USER(s)
367 'M' => "", # Display info about archives owned by USER(s)
368 'U' => "" # Display current userID and ID source
369 };
370  
371 # VCS-specific defaults
372 my ($vcsopts) = {
373 'A' => "", # specify access list
374 'EC' => "", # Specify comment prefix
375 'EN' => "", # Specify newline prefix
376 'I' => "", # Create an empty archive with no revisions
377 'L' => "", # Lock this version or ver_label
378 'M' => "", # Default checkin comment
379 'L' => "", # Force immediete checkout with lock
380 'N' => "", # Answer NO in advance to any prompt
381 'O' => "", # Change Archive owner to this user
382 'PC' => "", # Enable or disable archive compression
383 'PD' => "", # Enable or disable delta compression
384 'PE' => "", # Enable or disable exclusive locking
385 'PG' => "", # Enable or disable delta generation
386 'PK' => "", # Enable or disable keyword expansion
387 'PL' => "", # Enable or disable lock checking
388 'PT' => "", # Enable or disable translation
389 'PW' => "", # Enable or disable archive write-protection
390 'Q' => "", # Quiet mode and answer YES to any prompt
391 'QO' => "1", # Quiet mode
392 'QN' => "", # Quiet mode and answer NO to any prompt
393 'T' => "", # Specify workfile description
394 'U' => "", # Unlock the revision|user|* for all users
395 'W' => "" # Specify workfile name
396 };
397  
398  
399 ##############################################################################
400 # Checkout methods
401 ##############################################################################
402 # -C[<file>] specify a configuration file
403 # -D<date/time> specify a revision by date/time
404 # -H display this text then exit
405 # -L[<rev>] lock the revision with intent to modify it
406 # -N force negative response to all queries
407 # -P[<rev>] pipe revision to stdout
408 # -Q[O] quiet mode; suppress messages and queries
409 # -R<rev> specify a particular revision
410 # -S<suffix> specify a suffix template
411 # -T[<rev>] touch the workfile (set to current time)
412 # -U[<date/time>] get only if newer than existing file or date
413 # -V<version> specify a particular version to extract
414 # -W[<rev>] make file writable even if not locked
415 # -XO<file> write output to file
416 # -XE<file> write errors to file
417 # -Y force affirmative response to all queries
418 # @[<file>] specify a file containing more options/files
419  
420 sub get{
421 @_ >= 1 or croak 'usage: get([get opts] file(s))';
422 my($options);
423 my($input);
424  
425 $options = _processOptions("get",\@_);
426
427 $input = "$options ".join(' ',@_);
428 _execute("get", $input);
429 ($PVCSERR) ? return 0 : return 1;
430  
431 }
432  
433 sub checkout{
434 get(@_);
435 }
436  
437 sub co{
438 get(@_);
439 }
440  
441 ##############################################################################
442 # Checkin methods
443 ##############################################################################
444 # -A[<id list>] specify the access list for a new archive
445 # -B ignore leading and trailing blanks when comparing
446 # -C[<file>] specify a configuration file
447 # -F[B] force PUT even if unchanged or force new branch
448 # -H display this text then exit
449 # -L after PUTting, do a GET with a lock
450 # -M[<text>] specify change description directly or from stdin
451 # -N force negative response to all queries
452 # -Q[O] quiet mode; suppress messages and queries
453 # -R<rev> specify a specific revision number
454 # -S<suffix> specify a suffix template
455 # -T[<desc>] specify workfile description directly or from stdin
456 # -U after PUTting, do a GET without a lock
457 # -V<version> assign version name to the revision
458  
459 sub put{
460 @_ >= 1 or croak 'usage: put([put opts] file(s))';
461 my($options);
462 my($input);
463  
464 $options = _processOptions("put",\@_);
465  
466 $input = $options;
467 if(defined(@_) && (scalar(@_) > 0)){
468 $input .= " ".join(' ',@_);
469 }
470  
471 _execute("put", $input);
472  
473 ($PVCSERR) ? return 0 : return 1;
474 }
475  
476 sub checkin{
477 put(@_);
478 }
479  
480 sub ci{
481 put(@_);
482 }
483  
484 ##############################################################################
485 # diff methods
486 ##############################################################################
487  
488 sub vdiff{
489 @_ >= 1 or croak 'usage: vdiff([vdiff opts])';
490 my($options);
491 my($input);
492  
493 $options = _processOptions("vdiff",\@_);
494 $input = $options;
495 if(defined(@_) && (scalar(@_) > 0)){
496 $input .= " ".join(' ',@_);
497 }
498 _execute("vdiff", $input);
499 ($PVCSERR) ? return 0 : return 1;
500 }
501  
502 ##############################################################################
503 # history methods
504 ##############################################################################
505 sub vlog{
506 @_ >= 1 or croak 'usage: vlog([vlog opts])';
507 my($options);
508 my($input);
509  
510 $options = _processOptions("vlog",\@_);
511 $input = $options;
512 if(defined(@_) && (scalar(@_) > 0)){
513 $input .= " ".join(' ',@_);
514 }
515 _execute("vlog", $input);
516 ($PVCSERR) ? return 0 : return 1;
517  
518 }
519  
520 sub log{
521 vlog(@_);
522 }
523  
524 sub history{
525 vlog(@_);
526 }
527  
528 ######################################################################
529 # locking methods
530 ######################################################################
531  
532 # vcs -L -l[ revision | ver_ label] Lock a revision.
533 sub lock{
534 @_ >= 1 or croak 'usage: lock([vcs opts] files)';
535 my($tmptype) = $vcsopts->{'L'};
536  
537 my($version) = shift;
538 $vcsopts->{'L'} = ($version) ? $version : 1;
539 vcs(@_);
540 $vcsopts->{'L'} = $tmptype;
541  
542 }
543  
544 # -U -u[ revision | ver_label] Unlock a revision by revision number
545 # or version label.
546 # -u: user Unlock all locks placed by user.
547 # -u:* Unlock all locks placed by all users.
548 sub unlock{
549 @_ >= 1 or croak 'usage: unlock([$label | $version],[vcs opts],file(s))';
550 my($tmptype) = $vcsopts->{'U'};
551  
552 my($version) = shift;
553 $vcsopts->{'U'} = ($version) ? $version : 1;
554 vcs(@_);
555 $vcsopts->{'U'} = $tmptype;
556  
557 }
558  
559 ######################################################################
560 # Version label methods
561 ######################################################################
562  
563  
564 # -v ver_label - Assign a version label to the trunk tip
565 # revision of specified archives.
566 #
567 # -v ver_label:rev_number | ver_label - Assign ver_label to the
568 # revision associated with rev_number or ver_label.
569 #
570 # -v floating_label:rev_number* - Assign floating_label to rev_number.
571 #
572 # -v floating_label:ver_label* - Assign floating_label to ver_label.
573 #
574 sub addVersionLabel{
575 @_ >= 2 or croak 'usage: addVersionLabel(label,[vcs opts],file(s))';
576 my($label) = shift;
577 my($tmpopt) = $globalopts->{'V'};
578  
579 $globalopts->{'V'} = $label;
580 vcs(@_);
581 $globalopts->{'V'} = $tmpopt;
582 }
583  
584 # -v ver_label:delete - Delete ver_label.
585 sub deleteVersionLabel{
586 @_ >= 2 or croak 'usage: deleteVersionLabel(label,[vcs opts],file(s))';
587 my($tmpopt) = $globalopts->{'V'};
588 my($label) = shift;
589  
590 ($label .= ":delete") unless ($label =~ /:delete$/);
591 $globalopts->{'V'} = $label;
592 vcs(@_);
593 $globalopts->{'V'} = $tmpopt;
594 }
595  
596 # -v new_ver_label::old_ver_label - Replace old_ver_label with new_ver_label.
597 sub replaceVersionLabel{
598 @_ >= 3 or croak 'usage: replaceVersionLabel($newlabel,$oldlabel,[vcs opts],files)';
599 my($tmpopt) = $globalopts->{'V'};
600 my($newlabel) = shift;
601 my($oldlabel) = shift;
602  
603 $globalopts->{'V'} = "$newlabel\:\:$oldlabel";
604 vcs(@_);
605 $globalopts->{'V'} = $tmpopt;
606 }
607  
608 # -v ver_ label:* - Transform to floating ver_label
609 sub transformVersionLabel{
610 @_ >= 2 or croak 'usage: transformVersionLabel(label,[vcs opts],file(s))';
611 my($tmpopt) = $globalopts->{'V'}; # save
612 my($tmpYopt) = $globalopts->{'Y'}; # save
613 my($label) = shift;
614  
615 ($label .= ":\\*") unless ($label =~ /:\*$/);
616 $globalopts->{'V'} = "$label";
617 $globalopts->{'Y'} = 1;
618 vcs(@_);
619 $globalopts->{'V'} = $tmpopt;
620 $globalopts->{'Y'} = $tmpYopt;
621 }
622  
623 # -v ver_ label:* - Add floating ver_label
624 sub addFloatingVersionLabel{
625 @_ >= 2 or croak 'usage: addFloatingVersionLabel(label,[vcs opts],file(s))';
626 my($tmpopt) = $globalopts->{'V'}; # save
627 my($label) = shift;
628  
629 ($label .= ":\\*") unless ($label =~ /:\*$/);
630 $globalopts->{'V'} = "$label";
631 vcs(@_);
632 $globalopts->{'V'} = $tmpopt;
633 }
634  
635  
636 ######################################################################
637 # Promotion group methods
638 ######################################################################
639  
640 # -G<group>:delete delete a promotion group
641 sub deletePromoGroup{
642 @_ >= 2 or croak 'usage: deletePromoGroup($group,[vcs opts],file(s))';
643 my($tmpopt) = $globalopts->{'G'};
644 my($label) = shift;
645 ($label .= ":delete") unless ($label =! /:delete$/);
646  
647 $globalopts->{'G'} = $label;
648 vcs(@_);
649 $globalopts->{'G'} = $tmpopt;
650 }
651  
652 # -G<group>[:<rev>] assign a promotion group to a revision
653 sub addPromoGroup{
654 @_ >= 2 or croak 'usage: addPromoGroup(group:$rev,[vcs opts],files(s))';
655 my($tmpopt) = $globalopts->{'G'};
656 my($label) = shift;
657  
658 $globalopts->{'G'} = $label;
659 vcs(@_);
660 $globalopts->{'G'} = $tmpopt;
661  
662 }
663  
664 # -I create and initialize an archive
665 sub createArchive{
666 @_ >= 1 or croak 'usage: createArchive([vcs opts],file(s))';
667 my($tmpopt) = $vcsopts->{'I'};
668 $vcsopts->{'I'} = 1;
669 vcs(@_);
670 $vcsopts->{'I'} = $tmpopt;
671 }
672  
673 ##########################################################################
674 # The all-seeing, all-knowing VCS utility command
675 ##########################################################################
676 sub vcs{
677 @_ >= 1 or croak 'usage: vcs([opts][files])';
678 my($options);
679 my($input);
680 $options = _processOptions("vcs",\@_);
681 $input = $options;
682 if(defined(@_) && (scalar(@_) > 0)){
683 $input .= " ".join(' ',@_);
684 }
685 _execute("vcs", $input);
686 ($PVCSERR) ? return 0 : return 1;
687 }
688  
689 ##########################################################################
690 # Private methods
691 ##########################################################################
692  
693 sub _processOptions{
694 my($cmd) = shift;
695 my($opt,$optstring);
696 my($tmpGlobals)= {};
697 my($tmpCmd) = {};
698 my($tmp) = shift;
699 my(@ARGV) = @{$tmp};
700 (@ARGV = split(' ',$ARGV[0])) if (scalar(@ARGV) == 1);
701  
702 Getopt::Long::config( "pass_through");
703  
704 %{$tmpGlobals} = %{$globalopts};
705 GetOptions($tmpGlobals, '-Y', '-R:s', '-C=s', '-V=s', '-G=s','-S=s','-XO=s','-XE=s');
706  
707 foreach $opt (keys(%{$tmpGlobals})){
708 if(defined($tmpGlobals->{$opt}) && length($tmpGlobals->{$opt})){
709 if($tmpGlobals->{$opt} =~ /^1$/){
710 $optstring .= " -${opt} ";
711 next;
712 }
713 elsif(length($tmpGlobals->{$opt})){
714 $optstring .= " -".$opt.$tmpGlobals->{$opt}." ";
715 next;
716 }
717 }
718 }
719  
720 if($cmd eq "get"){
721 %{$tmpCmd} = %{$getopts};
722 GetOptions($tmpCmd, '-P', '-Q', '-U=s', '-W=s', '-T=s',
723 '-L=s', '-D=s', '-QN');
724 foreach $opt (keys(%{$tmpCmd})){
725 if(defined($tmpCmd->{$opt}) && length($tmpCmd->{$opt})){
726 if($tmpCmd->{$opt} =~ /^1$/){
727 $optstring .= " -${opt} ";
728 next;
729 }
730 elsif(length($tmpCmd->{$opt})){
731 $optstring .= " -".$opt.$tmpCmd->{$opt}." ";
732 next;
733 }
734 }
735 }
736 }
737 elsif($cmd eq "put"){
738 %{$tmpCmd} = %{$putopts};
739 GetOptions($tmpCmd, '-QO', '-FB', '-Q', '-A=s',
740 '-U', '-B', '-W', '-T=s', '-L', '-M=s', '-N', '-F');
741 foreach $opt (keys(%{$tmpCmd})){
742 if(defined($tmpCmd->{$opt}) && length($tmpCmd->{$opt})){
743 if($tmpCmd->{$opt} =~ /^1$/){
744 $optstring .= " -${opt} ";
745 next;
746 }
747 elsif(length($tmpCmd->{$opt})){
748 $optstring .= " -".$opt.$tmpCmd->{$opt}." ";
749 next;
750 }
751 }
752 }
753 }
754 elsif($cmd eq "vdiff"){
755 %{$tmpCmd} = %{$vdiffopts};
756 GetOptions($tmpCmd, '-D=s', '-Q', '-A',
757 '-E=i', '-H', '-L=i', '-T', '-M=s', '-N', '-Q');
758 foreach $opt (keys(%{$tmpCmd})){
759 if(defined($tmpCmd->{$opt}) && length($tmpCmd->{$opt})){
760 if($tmpCmd->{$opt} =~ /^1$/){
761 $optstring .= " -${opt} ";
762 next;
763 }
764 elsif(length($tmpCmd->{$opt})){
765 $optstring .= " -".$opt.$tmpCmd->{$opt}." ";
766 next;
767 }
768 }
769 }
770 }
771 elsif($cmd eq "vlog"){
772 %{$tmpCmd} = %{$vlogopts};
773 GetOptions($tmpCmd, '-B', '-BC=s', '-BG=s', '-BL=s','-BN=s',
774 '-BR=s', '-BV=s','D=s','-I','-O=s', '-Q', '-A=s',
775 '-U', '-B', '-L=s' );
776 foreach $opt (keys(%{$tmpCmd})){
777 if(defined($tmpCmd->{$opt}) && length($tmpCmd->{$opt})){
778 if($tmpCmd->{$opt} =~ /^1$/){
779 $optstring .= " -${opt} ";
780 next;
781 }
782 elsif(length($tmpCmd->{$opt})){
783 $optstring .= " -".$opt.$tmpCmd->{$opt}." ";
784 next;
785 }
786 }
787 }
788 }
789 elsif($cmd eq "vcs"){
790 %{$tmpCmd} = %{$vcsopts};
791 ($tmpGlobals->{'Y'}) && ($tmpCmd->{'QN'} = '');
792 GetOptions($tmpCmd, '-D','-PC', '-EN=s', '-T=s',
793 '-PD', '-U:s', '-PE', '-W=s', '-PG',
794 '-PK', '-PL', '-QN', '-QO', '-A=s', '-PT',
795 '-PW', '-EC=s', '-I', '-L:s', '-M', '-N', '-O=s', '-Q');
796 foreach $opt (keys(%{$tmpCmd})){
797 if(defined($tmpCmd->{$opt}) && length($tmpCmd->{$opt})){
798 if($tmpCmd->{$opt} =~ /^1$/){
799 $optstring .= " -${opt} ";
800 next;
801 }
802 elsif(length($tmpCmd->{$opt})){
803 $optstring .= " -".$opt.$tmpCmd->{$opt}." ";
804 next;
805 }
806 }
807 }
808 }
809  
810 # Restore the callers @_, kinda icky
811 @{$tmp} = ();
812 foreach $opt (@ARGV){
813 push(@{$tmp},$opt);
814 }
815 return ($optstring);
816 }
817  
818 sub _execute{
819 my($command,$options) = @_;
820 my($output,$error);
821  
822 if($PVCSSHOWMODE){
823 warn "Would have executed:\n $PVCS_BINDIR/$command -C$PVCSMASTERCFG -C$PVCSCURRPROJCFG $options\n";
824 }
825 else{
826 if($^O eq "MSWin32"){
827 $output = `$PVCS_BINDIR\\$command -C$PVCSMASTERCFG -C$PVCSCURRPROJCFG $options`;
828 }else{
829 $output = `$PVCS_BINDIR/$command -C$PVCSMASTERCFG -C$PVCSCURRPROJCFG $options`;
830 }
831 $error = $?;
832 }
833 if(! $PVCSSHOWMODE){
834 $PVCSERR = $error;
835 $PVCSOUTPUT .= $output;
836 $PVCSCURROUTPUT = $output;
837 }
838  
839 }
840
841  
842  
843 1;
844  
845 __END__