Add a version number to Module::Pluggable::Object and
[p5sagit/p5-mst-13.2.git] / lib / CPAN / HandleConfig.pm
index 3d03b56..d4495ef 100644 (file)
@@ -2,7 +2,7 @@ package CPAN::HandleConfig;
 use strict;
 use vars qw(%can %keys $VERSION);
 
-$VERSION = sprintf "%.6f", substr(q$Rev: 1379 $,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: 1379 $,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: 1379 $,4)/1000000 + 5.4;
      "bzip2",
      "cache_metadata",
      "check_sigs",
+     "colorize_debug",
      "colorize_output",
      "colorize_print",
      "colorize_warn",
@@ -124,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;
@@ -156,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");
+            }
+        }
     }
 }
 
@@ -530,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",
@@ -653,7 +685,7 @@ sub prefs_lookup {
 
     use strict;
     use vars qw($AUTOLOAD $VERSION);
-    $VERSION = sprintf "%.2f", substr(q$Rev: 1379 $,4)/100;
+    $VERSION = sprintf "%.2f", substr(q$Rev: 1566 $,4)/100;
 
     # formerly CPAN::HandleConfig was known as CPAN::Config
     sub AUTOLOAD {