# # patch "ChangeLog" # from [e6069e74f7283fc93e85e79ef1fad177e6b0581e] # to [6f8bc7185c33a2fe7498d78fb4881be029f5cded] # # patch "commands.cc" # from [755e27d10e9737caf42ab7f9243b56971a5f2d36] # to [b21e0e7787542f5ba176db2284bcb326a5020a9d] # # patch "diff_patch.cc" # from [022e125cb1265ea8d0a484289b952587060053cc] # to [7207c21edd6d0fec628ea9d263ad4ca2c037e6d5] # # patch "ui.cc" # from [81f19fda85b379e6e32241b99c9355fa8d0ff186] # to [4eb91893b9ade75c61d42b1743bd60d92fac9ca3] # # patch "ui.hh" # from [582fb0aff44602a587da60f79754f7d01e11a187] # to [daec74ed24338ff3ee7eda12f14e7deb7aeb6473] # =============================================== --- ChangeLog e6069e74f7283fc93e85e79ef1fad177e6b0581e +++ ChangeLog 6f8bc7185c33a2fe7498d78fb4881be029f5cded @@ -1,3 +1,13 @@ +2005-07-23 Nathaniel Smith + + * ui.{hh,cc} (guess_terminal_width): New function. + (tick_write_dot::chars_on_line): Make unsigned to quiet gcc warning. + (tick_write_dot::write_ticks): Use guess_terminal_width. + * commands.cc (dump_diffs): Take full responsibility for printing + === lines, and use guess_terminal_width. + * diff_patch.cc (make_diff): Don't print === lines. + (unidiff_append_test): Adjust accordingly. + 2005-07-22 Nathaniel Smith * monotone.texi (Committing Work): Remove discussion of manifests. =============================================== --- commands.cc 755e27d10e9737caf42ab7f9243b56971a5f2d36 +++ commands.cc b21e0e7787542f5ba176db2284bcb326a5020a9d @@ -2570,10 +2570,11 @@ bool new_is_archived, diff_type type) { - + std::string patch_sep = std::string(guess_terminal_width(), '='); for (change_set::delta_map::const_iterator i = deltas.begin(); i != deltas.end(); ++i) { + cout << patch_sep << "\n"; if (null_id(delta_entry_src(i))) { data unpacked; @@ -2598,7 +2599,6 @@ split_into_lines(unpacked(), lines); if (! lines.empty()) { - cout << "===============================================\n"; cout << (F("--- %s\t%s\n") % delta_entry_path(i) % delta_entry_src(i)) << (F("+++ %s\t%s\n") % delta_entry_path(i) % delta_entry_dst(i)) << (F("@@ -0,0 +1,%d @@\n") % lines.size()); =============================================== --- diff_patch.cc 022e125cb1265ea8d0a484289b952587060053cc +++ diff_patch.cc 7207c21edd6d0fec628ea9d263ad4ca2c037e6d5 @@ -1112,7 +1112,6 @@ { case unified_diff: { - ost << "===============================================" << endl; ost << "--- " << filename1 << "\t" << id1 << endl; ost << "+++ " << filename2 << "\t" << id2 << endl; @@ -1122,7 +1121,6 @@ } case context_diff: { - ost << "===============================================" << endl; ost << "*** " << filename1 << "\t" << id1 << endl; ost << "--- " << filename2 << "\t" << id2 << endl; @@ -1205,8 +1203,7 @@ + "}\n" + "\n"); - string ud(string("===============================================\n") - + "--- hello.c\t0123456789abcdef0123456789abcdef01234567\n" + string ud(string("--- hello.c\t0123456789abcdef0123456789abcdef01234567\n" + "+++ hello.c\tabcdef0123456789abcdef0123456789abcdef01\n" + "@@ -9,3 +9,9 @@\n" + " {\n" =============================================== --- ui.cc 81f19fda85b379e6e32241b99c9355fa8d0ff186 +++ ui.cc 4eb91893b9ade75c61d42b1743bd60d92fac9ca3 @@ -223,7 +223,7 @@ > (old->second / i->second->mod))) { chars_on_line += i->second->shortname.size(); - if (chars_on_line > 72) + if (chars_on_line > guess_terminal_width()) { chars_on_line = tickline_prefix.size() + i->second->shortname.size(); tickline2 += "\n" + tickline_prefix; @@ -356,3 +356,13 @@ clog << sanitize(prefixedLine) << endl; clog.flush(); } + +unsigned int +guess_terminal_width() +{ + unsigned int w = terminal_width(); + if (!w) + w = 72; + return w; +} + =============================================== --- ui.hh 582fb0aff44602a587da60f79754f7d01e11a187 +++ ui.hh daec74ed24338ff3ee7eda12f14e7deb7aeb6473 @@ -60,7 +60,7 @@ void clear_line(); private: std::map last_ticks; - int chars_on_line; + unsigned int chars_on_line; }; struct tick_write_nothing : virtual public tick_writer @@ -103,5 +103,8 @@ extern struct user_interface ui; +// like platform.hh's "terminal_width", but always returns a sensible value +// (even if there is no terminal) +unsigned int guess_terminal_width(); #endif // __UI_HH__