Commits

Jens-Heiner Rechtien [hr]  committed 66112a8

hr77: #i117757#: small enhancements to cws.pl

- change the default (pull) entry to point to the CWS outgoing repository
- disable obsolete switch -p
- fetching prebuild binaries: display major and milestone
- external_sources: fix diagnostic caused by empty last line in ooo.lst

  • Participants
  • Parent commits 38188af

Comments (0)

Files changed (1)

File solenv/bin/cws.pl

 my %valid_options_hash = ( 
                             'help'       => ['help'],
                             'create'     => ['help', 'milestone', 'migration', 'hg'],
-                            'fetch'      => ['help', 'milestone', 'childworkspace','platforms','noautocommon',
-                                            'quiet', 'onlysolver', 'additionalrepositories'],
+                            'fetch'      => ['help', 'milestone', 'childworkspace', 'platforms',
+                                            'nolongerused', 'quiet', 'onlysolver', 'additionalrepositories'],
                             'query'      => ['help', 'milestone','masterworkspace','childworkspace'],
                             'task'       => ['help'],
                             'setcurrent' => ['help', 'milestone'],
                                              'debug',
                                              'profile',
                                              'commit|C',
-                                             'platforms|p=s',
+                                             'platforms|x=s',
+                                             'nolongerused|p=s',
                                              'additionalrepositories|r=s',
-                                             'noautocommon|x=s',
                                              'onlysolver|o',
                                              'quiet|q',
                                              'help|h'
     print_message("... finished in " . timestr($time_diff));
 }
 
