# # # patch "monotone.cc" # from [d81c204e891e4768575408f0a430f04900594d66] # to [3203fd093d06929ee733eac5eba3eb101abc99d6] # # patch "options_applicator.cc" # from [381a87dcb7726bfd42997d3e24a63a50e69a3fa9] # to [5407017eb222eb329f9e22fc465d4f36743d37ee] # # patch "sanity.cc" # from [d664277d416ef52512757d2d033845a9650ccd29] # to [00973120f9cecede882c32d5e88e1c20bdcaafd0] # # patch "sanity.hh" # from [6f2f5e7964abbdb8eed0d1e38d221b722741617e] # to [1f70fd2034c34f0c83a683a59362fb8d1dbac625] # ============================================================ --- monotone.cc d81c204e891e4768575408f0a430f04900594d66 +++ monotone.cc 3203fd093d06929ee733eac5eba3eb101abc99d6 @@ -231,10 +231,7 @@ cpp_main(int argc, char ** argv) { ui.redirect_log_to(app.opts.log); } - if (app.opts.verbosity >= 1) - { - global_sanity.set_debug(); - } + global_sanity.set_verbosity(app.opts.verbosity, true); if (app.opts.dump_given) { global_sanity.set_dump_path(app.opts.dump.as_external()); ============================================================ --- options_applicator.cc 381a87dcb7726bfd42997d3e24a63a50e69a3fa9 +++ options_applicator.cc 5407017eb222eb329f9e22fc465d4f36743d37ee @@ -21,7 +21,6 @@ public: options_applicator::for_what what; bool were_timestamps_enabled; int prev_verbosity; - bool set_verbosity; user_interface::ticker_type tick_type; }; @@ -39,14 +38,8 @@ options_applicator::options_applicator(o // debug messages are not captured for automate, so don't allow // changing the debug-ness for automate commands - if (what == for_primary_cmd || - (!global_sanity.debug_p() && (opts.verbosity < 2))) - { - _impl->prev_verbosity = global_sanity.set_verbosity(opts.verbosity); - _impl->set_verbosity = true; - } - else - _impl->set_verbosity = false; + _impl->prev_verbosity = global_sanity.set_verbosity(opts.verbosity, + what == for_primary_cmd); _impl->tick_type = ui.get_ticker_type(); if (global_sanity.get_verbosity() < 0) @@ -70,8 +63,7 @@ options_applicator::~options_applicator( { ui.enable_timestamps(_impl->were_timestamps_enabled); - if (_impl->set_verbosity) - global_sanity.set_verbosity(_impl->prev_verbosity); + global_sanity.set_verbosity(_impl->prev_verbosity, false); ui.set_ticker_type(_impl->tick_type); ============================================================ --- sanity.cc d664277d416ef52512757d2d033845a9650ccd29 +++ sanity.cc 00973120f9cecede882c32d5e88e1c20bdcaafd0 @@ -67,6 +67,12 @@ struct sanity::impl struct sanity::impl { int verbosity; + // logically this should be "verbosity >= 1", but debug messages aren't + // captured for automate output and doing so would probably be an + // information leak in the case of remote_automate. So track debug-ness + // separately so it can be unchanged when a subcommand changes the + // verbosity level. + bool is_debug; boost::circular_buffer logbuf; std::string real_prog_name; std::string filename; @@ -170,30 +176,35 @@ int } int -sanity::set_verbosity(int level) +sanity::set_verbosity(int level, bool allow_debug_change) { I(imp); int ret = imp->verbosity; imp->verbosity = level; - if (level >= 1) + if (allow_debug_change) { - // it is possible that some pre-setting-of-debug data - // accumulated in the log buffer (during earlier option processing) - // so we will dump it now - ostringstream oss; - vector lines; - copy(imp->logbuf.begin(), imp->logbuf.end(), ostream_iterator(oss)); - split_into_lines(oss.str(), lines); - for (vector::const_iterator i = lines.begin(); i != lines.end(); ++i) - inform_log((*i) + "\n"); + imp->is_debug = (level >= 1); + + if (imp->is_debug) + { + // it is possible that some pre-setting-of-debug data + // accumulated in the log buffer (during earlier option processing) + // so we will dump it now + ostringstream oss; + vector lines; + copy(imp->logbuf.begin(), imp->logbuf.end(), ostream_iterator(oss)); + split_into_lines(oss.str(), lines); + for (vector::const_iterator i = lines.begin(); i != lines.end(); ++i) + inform_log((*i) + "\n"); + } } return ret; } void sanity::set_debug() { - set_verbosity(1); + set_verbosity(1, true); } int sanity::get_verbosity() const @@ -236,7 +247,7 @@ sanity::debug_p() if (!imp) throw std::logic_error("sanity::debug_p called " "before sanity::initialize"); - return imp->verbosity >= 1; + return imp->is_debug; } void ============================================================ --- sanity.hh 6f2f5e7964abbdb8eed0d1e38d221b722741617e +++ sanity.hh 1f70fd2034c34f0c83a683a59362fb8d1dbac625 @@ -63,7 +63,7 @@ struct sanity { virtual ~sanity(); virtual void initialize(int, char **, char const *); void dump_buffer(); - int set_verbosity(int level); + int set_verbosity(int level, bool allow_debug_change); int get_verbosity() const; void set_debug(); // wrapper on set_verbosity // This takes a bare std::string because we don't want to expose vocab.hh