# # patch "ChangeLog" # from [5761c2caa715f2af4b1c74862ba2678668614393] # to [8be0e2fbf11486c2bf90145ed2a8520dbb5eaa5a] # # patch "commands.cc" # from [3e8ad65cb96a478855b3b9b756f498eb23269f3e] # to [e16a82f8cdaa854ef2ce9f1a929de9cd24e0fc52] # # patch "monotone.cc" # from [0d67d084ddfc9f143006b339c925a5fe86dce4c5] # to [c16834cd4c67d32acc773d866596d4a41d26a035] # # patch "options.hh" # from [4c2651f57f221b2224b9a9dca93a4b1e9c99b281] # to [31fd46bd9a90626226c5d382c34652bfc47b2323] # # patch "sanity.cc" # from [87f3bbf0785ac602b26fc8f36ff4efdf475db220] # to [2a3933f0a61318d32c1f2061fcadd106761fce87] # # patch "sanity.hh" # from [327d38c4b4e0a26e734861ef263ee7c365f5ceb5] # to [2fea4a99d4e7e8b108c8168d974243c6fcb3212a] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,16 @@ +2005-05-21 Richard Levitte + + * commands.cc (log_certs): Add two arguments; a separator string + to be used in front of the second to last cert for multi-valued + cert types, a bool to say if each cert should be ended with a + newline. Overload with shortcuts. + (CMD(log)): Use the --brief option and implement it using the + shortcut variants of log_certs. + * monotone.cc, options.hh: Add the --brief option (OPT_BRIEF + internally). + * sanity.cc, sanity.hh (struct sanity): Add the member variable + and function to hold and set the brief flag. + 2005-05-19 Derek Scherger * commands.cc (checkout): rearrange to use --revision option --- commands.cc +++ commands.cc @@ -3393,10 +3393,16 @@ } static void -log_certs(app_state & app, revision_id id, cert_name name, string label, bool multiline) +log_certs(app_state & app, revision_id id, cert_name name, + string label, string separator, + bool multiline, bool newline) { vector< revision > certs; + bool first = true; + if (multiline) + newline = true; + app.db.get_revision_certs(id, name, certs); erase_bogus_certs(certs, app); for (vector< revision >::const_iterator i = certs.begin(); @@ -3404,16 +3410,42 @@ { cert_value tv; decode_base64(i->inner().value, tv); - cout << label; - if (multiline) - cout << endl << endl << tv << endl; + if (first) + cout << label; else - cout << tv << endl; - } + cout << separator; + + if (multiline) + { + cout << endl << endl << tv; + if (newline) + cout << endl; + } + else + { + cout << tv; + if (newline) + cout << endl; + } + + first = false; + } } +static void +log_certs(app_state & app, revision_id id, cert_name name, string label, bool multiline) +{ + log_certs(app, id, name, label, label, multiline, true); +} +static void +log_certs(app_state & app, revision_id id, cert_name name) +{ + log_certs(app, id, name, " ", ",", false, false); +} + + CMD(annotate, "informative", "PATH", "print annotated copy of the file from REVISION", OPT_REVISION) @@ -3452,7 +3484,7 @@ CMD(log, "informative", "[file] [--revision=REVISION [--revision=REVISION [...]]]", "print history in reverse order (filtering by 'file'). If one or more revisions\n" "are given, use them as a starting point.", - OPT_DEPTH % OPT_REVISION) + OPT_DEPTH % OPT_REVISION % OPT_BRIEF) { file_path file; @@ -3560,28 +3592,39 @@ if (print_this) { - cout << "-----------------------------------------------------------------" - << endl; - cout << "Revision: " << rid << endl; + if (global_sanity.brief) + { + cout << rid; + log_certs(app, rid, author_name); + log_certs(app, rid, date_name); + log_certs(app, rid, branch_name); + cout << endl; + } + else + { + cout << "-----------------------------------------------------------------" + << endl; + cout << "Revision: " << rid << endl; - for (set::const_iterator anc = ancestors.begin(); - anc != ancestors.end(); ++anc) - cout << "Ancestor: " << *anc << endl; + for (set::const_iterator anc = ancestors.begin(); + anc != ancestors.end(); ++anc) + cout << "Ancestor: " << *anc << endl; - log_certs(app, rid, author_name, "Author: ", false); - log_certs(app, rid, date_name, "Date: ", false); - log_certs(app, rid, branch_name, "Branch: ", false); - log_certs(app, rid, tag_name, "Tag: ", false); + log_certs(app, rid, author_name, "Author: ", false); + log_certs(app, rid, date_name, "Date: ", false); + log_certs(app, rid, branch_name, "Branch: ", false); + log_certs(app, rid, tag_name, "Tag: ", false); - if (! csum.empty) - { - cout << endl; - csum.print(cout, 70); - cout << endl; - } + if (! csum.empty) + { + cout << endl; + csum.print(cout, 70); + cout << endl; + } - log_certs(app, rid, changelog_name, "ChangeLog: ", true); - log_certs(app, rid, comment_name, "Comments: ", true); + log_certs(app, rid, changelog_name, "ChangeLog: ", true); + log_certs(app, rid, comment_name, "Comments: ", true); + } if (depth > 0) { --- monotone.cc +++ monotone.cc @@ -49,6 +49,7 @@ {"author", 0, POPT_ARG_STRING, &argstr, OPT_AUTHOR, "override author for commit", NULL}, {"depth", 0, POPT_ARG_LONG, &arglong, OPT_DEPTH, "limit the log output to the given number of entries", NULL}, {"pid-file", 0, POPT_ARG_STRING, &argstr, OPT_PIDFILE, "record process id of server", NULL}, + {"brief", 0, POPT_ARG_NONE, NULL, OPT_BRIEF, "print a brief version of the normal output", NULL}, { NULL, 0, 0, NULL, 0, NULL, NULL } }; @@ -354,6 +355,10 @@ app.set_depth(arglong); break; + case OPT_BRIEF: + global_sanity.set_brief(); + break; + case OPT_PIDFILE: app.set_pidfile(absolutify(tilde_expand(string(argstr)))); break; --- options.hh +++ options.hh @@ -30,3 +30,4 @@ #define OPT_ALL_FILES 21 #define OPT_PIDFILE 22 #define OPT_MSGFILE 23 +#define OPT_BRIEF 24 --- sanity.cc +++ sanity.cc @@ -74,6 +74,12 @@ ui.inform((*i) + "\n"); } +void +sanity::set_brief() +{ + brief = true; +} + void sanity::set_quiet() { --- sanity.hh +++ sanity.hh @@ -42,10 +42,12 @@ ~sanity(); void dump_buffer(); void set_debug(); + void set_brief(); void set_quiet(); void set_relaxed(bool rel); bool debug; + bool brief; bool quiet; bool relaxed; boost::circular_buffer logbuf;