# # patch "annotate.cc" # from [0788e74979f9d92aee0bcb66e2ae403737675540] # to [c008c4473c682ce6914519ca99d4ae660963be7f] # # patch "format.cc" # from [7f4d767f35714c10227cf8d5bd3fba12d8992603] # to [214e2fce14624a431f086ea7c37ca6cabba6ab9c] # --- annotate.cc +++ annotate.cc @@ -191,8 +191,7 @@ public: annotate_formatter(app_state &app, std::set::const_iterator startrev, - std::set::const_iterator endrev, - const std::string &format_string); + std::set::const_iterator endrev); std::string format (const revision_id &rev, const std::string &line) const { @@ -211,22 +210,32 @@ annotate_formatter::annotate_formatter(app_state &app, std::set::const_iterator startrev, - std::set::const_iterator endrev, - const std::string &format_string) -{ + std::set::const_iterator endrev) +{ + std::ostringstream res_stream; + PrintFormatter pf(res_stream, app, app.format_string); + + size_t max_annotate_len = 0; std::set::const_iterator i; i = startrev; while (i != endrev) { - std::ostringstream res_stream; + pf.apply(*i); - { - FormatFunc fmt(res_stream, app); - fmt(*i); - } + size_t rs = res_stream.str().size(); + max_annotate_len = (rs > max_annotate_len) ? rs : max_annotate_len; + desc.insert(std::make_pair(*i, res_stream.str())); res_stream.str(""); i++; } + + // justify the annotate strings + std::map::iterator j = desc.begin(); + while (j != desc.end()) { + size_t extra_spaces = max_annotate_len - j->second.size(); + j->second = std::string(extra_spaces, ' ') + j->second; + j++; + } } @@ -582,8 +591,6 @@ W(F("annotate was unable to assign blame to some lines. This is a bug.\n")); } - external fmtstr; - utf8_to_system(app.format_string, fmtstr); - boost::shared_ptr frmt(new annotate_formatter(app, acp->begin_revisions(), acp->end_revisions(), fmtstr())); + boost::shared_ptr frmt(new annotate_formatter(app, acp->begin_revisions(), acp->end_revisions())); acp->write_annotations(frmt, std::cout); } --- format.cc +++ format.cc @@ -147,8 +147,10 @@ std::string::size_type l = std::string::npos; if (from_start) l = tv().find_first_of(sep); - if (from_end) + if (from_end) { f = tv().find_last_of(sep); + if (f == std::string::npos) f = 0; + } out << tv().substr(f, l); return; }