1. mst
  2. ooo340

Commits

Vladimir Glazunov  committed 0f4679b Merge

CWS-TOOLING: integrate CWS hr67

  • Participants
  • Parent commits b239943, 29a9a50
  • Branches default

Comments (0)

Files changed (1)

File solenv/bin/cws.pl

View file
 
 #### globals ####
 
-# TODO: replace dummy vales with actual SVN->hg migration milestones
+# TODO: replace dummy vales with actual SVN->hg and source_config migration milestones
 my $dev300_migration_milestone = 'm64';
+my $dev300_source_config_milestone = 'm65';
 my $ooo320_migration_milestone = 'm999';
+my $ooo320_source_config_milestone = 'm999';
 
 # valid command with possible abbreviations
 my @valid_commands = (  
 
 #  set by --debug switch
 my $debug = 0;
+#  set by --profile switch
+my $profile = 0;
+
 
 #### main ####
 
                                              'migration',
                                              'childworkspace|child|c=s',
                                              'debug',
+                                             'profile',
                                              'commit|C',
                                              'switch|s',
                                              'platforms|p=s',
             $debug = 1;
             next;
         }
+        if ( /profile/ ) {
+            $profile = 1;
+            next;
+        }
         if (!exists $valid_command_options_hash{$_}) {
             print_error("can't use option '--$_' with subcommand '$command'.", 1);
         }
         hg_strip($dest, $revision);
     }
     my $t2 = Benchmark->new();
-    print_time_elapsed($t1, $t2);
+    print_time_elapsed($t1, $t2) if $profile;
 }
 
 sub hg_lan_clone_repository
     print_message("... clone LAN repository '$lan_source' to '$dest'");
     hg_clone($lan_source, $dest, "-U -r $milestone_tag");
     my $t2 = Benchmark->new();
-    print_time_elapsed($t1, $t2);
+    print_time_elapsed($t1, $t2) if $profile;
 }
 
 sub hg_remote_pull_repository
     print_message("... pull from REMOTE repository '$remote_source' to '$dest'");
     hg_pull($dest, $remote_source);
     my $t2 = Benchmark->new();
-    print_time_elapsed($t1, $t2);
+    print_time_elapsed($t1, $t2) if $profile;
 }
 
 sub hg_update_repository
     print_message("... update repository '$dest'");
     hg_update($dest);
     my $t2 = Benchmark->new();
-    print_time_elapsed($t1, $t2);
+    print_time_elapsed($t1, $t2) if $profile;
 }
 
 # Check if clone source and destination are on the same filesystem,
 
 sub update_solver
 {
-    my $platform   = shift;
-    my $source     = shift;
-    my $solver     = shift;
-    my $milestone  = shift;
+    my $platform      = shift;
+    my $source        = shift;
+    my $solver        = shift;
+    my $milestone     = shift;
+    my $source_config = shift;
 
     my @zip_sub_dirs = ('bin', 'doc', 'idl', 'inc', 'lib', 'par', 'pck', 'pdb', 'pus', 'rdb', 'res', 'xml', 'sdf');
     
     my $nzips = @zips;
     print_message("... unzipping $nzips zip archives for platform '$platform'");
 
+
     foreach(@zips) {
         my $zip = Archive::Zip->new();
         unless ( $zip->read( "$platform_source/$_" ) == AZ_OK ) {
         }
         # TODO: check for erorrs
         foreach (@zip_sub_dirs) {
-            unless ( $zip->extractTree($_, "$platform_solver/$_.$milestone") == AZ_OK ) {
+            my $extract_destination = $source_config ? "$platform_solver/$_" : "$platform_solver/$_.$milestone";
+            unless ( $zip->extractTree($_, $extract_destination) == AZ_OK ) {
                 print_error("Can't extract stream from zip file '$platform_source/$_': $!.", 44);
             }
         }
         }
     }
     else {
-        $scm = 'SVN'
+        $scm = 'SVN';
     }
     return $scm;
 }
 
+# TODO: special provisions for "source_config" migration, remove this 
+# some time after migration
+sub get_source_config_for_milestone
+{
+    my $masterws = shift;
+    my $milestone = shift;
+
+    my $milestone_sequence_number = extract_milestone_sequence_number($milestone);
+    my $dev300_migration_sequence_number = extract_milestone_sequence_number($dev300_source_config_milestone);
+    my $ooo320_migration_sequence_number = extract_milestone_sequence_number($ooo320_source_config_milestone);
+
+    my $source_config = 0;
+
+    if ( $masterws eq 'DEV300' ) {
+        if ( $milestone_sequence_number >= $dev300_migration_sequence_number ) {
+            $source_config = 1; 
+        }
+    }
+    elsif ( $masterws eq 'OOO320' ) {
+        if ( $milestone_sequence_number >= $ooo320_migration_sequence_number ) {
+            $source_config = '1'; 
+        }
+    }
+    else {
+        $source_config = 0;
+    }
+    return $source_config;
+}
+
 sub extract_milestone_sequence_number
 {
     my $milestone = shift;
                     hg_clone_repository('ooo', $cws, "$work_master/ooo", $clone_milestone_only); 
                     hg_clone_repository('so', $cws, "$work_master/sun", $clone_milestone_only);
                 }
-                my $linkdir = "$work_master/src.$milestone";
-                if ( !mkdir($linkdir) ) {
-                    print_error("Can't create directory '$linkdir': $!.", 8);
+                if ( get_source_config_for_milestone($masterws, $milestone) ) {
+                    # write source_config file
+                    my $source_config_file = "$work_master/source_config";
+                    if ( !open(SOURCE_CONFIG, ">$source_config_file") ) {
+                        print_error("Can't create source_config file '$source_config_file': $!.", 8);
+                    }
+                    print SOURCE_CONFIG "[repositories]\n";
+                    print SOURCE_CONFIG "ooo=active\n";
+                    print SOURCE_CONFIG "sun=active\n";
+                    close(SOURCE_CONFIG);
                 }
-                relink_workspace($linkdir);
+                else {
+                    my $linkdir = "$work_master/src.$milestone";
+                    if ( !mkdir($linkdir) ) {
+                        print_error("Can't create directory '$linkdir': $!.", 8);
+                    }
+                    relink_workspace($linkdir);
+                }
             }
             else {
                 if ( $scm eq 'SVN' ) {
                 print_error("Can't create directory '$solver': $!.", 8);
             }
         }
+        my $source_config = get_source_config_for_milestone($masterws, $milestone);
         foreach(@platforms) {
             my $time_solver_start = Benchmark->new();
             print_message("... copying platform solver '$_'.");
-            update_solver($_, $prebuild_dir, $solver, $milestone);
+            update_solver($_, $prebuild_dir, $solver, $milestone, $source_config);
             my $time_solver_stop = Benchmark->new();
-            print_time_elapsed($time_solver_start, $time_solver_stop);
+            print_time_elapsed($time_solver_start, $time_solver_stop) if $profile;
         }
     }
     my $time_fetch_stop = Benchmark->new();