[Buildd-tools-devel] [PATCH 13/22] Change listing default to verified lists

Jan-Marek Glogowski glogow at fbihome.de
Thu Mar 26 21:13:51 UTC 2009


This changes the default listing behaviour, so the lists just
contain verified chroots and sessions.
---
 bin/dchroot-dsa/dchroot-dsa-options.cc |    2 +-
 bin/dchroot/dchroot-options.cc         |    2 +-
 bin/schroot/schroot-main-base.cc       |    4 ++--
 bin/schroot/schroot-main.cc            |    2 +-
 bin/schroot/schroot-options-base.cc    |   14 +++++++++-----
 bin/schroot/schroot-options-base.h     |   14 ++------------
 6 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/bin/dchroot-dsa/dchroot-dsa-options.cc b/bin/dchroot-dsa/dchroot-dsa-options.cc
index fec282d..2c88e5c 100644
--- a/bin/dchroot-dsa/dchroot-dsa-options.cc
+++ b/bin/dchroot-dsa/dchroot-dsa-options.cc
@@ -96,7 +96,7 @@ options::check_options ()
       !sbuild::is_absname(this->command[0]))
     throw opt::validation_error(_("Command must have an absolute path"));
 
-  if (this->chroots.empty() && !all_used() &&
+  if (this->chroots.empty() && !all_used &&
       (this->action != ACTION_CONFIG &&
        this->action != ACTION_INFO &&
        this->action != ACTION_LIST &&
diff --git a/bin/dchroot/dchroot-options.cc b/bin/dchroot/dchroot-options.cc
index 7d6dded..55dc416 100644
--- a/bin/dchroot/dchroot-options.cc
+++ b/bin/dchroot/dchroot-options.cc
@@ -89,7 +89,7 @@ options::check_options ()
       sbuild::log_info() << _("Using verbose output") << endl;
     }
 
-  if (!this->chroots.empty() && all_used())
+  if (!this->chroots.empty() && all_used)
     {
       sbuild::log_warning()
 	<< _("--chroot and --all may not be used at the same time")
diff --git a/bin/schroot/schroot-main-base.cc b/bin/schroot/schroot-main-base.cc
index b27f5a5..2f15c2b 100644
--- a/bin/schroot/schroot-main-base.cc
+++ b/bin/schroot/schroot-main-base.cc
@@ -116,7 +116,7 @@ main_base::get_chroot_options ()
       this->options->all_sessions == true)
     {
       sbuild::chroot_config::chroot_list const& list =
-	this->config->get_chroots();
+	this->config->get_chroots(!this->options->all_used);
 
       for (sbuild::chroot_config::chroot_list::const_iterator chroot =
 	     list.begin();
@@ -134,7 +134,7 @@ main_base::get_chroot_options ()
   else
     {
       sbuild::string_list invalid_chroots =
-	this->config->validate_chroots(this->options->chroots);
+	this->config->validate_chroots(this->options->chroots, true);
 
       if (!invalid_chroots.empty())
 	{
diff --git a/bin/schroot/schroot-main.cc b/bin/schroot/schroot-main.cc
index 7dd3203..adc9b84 100644
--- a/bin/schroot/schroot-main.cc
+++ b/bin/schroot/schroot-main.cc
@@ -66,7 +66,7 @@ main::action_config ()
 void
 main::action_list ()
 {
-  this->config->print_chroot_list(std::cout);
+  this->config->print_chroot_list(std::cout, !this->options->all_used);
 }
 
 void
diff --git a/bin/schroot/schroot-options-base.cc b/bin/schroot/schroot-options-base.cc
index 8f7db54..56c7d1c 100644
--- a/bin/schroot/schroot-options-base.cc
+++ b/bin/schroot/schroot-options-base.cc
@@ -52,6 +52,7 @@ options_base::options_base ():
   all(false),
   all_chroots(false),
   all_sessions(false),
+  all_used(false),
   session_name(),
   session_force(false),
   chroot(_("Chroot selection")),
@@ -166,6 +167,9 @@ options_base::check_actions ()
   // Chain up to check basic actions.
   schroot_base::options::check_actions();
 
+  // An 'all' commandline flag was set originally.
+  this->all_used = (this->all || this->all_chroots || this->all_sessions);
+
   if (this->quiet && this->verbose)
     {
       sbuild::log_warning()
@@ -174,7 +178,7 @@ options_base::check_actions ()
       sbuild::log_info() << _("Using verbose output") << endl;
     }
 
-  if (!this->chroots.empty() && all_used())
+  if (!this->chroots.empty() && all_used)
     {
       sbuild::log_warning()
 	<< _("--chroot and --all may not be used at the same time")
@@ -192,7 +196,7 @@ options_base::check_actions ()
       this->all = this->all_sessions = false;
 
       // If no chroot was specified, fall back to the "default" chroot.
-      if (this->chroots.empty() && all_used() == false)
+      if (this->chroots.empty() && !all_used)
 	this->chroots.push_back("default");
     }
   else if (this->action == ACTION_SESSION_BEGIN)
@@ -200,7 +204,7 @@ options_base::check_actions ()
       // Only allow one session chroot
       this->load_chroots = true;
       this->load_sessions = false;
-      if (this->chroots.size() != 1 || all_used())
+      if (this->chroots.size() != 1 || all_used)
 	throw opt::validation_error(_("Exactly one chroot must be specified when beginning a session"));
 
       this->all = this->all_chroots = this->all_sessions = false;
@@ -223,7 +227,7 @@ options_base::check_actions ()
     {
       // If not specified otherwise, load normal chroots, but allow
       // --all options.
-      if (!all_used())
+      if (!all_used)
 	{
 	  if (sessions)
 	    this->load_sessions = true;
@@ -245,7 +249,7 @@ options_base::check_actions ()
       // --all options.
       if (!this->chroots.empty()) // chroot specified
 	this->load_chroots = this->load_sessions = true;
-      else if (!all_used()) // no chroots specified
+      else if (!all_used) // no chroots specified
 	{
 	  if (sessions)
 	    {
diff --git a/bin/schroot/schroot-options-base.h b/bin/schroot/schroot-options-base.h
index 9174bdc..6c90a69 100644
--- a/bin/schroot/schroot-options-base.h
+++ b/bin/schroot/schroot-options-base.h
@@ -97,6 +97,8 @@ namespace schroot
     bool                 all_chroots;
     /// Use all sessions.
     bool                 all_sessions;
+    /// An 'all' commandline flags was used.
+    bool                 all_used;
     /// Load chroots.
     bool                 load_chroots;
     /// Load sessions.
@@ -107,18 +109,6 @@ namespace schroot
     bool                 session_force;
 
   protected:
-    /**
-     * Check if any of the --all options have been used.
-     *
-     * @returns true if any of the options have been used, otherwise
-     * false.
-     */
-    bool
-    all_used () const
-    {
-      return (this->all || this->all_chroots || this->all_sessions);
-    }
-
     virtual void
     add_options ();
 
-- 
1.6.2.1




More information about the Buildd-tools-devel mailing list