# # # patch "cmd_automate.cc" # from [ca222967f517eaa22e4793d359beab1dfe7ac92b] # to [9e92aa7935f1b8a96d871a8503931c8ba00c5040] # # patch "cmd_netsync.cc" # from [c71251830cfe3887c8cc5185b2b06491407d84b8] # to [f3cf1b10c6d49b1438d459f4f35eea59b57de5c2] # # patch "constants.hh" # from [ff5b7650bdf8db3a6a6811f5ac14c43cf3db5ffa] # to [772e902f840ba1ac694e5d11f7f4befccb13ebbf] # # patch "options.hh" # from [639934070e6a7ef8e526c75be49cf17923535242] # to [e3783797c78b59fa4679c2a417bdb59ef19b60e3] # # patch "options_list.hh" # from [ef73b9b77442cf2ccbccf1d172fb8de0a7eedc3a] # to [b549313cdd98c32cb903c9ec47b12d4dafbd0045] # ============================================================ --- cmd_automate.cc ca222967f517eaa22e4793d359beab1dfe7ac92b +++ cmd_automate.cc 9e92aa7935f1b8a96d871a8503931c8ba00c5040 @@ -19,6 +19,7 @@ #include "automate_ostream.hh" #include "automate_reader.hh" #include "automate_stdio_helpers.hh" +#include "constants.hh" #include "options_applicator.hh" #include "ui.hh" #include "lua.hh" @@ -237,7 +238,10 @@ CMD_AUTOMATE_NO_STDIO(stdio, "", // immediately if a version discrepancy exists db.ensure_open(); - automate_ostream os(output, app.opts.automate_stdio_size); + long packet_size = constants::default_stdio_packet_size; + if (app.opts.automate_stdio_size_given) + packet_size = app.opts.automate_stdio_size; + automate_ostream os(output, packet_size); automate_reader ar(std::cin); std::vector > headers; ============================================================ --- cmd_netsync.cc c71251830cfe3887c8cc5185b2b06491407d84b8 +++ cmd_netsync.cc f3cf1b10c6d49b1438d459f4f35eea59b57de5c2 @@ -132,7 +132,10 @@ CMD_AUTOMATE_NO_STDIO(remote_stdio, automate_connection, args, info); info->client.set_input_stream(std::cin); - automate_ostream os(output, app.opts.automate_stdio_size); + long packet_size = constants::default_stdio_packet_size; + if (app.opts.automate_stdio_size_given) + packet_size = app.opts.automate_stdio_size; + automate_ostream os(output, packet_size); info->client.set_output_stream(os); run_netsync_protocol(app, app.opts, app.lua, project, keys, @@ -254,7 +257,10 @@ CMD_AUTOMATE_NO_STDIO(remote, L(FL("stdio input: %s") % ss.str()); - automate_ostream_demuxed os(output, std::cerr, app.opts.automate_stdio_size); + long packet_size = constants::default_stdio_packet_size; + if (app.opts.automate_stdio_size_given) + packet_size = app.opts.automate_stdio_size; + automate_ostream_demuxed os(output, std::cerr, packet_size); info->client.set_input_stream(ss); info->client.set_output_stream(os); ============================================================ --- constants.hh ff5b7650bdf8db3a6a6811f5ac14c43cf3db5ffa +++ constants.hh 772e902f840ba1ac694e5d11f7f4befccb13ebbf @@ -38,6 +38,9 @@ namespace constants // number of characters in a raw epoch std::size_t const epochlen_bytes = idlen_bytes; + // default packet size for 'automate stdio' + std::size_t const default_stdio_packet_size = 32768; + // number of seconds in window, in which to consider CVS commits equivalent // if they have otherwise compatible contents (author, changelog) std::time_t const cvs_window = 60 * 5; ============================================================ --- options.hh 639934070e6a7ef8e526c75be49cf17923535242 +++ options.hh e3783797c78b59fa4679c2a417bdb59ef19b60e3 @@ -18,11 +18,35 @@ */ #include +#include #include "option.hh" #include "paths.hh" #include "dates.hh" +#include "lexical_cast.hh" + +template +class restricted_long +{ + long value; +public: + restricted_long() + { + if (-1 < low) + value = -1; + else + value = low - 1; + } + restricted_long(std::string const & x, origin::type o) + { + value = boost::lexical_cast(x); + if (value < low) + throw option::bad_arg_internal((F("must not be less than %d") % low).str()); + } + operator long() const { return value; } +}; + struct options { options(); ============================================================ --- options_list.hh ef73b9b77442cf2ccbccf1d172fb8de0a7eedc3a +++ options_list.hh b549313cdd98c32cb903c9ec47b12d4dafbd0045 @@ -180,15 +180,9 @@ SIMPLE_OPTION(author, "author", utf8, ge SIMPLE_OPTION(author, "author", utf8, gettext_noop("override author for commit")) -OPT(automate_stdio_size, "automate-stdio-size", size_t, 32768, - gettext_noop("block size in bytes for \"automate stdio\" output")) -#ifdef option_bodies -{ - automate_stdio_size = boost::lexical_cast(arg); - if (automate_stdio_size <= 0) - throw bad_arg_internal(F("cannot be zero or negative").str()); -} -#endif +SIMPLE_OPTION(automate_stdio_size, "automate-stdio-size", + restricted_long<1>, + gettext_noop("block size in bytes for \"automate stdio\" output")) SIMPLE_OPTION(auto_update, "update/no-update", bool, gettext_noop("automatically update the workspace, if it is clean and the base " @@ -299,15 +293,8 @@ GLOBAL_SIMPLE_OPTION(debug, "debug", boo GLOBAL_SIMPLE_OPTION(debug, "debug", bool, gettext_noop("print debug log to stderr while running")) -OPT(depth, "depth", long, -1, - gettext_noop("limit the number of levels of directories to descend")) -#ifdef option_bodies -{ - depth = boost::lexical_cast(arg); - if (depth < 0) - throw bad_arg_internal(F("cannot be negative").str()); -} -#endif +SIMPLE_OPTION(depth, "depth", restricted_long<0>, + gettext_noop("limit the number of levels of directories to descend")) OPTSET(diff_options) @@ -424,15 +411,8 @@ SIMPLE_OPTION(keys_to_push, "key-to-push SIMPLE_OPTION(keys_to_push, "key-to-push", std::vector, gettext_noop("push the specified key even if it hasn't signed anything")) -OPT(last, "last", long, -1, - gettext_noop("limit log output to the last number of entries")) -#ifdef option_bodies -{ - last = boost::lexical_cast(arg); - if (last <= 0) - throw bad_arg_internal(F("cannot be zero or negative").str()); -} -#endif +SIMPLE_OPTION(last, "last", restricted_long<1>, + gettext_noop("limit log output to the last number of entries")) GLOBAL_SIMPLE_OPTION(log, "log", system_path, gettext_noop("file to write the log to")) @@ -449,15 +429,8 @@ SIMPLE_OPTION(missing, "missing", bool, SIMPLE_OPTION(missing, "missing", bool, gettext_noop("perform the operations for files missing from workspace")) -OPT(next, "next", long, -1, - gettext_noop("limit log output to the next number of entries")) -#ifdef option_bodies -{ - next = boost::lexical_cast(arg); - if (next <= 0) - throw bad_arg_internal(F("cannot be zero or negative").str()); -} -#endif +SIMPLE_OPTION(next, "next", restricted_long<1>, + gettext_noop("limit log output to the next number of entries")) SIMPLE_OPTION(no_files, "no-files/files", bool, gettext_noop("exclude files when printing logs"))