#
#
# patch "ChangeLog"
# from [3a7eb0936219c11e6df407f163b0472780079637]
# to [7688a652a821b0f777934d3dcbb2b67c964eac0e]
#
# patch "app_state.cc"
# from [065def7a145f069635bcbf6270a4ec5e2038d096]
# to [19b9781db8070f5278aed5a71e9ceab139a85037]
#
# patch "app_state.hh"
# from [b52ed48ef2fe80bcc7f5290b4f95d8b33165d9c3]
# to [7eac59cda812029f862c9965272f10242c5e0f21]
#
# patch "monotone.cc"
# from [af5584575bd8cf33478f05f3d584e74badce7e34]
# to [47ac3dcbe654fb57adb466f22b3f9193ee6a9bad]
#
# patch "ui.cc"
# from [1403ede5802e182f7cad5acf236514416d18c05a]
# to [b944f8c34e63c7c9e44e06c347add0b9ac511680]
#
# patch "ui.hh"
# from [5a1e338407beeda0b373e5296d9106d4a6d9f35f]
# to [54e338a229263f639a30d54e6695bcb1d99b7d6a]
#
============================================================
--- ChangeLog 3a7eb0936219c11e6df407f163b0472780079637
+++ ChangeLog 7688a652a821b0f777934d3dcbb2b67c964eac0e
@@ -1,3 +1,11 @@
+2006-04-05 Nathaniel Smith
+
+ * ui.{cc,hh}: Use the prog_name in output.
+ * app_state.cc (app_state::prog_name): Change default to 'mtn'.
+ Set the global ui object's prog_name whenever our prog_name is
+ set.
+ * monotone.cc (cpp_main): Use the new prog_name setter.
+
2006-04-04 Nathaniel Smith
* roster.hh (class roster_t): Add massive comment about roster_t's
============================================================
--- app_state.cc 065def7a145f069635bcbf6270a4ec5e2038d096
+++ app_state.cc 19b9781db8070f5278aed5a71e9ceab139a85037
@@ -8,6 +8,7 @@
#include
#include
+#include "ui.hh"
#include "app_state.hh"
#include "database.hh"
#include "file_io.hh"
@@ -36,12 +37,12 @@
depth(-1), last(-1), next(-1), diff_format(unified_diff), diff_args_provided(false),
use_lca(false), execute(false), bind_address(""), bind_port(""),
missing(false), unknown(false),
- confdir(get_default_confdir()), have_set_key_dir(false), no_files(false),
- prog_name("monotone")
+ confdir(get_default_confdir()), have_set_key_dir(false), no_files(false)
{
db.set_app(this);
lua.set_app(this);
keys.set_key_dir(confdir / "keys");
+ set_prog_name(utf8(std::string("mtn")));
}
app_state::~app_state()
@@ -472,6 +473,13 @@
}
void
+app_state::set_prog_name(utf8 const & name)
+{
+ prog_name = name;
+ ui.set_prog_name(name());
+}
+
+void
app_state::add_rcfile(utf8 const & filename)
{
extra_rcfiles.push_back(filename);
============================================================
--- app_state.hh b52ed48ef2fe80bcc7f5290b4f95d8b33165d9c3
+++ app_state.hh 7eac59cda812029f862c9965272f10242c5e0f21
@@ -75,7 +75,6 @@
bool have_set_key_dir;
std::set attrs_to_drop;
bool no_files;
- std::string prog_name;
std::map explicit_option_map; // set if the value of the flag was explicitly given on the command line
void set_is_explicit_option (int option_id);
@@ -127,6 +126,7 @@
void set_diff_args(utf8 const & args);
void add_key_to_push(utf8 const & key);
void set_recursive(bool r = true);
+ void set_prog_name(utf8 const & prog_name);
void set_stdhooks(bool b);
void set_rcfiles(bool b);
@@ -139,6 +139,10 @@
explicit app_state();
~app_state();
+ // only use set_prog_name to set this; changes need to be propagated to the
+ // global ui object
+ utf8 prog_name;
+
private:
void load_rcfiles();
void read_options();
============================================================
--- monotone.cc af5584575bd8cf33478f05f3d584e74badce7e34
+++ monotone.cc 47ac3dcbe654fb57adb466f22b3f9193ee6a9bad
@@ -278,7 +278,7 @@
save_initial_path();
utf8_argv uv(argc, argv);
- string prog_name(uv.argv[0]);
+ utf8 prog_name(uv.argv[0]);
// prepare for arg parsing
@@ -302,7 +302,7 @@
{
app_state app;
- app.prog_name = prog_name;
+ app.set_prog_name(prog_name);
while ((opt = poptGetNextOpt(ctx())) > 0)
{
============================================================
--- ui.cc 1403ede5802e182f7cad5acf236514416d18c05a
+++ ui.cc b944f8c34e63c7c9e44e06c347add0b9ac511680
@@ -169,7 +169,7 @@
if (write_tickline1)
{
// Reissue the titles if the widths have changed.
- tickline1 = "monotone: ";
+ tickline1 = ui.output_prefix();
for (size_t i = 0; i < tick_widths.size(); ++i)
{
if (i != 0)
@@ -181,7 +181,7 @@
}
// Always reissue the counts.
- string tickline2 = "monotone: ";
+ string tickline2 = ui.output_prefix();
for (size_t i = 0; i < tick_widths.size(); ++i)
{
if (i != 0)
@@ -240,7 +240,7 @@
void tick_write_dot::write_ticks()
{
- static const string tickline_prefix = "monotone: ";
+ static const string tickline_prefix = ui.output_prefix();
string tickline1, tickline2;
bool first_tick = true;
@@ -251,7 +251,7 @@
}
else
{
- tickline1 = "monotone: ticks: ";
+ tickline1 = ui.output_prefix() + "ticks: ";
tickline2 = "\n" + tickline_prefix;
chars_on_line = tickline_prefix.size();
}
@@ -368,12 +368,24 @@
{
inform(F("fatal: %s\n"
"this is almost certainly a bug in monotone.\n"
- "please send this error message, the output of 'monotone --full-version',\n"
+ "please send this error message, the output of '%s --full-version',\n"
"and a description of what you were doing to %s.\n")
- % fatal % PACKAGE_BUGREPORT);
+ % fatal % prog_name % PACKAGE_BUGREPORT);
}
+void
+user_interface::set_prog_name(std::string const & name)
+{
+ prog_name = name;
+}
+std::string
+user_interface::output_prefix()
+{
+ I(!prog_name.empty());
+ return prog_name + ": ";
+}
+
static inline string
sanitize(string const & line)
{
@@ -419,7 +431,7 @@
user_interface::inform(string const & line)
{
string prefixedLine;
- prefix_lines_with(_("monotone: "), line, prefixedLine);
+ prefix_lines_with(output_prefix(), line, prefixedLine);
ensure_clean_line();
clog << sanitize(prefixedLine) << endl;
clog.flush();
============================================================
--- ui.hh 5a1e338407beeda0b373e5296d9106d4a6d9f35f
+++ ui.hh 54e338a229263f639a30d54e6695bcb1d99b7d6a
@@ -93,6 +93,9 @@
void ensure_clean_line();
void redirect_log_to(system_path const & filename);
+ void set_prog_name(std::string const & name);
+ std::string output_prefix();
+
private:
std::set issued_warnings;
@@ -104,6 +107,8 @@
void write_ticks();
std::string tick_trailer;
+ std::string prog_name;
+
friend struct tick_write_dot;
friend struct tick_write_count;
friend struct ticker;