-sub hgrc_append_push_path_and_hooks
+sub hgrc_modify_default_paths_and_append_hooks
 {
     my $target     = shift;
     my $cws_source = shift;
 
+    my $cws_http = $cws_source;
     $cws_source =~ s/http:\/\//ssh:\/\/hg@/;
+
     if ( $debug ) {
-        print STDERR "CWS-DEBUG: hgrc_append_push_path_and_hooks(): default-push path: '$cws_source'\n";
+        print STDERR "CWS-DEBUG: hgrc_modify_default_paths_and_append_hooks(): default-push path: '$cws_source'\n";
     }
-    if ( !open(HGRC, ">>$target/.hg/hgrc") ) {
-        print_error("Can't append to hgrc file of repository '$target'.\n", 88);
+    if ( !open(HGRC, "+<$target/.hg/hgrc") ) {
+        print_error("Can't open hgrc file of repository '$target' for r/w.\n", 88);
+    }
+    my @hgrc = <HGRC>;
+
+    if ( !truncate(HGRC, 0) ) {
+        print_error("Can't truncate hgrc file of repository '$target'.\n", 88);
+    }
+    if ( !seek(HGRC, 0, 0) ) {
+        print_error("Can't seek hgrc file of repository '$target'.\n", 88);
+    }
+
+    foreach(@hgrc) {
+        if ($_ =~ /default\s+\=\s+\w+/) {
+            print HGRC "default = " . "$cws_http\n";
+        }
+        else {
+            print HGRC $_;
+        }
     }
     print HGRC "default-push = " . "$cws_source\n";
     print HGRC "[extensions]\n";
 
     # if we fetched a CWS adorn the result with push-path and hooks
     if ( $cws_remote_source ) {
-        hgrc_append_push_path_and_hooks($target, $cws_remote_source);
+        hgrc_modify_default_paths_and_append_hooks($target, $cws_remote_source);
     }
 
     # update the result if necessary
     while(<EXT>) {
         if ( !/^http:/ ) {
             chomp;
+            next if /^$/;
             push(@external_sources, $_);
         }
     }
      }
     elsif ($arg eq 'fetch') {
         print STDERR "fetch: fetch a milestone or CWS\n";
-        print STDERR "usage: fetch [-q] [-p platforms] [-r additionalrepositories] [-o] <-m milestone> <workspace>\n";
-        print STDERR "usage: fetch [-q] [-p platforms] [-r additionalrepositories] [-o] <-c cws> <workspace>\n";
         print STDERR "usage: fetch [-q] [-x platforms] [-r additionalrepositories] [-o] <-m milestone> <workspace>\n";
         print STDERR "usage: fetch [-q] [-x platforms] [-r additionalrepositories] [-o] <-c cws> <workspace>\n";
         print STDERR "usage: fetch [-q] <-m milestone> <workspace>\n";
         print STDERR "\t--milestone milestone:   Same as -m milestone\n";
         print STDERR "\t-c childworkspace:       Checkout CWS <childworkspace> to workspace <workspace>\n";
         print STDERR "\t--child childworkspace:  Same as -c childworkspace\n";
-        print STDERR "\t-p platform:             Copy one or more prebuilt platforms 'platform'. \n";
-        print STDERR "\t                         Separate multiple platforms with commas.\n";
-        print STDERR "\t                         Automatically adds 'common[.pro]' as required.\n";
-        print STDERR "\t--platforms platform:    Same as -p\n";
         print STDERR "\t-x platform:             Copy one or more prebuilt platforms 'platform'. \n";
         print STDERR "\t                         Separate multiple platforms with commas.\n";
-        print STDERR "\t                         Does not automatically adds 'common[.pro]'.\n";
         print STDERR "\t-r additionalrepositories Checkout additional repositories. \n";
         print STDERR "\t                         Separate multiple repositories with commas.\n";
-        print STDERR "\t--noautocommon platform: Same as -x\n";
+        print STDERR "\t--platforms platform:    Same as -x\n";
         print STDERR "\t-o:                      Omit checkout of sources, copy only solver. \n";
         print STDERR "\t--onlysolver:            Same as -o\n";
         print STDERR "\t-q:                      Silence some of the output of the command.\n";
     $additional_repositories_opt = "", if ( !defined $additional_repositories_opt );
     my $child = $options_ref->{'childworkspace'};
     my $platforms = $options_ref->{'platforms'};
-    my $noautocommon = $options_ref->{'noautocommon'};
+    my $nolongerused = $options_ref->{'nolongerused'};
     my $quiet  = $options_ref->{'quiet'}  ? 1 : 0 ;
     my $switch = $options_ref->{'switch'} ? 1 : 0 ;
     my $onlysolver = $options_ref->{'onlysolver'} ? 1 : 0 ;
 
+    if ( defined($nolongerused) ) {
+        print_error("Option '-p' is obsolete. Please use option '-x' instead.", 0);
+        do_help(['fetch']);
+    }
+
     if ( !defined($milestone_opt) && !defined($child) ) {
         print_error("Specify one of these options: -m or -c", 0);
         do_help(['fetch']);
         do_help(['fetch']);
     }
 
-    if ( defined($platforms) && defined($noautocommon) ) {
-        print_error("Options -p and -x are mutally exclusive", 0);
-        do_help(['fetch']);
-    }
-
-    if ( $onlysolver && !(defined($platforms) || defined($noautocommon)) ) {
-        print_error("Option '-o' is Only usuable combination with option '-p' or '-x'.", 0);
+    if ( $onlysolver && !defined($platforms)  ) {
+        print_error("Option '-o' is Only usuable combination with option '-x'.", 0);
         do_help(['fetch']);
     }
 
     # Check early for platforms so we can bail out before anything time consuming is done
     # in case of a missing platform
     my @platforms;
-    if ( defined($platforms) || defined($noautocommon) ) {
+    if ( defined($platforms) ) {
         use Archive::Zip; # warn early if module is missing
         if ( !defined($prebuild_dir ) ) {
             print_error("PREBUILD_BINARIES not configured, can't find platform solvers", 99);
         }
         $prebuild_dir = "$prebuild_dir/$masterws";
+        @platforms = split(/,/, $platforms);
 
-        if ( defined($platforms) ) {
-            @platforms = split(/,/, $platforms);
-
-            my $added_product = 0;
-            my $added_nonproduct = 0;
-            foreach(@platforms) {
-                if ( $_ eq 'common.pro' ) {
-                    $added_product = 1;
-                    print_warning("'$_' is added automatically to the platform list, don't specify it explicit");
-                }
-                if ( $_ eq 'common' ) {
-                    $added_nonproduct = 1;
-                    print_warning("'$_' is added automatically to the platform list, don't specify it explicit");
-                }
-            }
-
-            # add common.pro/common to platform list
-            if ( $so_svn_server ) {
-                my $product = 0;
-                my $nonproduct = 0;
-                foreach(@platforms) {
-                    if ( /\.pro$/ ) {
-                        $product = 1;
-                    }
-                    else {
-                        $nonproduct = 1;
-                    }
-                }
-                unshift(@platforms, 'common.pro') if ($product && !$added_product);
-                unshift(@platforms, 'common') if ($nonproduct && !$added_nonproduct);
-            }
-        }
-        else {
-            @platforms = split(/,/, $noautocommon);
-        }
-
+        print_message("... checking availability of platform solver(s), master '$masterws', milestone '$milestone'.");
         foreach(@platforms) {
             if ( ! -d "$prebuild_dir/$_") {
                 print_error("Can't find prebuild binaries for platform '$_'.", 22);
         }
     }
 
-    if ( defined($platforms) || defined($noautocommon) ) {
+    if ( defined($platforms) ) {
         if ( !-d $workspace ) {
             if ( !mkdir($workspace) ) {
                 print_error("Can't create directory '$workspace': $!.", 8);