Add a version number to Module::Pluggable::Object and
[p5sagit/p5-mst-13.2.git] / lib / CPAN / HandleConfig.pm
index 4f4b5a3..d4495ef 100644 (file)
@@ -2,7 +2,7 @@ package CPAN::HandleConfig;
 use strict;
 use vars qw(%can %keys $VERSION);
 
-$VERSION = sprintf "%.6f", substr(q$Rev: 1264 $,4)/1000000 + 5.4;
+$VERSION = sprintf "%.6f", substr(q$Rev: 1566 $,4)/1000000 + 5.4;
 
 %can = (
         commit   => "Commit changes to disk",
@@ -16,6 +16,8 @@ $VERSION = sprintf "%.6f", substr(q$Rev: 1264 $,4)/1000000 + 5.4;
 # A2: svn diff -r 985:986 # where andk added yaml_module
 %keys = map { $_ => undef }
     (
+     "applypatch",
+     "auto_commit",
      "build_cache",
      "build_dir",
      "build_dir_reuse",
@@ -23,6 +25,7 @@ $VERSION = sprintf "%.6f", substr(q$Rev: 1264 $,4)/1000000 + 5.4;
      "bzip2",
      "cache_metadata",
      "check_sigs",
+     "colorize_debug",
      "colorize_output",
      "colorize_print",
      "colorize_warn",
@@ -76,6 +79,7 @@ $VERSION = sprintf "%.6f", substr(q$Rev: 1264 $,4)/1000000 + 5.4;
      "test_report",
      "unzip",
      "urllist",
+     "use_sqlite",
      "username",
      "wait_list",
      "wget",
@@ -85,6 +89,7 @@ $VERSION = sprintf "%.6f", substr(q$Rev: 1264 $,4)/1000000 + 5.4;
 my %prefssupport = map { $_ => 1 }
     (
      "build_requires_install_policy",
+     "check_sigs",
      "make",
      "make_install_make_command",
      "prefer_installer",
@@ -122,13 +127,21 @@ sub edit {
         unless (exists $keys{$o}) {
             $CPAN::Frontend->mywarn("Warning: unknown configuration variable '$o'\n");
         }
+        my $changed;
+
+
         # one day I used randomize_urllist for a boolean, so we must
         # list them explicitly --ak
-       if ($o =~ /^(wait_list|urllist|dontload_list)$/) {
+       if (0) {
+        } elsif ($o =~ /^(wait_list|urllist|dontload_list)$/) {
+
+            #
+            # ARRAYS
+            #
+
            $func = shift @args;
            $func ||= "";
             CPAN->debug("func[$func]args[@args]") if $CPAN::DEBUG;
-            my $changed;
            # Let's avoid eval, it's easier to comprehend without.
            if ($func eq "push") {
                push @{$CPAN::Config->{$o}}, @args;
@@ -154,34 +167,52 @@ sub edit {
                 $self->prettyprint($o);
            }
             if ($changed) {
-                $CPAN::CONFIG_DIRTY = 1;
                 if ($o eq "urllist") {
                     # reset the cached values
                     undef $CPAN::FTP::Thesite;
                     undef $CPAN::FTP::Themethod;
+                    $CPAN::Index::LAST_TIME = 0;
                 } elsif ($o eq "dontload_list") {
                     # empty it, it will be built up again
                     $CPAN::META->{dontload_hash} = {};
                 }
             }
-            return $changed;
         } elsif ($o =~ /_hash$/) {
+
+            #
+            # HASHES
+            #
+
             if (@args==1 && $args[0] eq ""){
                 @args = ();
             } elsif (@args % 2) {
                 push @args, "";
             }
             $CPAN::Config->{$o} = { @args };
-            $CPAN::CONFIG_DIRTY = 1;
+            $changed = 1;
         } else {
+
+            #
+            # SCALARS
+            #
+
             if (defined $args[0]){
                 $CPAN::CONFIG_DIRTY = 1;
                 $CPAN::Config->{$o} = $args[0];
+                $changed = 1;
             }
            $self->prettyprint($o)
                 if exists $keys{$o} or defined $CPAN::Config->{$o};
-            return 1;
        }
+        if ($changed) {
+            if ($CPAN::Config->{auto_commit}) {
+                $self->commit;
+            } else {
+                $CPAN::CONFIG_DIRTY = 1;
+                $CPAN::Frontend->myprint("Please use 'o conf commit' to ".
+                                         "make the config permanent!\n\n");
+            }
+        }
     }
 }
 
@@ -332,7 +363,7 @@ sub defaults {
     for my $config (qw(CPAN/MyConfig.pm CPAN/Config.pm)) {
         if ($INC{$config}) {
             CPAN->debug("INC{'$config'}[$INC{$config}]") if $CPAN::DEBUG;
-            CPAN::Shell->reload_this($config,{force => 1});
+            CPAN::Shell->_reload_this($config,{reloforce => 1});
             $CPAN::Frontend->myprint("'$INC{$config}' reread\n");
             last;
         }
@@ -528,9 +559,12 @@ $configpm initialized.
     CPAN::FirstTime::init($configpm, %args);
 }
 
+
+# returns mandatory but missing entries in the Config
 sub missing_config_data {
     my(@miss);
     for (
+         "auto_commit",
          "build_cache",
          "build_dir",
          "cache_metadata",
@@ -622,10 +656,17 @@ sub cpl {
 
 sub prefs_lookup {
     my($self,$distro,$what) = @_;
+
     if ($prefssupport{$what}) {
-        return $distro->prefs->{cpanconfig}{$what} || $CPAN::Config->{$what};
+        return $CPAN::Config->{$what} unless
+            $distro
+                and $distro->prefs
+                    and $distro->prefs->{cpanconfig}
+                        and defined $distro->prefs->{cpanconfig}{$what};
+        return $distro->prefs->{cpanconfig}{$what};
     } else {
-        warn "Warning: $what no yet officially supported for distroprefs, doing a normal lookup";
+        $CPAN::Frontend->mywarn("Warning: $what not yet officially ".
+                                "supported for distroprefs, doing a normal lookup");
         return $CPAN::Config->{$what};
     }
 }
@@ -644,7 +685,7 @@ sub prefs_lookup {
 
     use strict;
     use vars qw($AUTOLOAD $VERSION);
-    $VERSION = sprintf "%.2f", substr(q$Rev: 1264 $,4)/100;
+    $VERSION = sprintf "%.2f", substr(q$Rev: 1566 $,4)/100;
 
     # formerly CPAN::HandleConfig was known as CPAN::Config
     sub AUTOLOAD {