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.7 by williamc, Wed Feb 9 08:16:15 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 + # linkarea(oref)                : link area with another
31  
32   package Configuration::ConfigArea;
33   use ActiveDoc::ActiveDoc;
34   require 5.004;
35   use Utilities::AddDir;
36   use ObjectUtilities::ObjectStore;
37 + use Cwd;
38   @ISA=qw(ActiveDoc::ActiveDoc ObjectUtilities::StorableObject);
39  
40   sub init {
# Line 38 | Line 44 | sub init {
44          $self->newparse("download");
45          $self->newparse("setup");
46          $self->addtag("init","project",\&Project_Start,$self,
47 <        \&Project_text,$self,"", $self );
47 >            \&Project_text,$self,"", $self );
48          $self->addurltags("download");
49          $self->addtag("download","use",\&Use_download_Start,$self,
50                                                  "", $self, "",$self);
# Line 46 | Line 52 | sub init {
52          $self->addtag("setup","use",\&Use_Start,$self, "", $self, "",$self);
53   }
54  
55 +
56 + sub defaultdirname {
57 +        my $self=shift;
58 +        my $name=$self->name();
59 +        my $vers=$self->version();
60 +        $vers=~s/^$name_//;
61 +        $name=$name."_".$vers;
62 +        return $name;
63 +        
64 + }
65 +
66   sub setup {
67          my $self=shift;
68  
69 <        # --- find out the location
70 <        my $location=$self->requestoption("area_location",
71 <                "Please Enter the location of the directory");
69 >        # --- find out the location - default is cwd
70 >        my $location=$self->option("area_location");
71 >        if ( ! defined $location ) {
72 >                $location=cwd();
73 >        }
74 >        elsif ( $location!~/^\// ) {
75 >                $location=cwd()."/".$location;
76 >        }
77  
78          # --- find area directory name , default name projectname_version
79          my $name=$self->option("area_name");
58        my $vers=$self->version;
80          if ( ! defined $name ) {
81 <          $name=$self->name();
61 <          $vers=~s/^$name_//;
62 <          $name=$name."_".$vers;
81 >          $name=$self->defaultdirname();
82          }
83          $self->location($location."/".$name);
84  
# Line 102 | Line 121 | sub bootstrapfromlocation {
121          if ( ! defined $self->location(@_) ) {
122            $self->error("Unable to locate the top of local configuration area");
123          }
124 +        print "Found top ".$self->location()."\n";
125          $self->_setupstore();
126          $self->restore($self->location()."/.SCRAM/ConfigArea.dat");
127   }
# Line 124 | Line 144 | sub store {
144          $fh->close();
145   }
146  
147 + sub copy {
148 +        my $self=shift;
149 +        my $destination=shift;
150 +        use File::Basename;
151 +        # create the area
152 +
153 +        AddDir::adddir(dirname($destination));
154 +        
155 +        $temp=$self->location();
156 +        my @cpcmd=(qw(cp -r), "$temp", "$destination");
157 +        print "@cpcmd"."\n";
158 + #       File::Copy::copy("$self->location()", "$destination") or
159 +        system(@cpcmd) == 0 or
160 +                        $self->error("Cannot copy ".$self->location().
161 +                        " to $destination ".$!);
162 +
163 +        # create a new object based on the new area
164 +        my $newarea=ref($self)->new($self->parentconfig());
165 +        $newarea->bootstrapfromlocation($destination);
166 +        # save it with the new location info
167 +        $newarea->store($self->location()."/.SCRAM/ConfigArea.dat");
168 + }
169 +
170   sub restore {
171          my $self=shift;
172          my $location=shift;
# Line 159 | Line 202 | sub location {
202          my $self=shift;
203  
204          if ( @_ ) {
205 <          $self->{location}=shift
205 >          $self->{location}=shift;
206          }
207          elsif ( ! defined $self->{location} ) {
208            # try and find the release location
209 <          $self->searchlocation();
209 >          $self->{location}=$self->searchlocation();
210          }
211          return  $self->{location};
212   }
213  
214   sub searchlocation {
215          my $self=shift;
173        use Cwd;
216  
217          #start search in current directory if not specified
218          my $thispath;
219          @_?$thispath=shift
220 <          :$thispath=cwd;
220 >          :$thispath=cwd();
221  
222          my $rv=0;
223  
224 <        do {
224 >        Sloop:{
225 >        do {
226 > #         print "Searching $thispath\n";
227            if ( -e "$thispath/.SCRAM" ) {
228 + #           print "Found\n";
229              $rv=1;
230 +            last Sloop;
231            }
232 <        } while ( ( $thispath=~s/(.*)\/.*/$1/ )=~/./  );
232 >        } while ( ($thispath=~s/(.*)\/.*/$1/)=~/./ ) };
233  
234          return $rv?$thispath:undef;
235   }
# Line 209 | Line 255 | sub addconfigitem {
255          # Set up the document
256          $docref->setup();
257   #       $self->config()->storepolicy("local");
212        $docref->save();
258   }
259  
260   # -------------- Tags ---------------------------------

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines