# # # add_file "date_format.hh" # content [e77f30981669d8a03057c9bc90eeb4c74c575a44] # # patch "Makefile.am" # from [da1489a4f54bbf32c2f70524bb2daab4a939c768] # to [f410e67edefbe9e28d3eb1897d146d2c823783fe] # # patch "annotate.cc" # from [148031d40f893f9a31c9bcc5644e12e5601d5255] # to [c06a35d087b06cd27feb895fea87642e56718084] # # patch "cmd_diff_log.cc" # from [82ddae0967fe4ca59141c862161507dbd88cfccd] # to [cdd677aa2c5cf73d74ce004aae86d05de104d316] # # patch "cmd_ws_commit.cc" # from [0aa57136e2df3ccc82bbd097da2cd03a0d3e2275] # to [88a6fef7b50e4a062e2fa05c6a96f159aac66892] # # patch "project.cc" # from [da20b004d233b9bdace2efa9bcaaa9e861bd3e87] # to [19401ad3cb96a7eb7a62d139b06ad6c5216340c6] # ============================================================ --- date_format.hh e77f30981669d8a03057c9bc90eeb4c74c575a44 +++ date_format.hh e77f30981669d8a03057c9bc90eeb4c74c575a44 @@ -0,0 +1,42 @@ +// Copyright (C) 2005 and later by various people +// see monotone commit logs for details and authors +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. + +#ifndef __DATE_FORMAT_HH__ +#define __DATE_FORMAT_HH__ + +#include "options.hh" +#include "lua_hooks.hh" +#include "vocab.hh" + +inline std::string +get_date_format(options const & opts, + lua_hooks & lua, + date_format_spec spec) +{ + std::string date_fmt; + if (opts.format_dates) + { + if (!opts.date_fmt.empty()) + date_fmt = opts.date_fmt; + else + lua.hook_get_date_format_spec(spec, date_fmt); + } + return date_fmt; +} + +#endif + +// Local Variables: +// mode: C++ +// fill-column: 76 +// c-file-style: "gnu" +// indent-tabs-mode: nil +// End: +// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s: ============================================================ --- Makefile.am da1489a4f54bbf32c2f70524bb2daab4a939c768 +++ Makefile.am f410e67edefbe9e28d3eb1897d146d2c823783fe @@ -107,7 +107,7 @@ MOST_SOURCES = \ rev_height.cc rev_height.hh \ rev_output.cc rev_output.hh \ asciik.cc asciik.hh \ - dates.cc dates.hh \ + dates.cc dates.hh date_format.hh \ \ lru_writeback_cache.hh hybrid_map.hh lazy_rng.hh \ \ ============================================================ --- annotate.cc 148031d40f893f9a31c9bcc5644e12e5601d5255 +++ annotate.cc c06a35d087b06cd27feb895fea87642e56718084 @@ -21,6 +21,7 @@ #include "constants.hh" #include "cset.hh" #include "database.hh" +#include "date_format.hh" #include "interner.hh" #include "lcs.hh" #include "platform.hh" @@ -399,14 +400,7 @@ annotate_context::build_revisions_to_ann } size_t max_note_length = 0; - string date_fmt; - if (app.opts.format_dates) - { - if (!app.opts.date_fmt.empty()) - date_fmt = app.opts.date_fmt; - else - app.lua.hook_get_date_format_spec(date_short, date_fmt); - } + string date_fmt = get_date_format(app.opts, app.lua, date_short); // build revision -> annotation string mapping for (set::const_iterator i = seen.begin(); ============================================================ --- cmd_diff_log.cc 82ddae0967fe4ca59141c862161507dbd88cfccd +++ cmd_diff_log.cc cdd677aa2c5cf73d74ce004aae86d05de104d316 @@ -17,6 +17,7 @@ #include "asciik.hh" #include "charset.hh" #include "cmd.hh" +#include "date_format.hh" #include "diff_output.hh" #include "file_io.hh" #include "parallel_iter.hh" @@ -559,14 +560,7 @@ CMD(log, "log", "", CMD_REF(informative) database db(app); project_t project(db); - string date_fmt; - if (app.opts.format_dates) - { - if (!app.opts.date_fmt.empty()) - date_fmt = app.opts.date_fmt; - else - app.lua.hook_get_date_format_spec(date_time_long, date_fmt); - } + string date_fmt = get_date_format(app.opts, app.lua, date_time_long); long last = app.opts.last; long next = app.opts.next; ============================================================ --- cmd_ws_commit.cc 0aa57136e2df3ccc82bbd097da2cd03a0d3e2275 +++ cmd_ws_commit.cc 88a6fef7b50e4a062e2fa05c6a96f159aac66892 @@ -32,6 +32,7 @@ #include "maybe_workspace_updater.hh" #include "simplestring_xform.hh" #include "database.hh" +#include "date_format.hh" #include "roster.hh" #include "rev_output.hh" #include "vocab_cast.hh" @@ -850,14 +851,7 @@ CMD(status, "status", "", CMD_REF(inform project_t project(db); workspace work(app); - string date_fmt; - if (app.opts.format_dates) - { - if (!app.opts.date_fmt.empty()) - date_fmt = app.opts.date_fmt; - else - app.lua.hook_get_date_format_spec(date_time_long, date_fmt); - } + string date_fmt = get_date_format(app.opts, app.lua, date_time_long); if (!date_fmt_valid(date_fmt)) W(F("date format '%s' cannot be used for commit") % date_fmt); @@ -1431,14 +1425,7 @@ void perform_commit(app_state & app, temp_node_id_source nis; cset excluded; - string date_fmt; - if (app.opts.format_dates) - { - if (!app.opts.date_fmt.empty()) - date_fmt = app.opts.date_fmt; - else - app.lua.hook_get_date_format_spec(date_time_long, date_fmt); - } + string date_fmt = get_date_format(app.opts, app.lua, date_time_long); work.get_parent_rosters(db, old_rosters); work.get_current_roster_shape(db, nis, new_roster); ============================================================ --- project.cc da20b004d233b9bdace2efa9bcaaa9e861bd3e87 +++ project.cc 19401ad3cb96a7eb7a62d139b06ad6c5216340c6 @@ -12,6 +12,7 @@ #include "cert.hh" #include "database.hh" +#include "date_format.hh" #include "project.hh" #include "revision.hh" #include "transforms.hh" @@ -672,14 +673,7 @@ describe_revision(options const & opts, description += encode_hexenc(id.inner()(), id.inner().made_from); - string date_fmt; - if (opts.format_dates) - { - if (!opts.date_fmt.empty()) - date_fmt = opts.date_fmt; - else - lua.hook_get_date_format_spec(date_time_short, date_fmt); - } + string date_fmt = get_date_format(opts, lua, date_time_short); // append authors and date of this revision vector certs;