- cleaned up RepoInfo tribools
authorJan Kupec <jkupec@suse.cz>
Mon, 30 Jul 2007 16:02:24 +0000 (16:02 +0000)
committerJan Kupec <jkupec@suse.cz>
Mon, 30 Jul 2007 16:02:24 +0000 (16:02 +0000)
src/zypper-misc.cc
src/zypper-sources.cc
src/zypper.cc

index 9197ab4..a3597d0 100644 (file)
@@ -1,6 +1,7 @@
 #include <fstream>
 #include <sstream>
 #include <boost/format.hpp>
+#include <boost/logic/tribool_io.hpp>
 
 #include <zypp/Patch.h>
 #include <zypp/base/Algorithm.h>
index 971fbef..87b15f9 100644 (file)
@@ -116,8 +116,7 @@ static void print_repo_list( const std::list<zypp::RepoInfo> &repos )
     // zypper status (enabled, autorefresh)
     else
     {
-      tr << (repo.enabled() || indeterminate(repo.enabled()) ?
-          _("Yes") : _("No"));
+      tr << (repo.enabled() ? _("Yes") : _("No"));
       tr << (repo.autorefresh() ? _("Yes") : _("No"));
     }
 
@@ -366,17 +365,15 @@ int add_repo_from_file(const std::string & repo_file_url,
   {
     RepoInfo repo = *it;
 
+    // by default set enabled and autorefresh to true
+    repo.setEnabled(true);
+    repo.setAutorefresh(true);
+
     if (!indeterminate(enabled))
       repo.setEnabled(enabled);
     if (!indeterminate(autorefresh))
       repo.setAutorefresh(autorefresh);
 
-    // by default set enabled and autorefresh to true
-    if (indeterminate(repo.enabled()))
-      repo.setEnabled(true);
-    if (indeterminate(repo.autorefresh()))
-      repo.setAutorefresh(true);
-
     add_repo(repo);
   }
 
index 5fbdae5..c8a8cab 100644 (file)
@@ -696,7 +696,8 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       return ZYPPER_EXIT_ERR_PRIVILEGES;
     }
 
-    tribool enabled(indeterminate);
+    // indeterminate indicates the user has not specified the values
+    tribool enabled(indeterminate); 
     tribool refresh(indeterminate);
 
     if (copts.count("disabled"))
@@ -729,10 +730,11 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
     string alias;
     if (arguments.size() > 1)
       alias = arguments[1];
-    //! \todo use timestamp as alias, if no alias was given
+    //! \todo use timestamp as alias, if no alias was given?
     if (alias.empty ())
       alias = url.asString();
 
+    // by default, enable the repo and set autorefresh
     if (indeterminate(enabled)) enabled = true;
     if (indeterminate(refresh)) refresh = true;