ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Configuration/ConfigArea.pm
(Generate patch)

Comparing COMP/SCRAM/src/Configuration/ConfigArea.pm (file contents):
Revision 1.5 by williamc, Mon Jan 24 17:22:45 2000 UTC vs.
Revision 1.6 by williamc, Thu Jan 27 17:50:55 2000 UTC

# Line 23 | Line 23
23   #                                 no location specified - cwd used
24   # searchlocation([startdir])    : returns the location directory. search starts
25   #                                 from cwd if not specified
26 + # defaultdirname()              : return the default directory name string
27 + # copy(location)                : make a copy of the current area at the
28 + #                                 specified location - return an object
29 + #                                 representing the area
30  
31   package Configuration::ConfigArea;
32   use ActiveDoc::ActiveDoc;
33   require 5.004;
34   use Utilities::AddDir;
35   use ObjectUtilities::ObjectStore;
36 + use Cwd;
37   @ISA=qw(ActiveDoc::ActiveDoc ObjectUtilities::StorableObject);
38  
39   sub init {
# Line 46 | Line 51 | sub init {
51          $self->addtag("setup","use",\&Use_Start,$self, "", $self, "",$self);
52   }
53  
54 + sub defaultdirname {
55 +        my $self=shift;
56 +        my $name=$self->name();
57 +        my $vers=$self->version();
58 +        $vers=~s/^$name_//;
59 +        $name=$name."_".$vers;
60 +        return $name;
61 +        
62 + }
63 +
64   sub setup {
65          my $self=shift;
66  
67          # --- find out the location
68          my $location=$self->requestoption("area_location",
69                  "Please Enter the location of the directory");
70 +        if ( $location!~/^\// ) {
71 +                $location=cwd()."/".$location;
72 +        }
73  
74          # --- find area directory name , default name projectname_version
75          my $name=$self->option("area_name");
58        my $vers=$self->version;
76          if ( ! defined $name ) {
77 <          $name=$self->name();
61 <          $vers=~s/^$name_//;
62 <          $name=$name."_".$vers;
77 >          $name=$self->defaultdirname();
78          }
79          $self->location($location."/".$name);
80  
# Line 102 | Line 117 | sub bootstrapfromlocation {
117          if ( ! defined $self->location(@_) ) {
118            $self->error("Unable to locate the top of local configuration area");
119          }
120 +        print "Found top ".$self->location()."\n";
121          $self->_setupstore();
122          $self->restore($self->location()."/.SCRAM/ConfigArea.dat");
123   }
# Line 124 | Line 140 | sub store {
140          $fh->close();
141   }
142  
143 + sub copy {
144 +        my $self=shift;
145 +        my $destination=shift;
146 +        use File::Basename;
147 +        # create the area
148 +
149 +        AddDir::adddir(dirname($destination));
150 +        
151 +        my @cpcmd=(qw(cp -r), "$self->location()", "$destination");
152 +        print "@cpcmd";
153 + #       File::Copy::copy("$self->location()", "$destination") or
154 +        system(@cpcmd) or
155 +                        $self->error("Cannot copy ".$self->location().
156 +                        " to $destination ".$!);
157 +
158 +        # create a new object based on the new area
159 +        my $newarea=ref($self)->new($self->parentconfig());
160 +        $newarea->bootstrapfromlocation($destination);
161 +        # save it with the new location info
162 +        $newarea->store($self->location()."/.SCRAM/ConfigArea.dat");
163 + }
164 +
165   sub restore {
166          my $self=shift;
167          my $location=shift;
# Line 159 | Line 197 | sub location {
197          my $self=shift;
198  
199          if ( @_ ) {
200 <          $self->{location}=shift
200 >          $self->{location}=shift;
201          }
202          elsif ( ! defined $self->{location} ) {
203            # try and find the release location
204 <          $self->searchlocation();
204 >          $self->{location}=$self->searchlocation();
205          }
206          return  $self->{location};
207   }
208  
209   sub searchlocation {
210          my $self=shift;
173        use Cwd;
211  
212          #start search in current directory if not specified
213          my $thispath;
214          @_?$thispath=shift
215 <          :$thispath=cwd;
215 >          :$thispath=cwd();
216  
217          my $rv=0;
218  
219 <        do {
219 >        Sloop:{
220 >        do {
221 > #         print "Searching $thispath\n";
222            if ( -e "$thispath/.SCRAM" ) {
223 + #           print "Found\n";
224              $rv=1;
225 +            last Sloop;
226            }
227 <        } while ( ( $thispath=~s/(.*)\/.*/$1/ )=~/./  );
227 >        } while ( ($thispath=~s/(.*)\/.*/$1/)=~/./ ) };
228  
229          return $rv?$thispath:undef;
230   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines