# # # patch "cmd_netsync.cc" # from [06d0925094e4543972b6e392c3d296373094cb06] # to [921f71670470523dc6fca1e86e5f1e22468528cb] # # patch "netsync.cc" # from [7d2cf5774d36b4fca9c1434f54f60a424f39f7db] # to [a6566f28082593258f45405edae952172fe33370] # # patch "network/connection_info.cc" # from [076b4c91cca8c4bb2a3aff04050fa19e936d9a86] # to [5edac2dd1159084bc7451cb7f2d733602772819e] # # patch "network/connection_info.hh" # from [4a6bf8a4ce7bcb2519ad1a993a8ab527e2ab92c7] # to [777e884cd05fa9559dd1c7306b31d10e0a3f0ab0] # # patch "vocab.hh" # from [925574290dd68029e94147dd05eb9e60ff247b79] # to [17ac4c8f007f5b46d0c34f5140942ac8c9f8ae75] # ============================================================ --- cmd_netsync.cc 06d0925094e4543972b6e392c3d296373094cb06 +++ cmd_netsync.cc 921f71670470523dc6fca1e86e5f1e22468528cb @@ -48,13 +48,14 @@ extract_client_connection_info(options & project_t & project, key_store & keys, lua_hooks & lua, + connection_type type, args_vector const & args, shared_conn_info & info, key_requiredness_flag key_requiredness = key_required) { if (opts.remote_stdio_host_given) { - netsync_connection_info::setup_from_uri(opts, project.db, lua, + netsync_connection_info::setup_from_uri(opts, project.db, lua, type, opts.remote_stdio_host, info); } else @@ -64,7 +65,7 @@ extract_client_connection_info(options & E(!opts.exclude_given, origin::user, F("cannot use --exclude in URL mode")); - netsync_connection_info::setup_from_uri(opts, project.db, lua, + netsync_connection_info::setup_from_uri(opts, project.db, lua, type, idx(args, 0), info); } else if (args.size() >= 2) @@ -77,7 +78,7 @@ extract_client_connection_info(options & vector exclude_patterns = opts.exclude_patterns; netsync_connection_info::setup_from_server_and_pattern(opts, project.db, - lua, server, + lua, type, server, include_patterns, exclude_patterns, info); @@ -87,7 +88,8 @@ extract_client_connection_info(options & // if no argument has been given and the --remote_stdio_host // option has been left out, try to load the database defaults // at least - netsync_connection_info::setup_default(opts, project.db, lua, info); + netsync_connection_info::setup_default(opts, project.db, + lua, type, info); } } @@ -126,9 +128,9 @@ CMD_AUTOMATE_NO_STDIO(remote_stdio, project_t project(db); shared_conn_info info; - extract_client_connection_info(app.opts, project, keys, app.lua, args, info); + extract_client_connection_info(app.opts, project, keys, app.lua, + automate_connection, args, info); - info->client.set_connection_type(netsync_connection_info::automate_connection); info->client.set_input_stream(std::cin); automate_ostream os(output, app.opts.automate_stdio_size); info->client.set_output_stream(os); @@ -224,7 +226,7 @@ CMD_AUTOMATE_NO_STDIO(remote, shared_conn_info info; extract_client_connection_info(app.opts, project, keys, app.lua, - args_vector(), info); + automate_connection, args_vector(), info); args_vector cleaned_args(args); std::vector > opts; @@ -254,7 +256,6 @@ CMD_AUTOMATE_NO_STDIO(remote, automate_ostream_demuxed os(output, std::cerr, app.opts.automate_stdio_size); - info->client.set_connection_type(netsync_connection_info::automate_connection); info->client.set_input_stream(ss); info->client.set_output_stream(os); @@ -279,7 +280,8 @@ CMD(push, "push", "", CMD_REF(network), project_t project(db); shared_conn_info info; - extract_client_connection_info(app.opts, project, keys, app.lua, args, info); + extract_client_connection_info(app.opts, project, keys, app.lua, + netsync_connection, args, info); run_netsync_protocol(app, app.opts, app.lua, project, keys, client_voice, source_role, info); @@ -298,7 +300,8 @@ CMD_AUTOMATE(push, N_("[ADDRESS[:PORTNUM project_t project(db); shared_conn_info info; - extract_client_connection_info(app.opts, project, keys, app.lua, args, info); + extract_client_connection_info(app.opts, project, keys, app.lua, + netsync_connection, args, info); run_netsync_protocol(app, app.opts, app.lua, project, keys, client_voice, source_role, info); @@ -320,8 +323,8 @@ CMD(pull, "pull", "", CMD_REF(network), maybe_workspace_updater updater(app, project); shared_conn_info info; - extract_client_connection_info(app.opts, project, keys, app.lua, args, info, - key_optional); + extract_client_connection_info(app.opts, project, keys, app.lua, + netsync_connection, args, info, key_optional); if (!keys.have_signing_key()) P(F("doing anonymous pull; use -kKEYNAME if you need authentication")); @@ -344,8 +347,8 @@ CMD_AUTOMATE(pull, N_("[ADDRESS[:PORTNUM project_t project(db); shared_conn_info info; - extract_client_connection_info(app.opts, project, keys, app.lua, args, - info, key_optional); + extract_client_connection_info(app.opts, project, keys, app.lua, + netsync_connection, args, info, key_optional); run_netsync_protocol(app, app.opts, app.lua, project, keys, client_voice, sink_role, info); @@ -367,7 +370,8 @@ CMD(sync, "sync", "", CMD_REF(network), maybe_workspace_updater updater(app, project); shared_conn_info info; - extract_client_connection_info(app.opts, project, keys, app.lua, args, info); + extract_client_connection_info(app.opts, project, keys, app.lua, + netsync_connection, args, info); if (app.opts.set_default && workspace::found) { @@ -394,7 +398,8 @@ CMD_AUTOMATE(sync, N_("[ADDRESS[:PORTNUM project_t project(db); shared_conn_info info; - extract_client_connection_info(app.opts, project, keys, app.lua, args, info); + extract_client_connection_info(app.opts, project, keys, app.lua, + netsync_connection, args, info); if (app.opts.set_default && workspace::found) { @@ -453,7 +458,7 @@ CMD(clone, "clone", "", CMD_REF(network) F("cannot use --exclude in URL mode")); netsync_connection_info::setup_from_uri(app.opts, project.db, app.lua, - server, info); + netsync_connection, server, info); if (args.size() == 2) workspace_arg = idx(args, 1); } @@ -462,8 +467,9 @@ CMD(clone, "clone", "", CMD_REF(network) vector include_patterns; include_patterns.push_back(idx(args, 1)); netsync_connection_info::setup_from_server_and_pattern(app.opts, project.db, - app.lua, server, - include_patterns, + app.lua, + netsync_connection, + server, include_patterns, app.opts.exclude_patterns, info); if (args.size() == 3) ============================================================ --- netsync.cc 7d2cf5774d36b4fca9c1434f54f60a424f39f7db +++ netsync.cc a6566f28082593258f45405edae952172fe33370 @@ -123,14 +123,14 @@ call_server(app_state & app, shared_ptr wrapped; switch (info->client.get_connection_type()) { - case netsync_connection_info::netsync_connection: + case netsync_connection: wrapped.reset(new netsync_session(sess.get(), app.opts, app.lua, project, keys, role, info->client.get_include_pattern(), info->client.get_exclude_pattern())); break; - case netsync_connection_info::automate_connection: + case automate_connection: wrapped.reset(new automate_session(app, sess.get(), &info->client.get_input_stream(), &info->client.get_output_stream())); ============================================================ --- network/connection_info.cc 076b4c91cca8c4bb2a3aff04050fa19e936d9a86 +++ network/connection_info.cc 5edac2dd1159084bc7451cb7f2d733602772819e @@ -35,7 +35,7 @@ netsync_connection_info::Client::Client( netsync_connection_info::Client::Client(database & d, options const & o) : connection_successful(false), use_argv(false), - connection_type(netsync_connection), + conn_type(netsync_connection), input_stream(0), output_stream(0), db(d), opts(o) @@ -275,16 +275,10 @@ netsync_connection_info::Client::get_uri return uri; } -void -netsync_connection_info::Client::set_connection_type(netsync_connection_info::conn_type type) -{ - connection_type = type; -} - -netsync_connection_info::conn_type +connection_type netsync_connection_info::Client::get_connection_type() const { - return connection_type; + return conn_type; } bool @@ -314,7 +308,7 @@ netsync_connection_info::Client::ensure_ E(!uri.resource.empty(), origin::user, F("connection resource is empty and no default value could be loaded")); - E(!include_pattern().empty(), origin::user, + E(conn_type != netsync_connection || !include_pattern().empty(), origin::user, F("branch pattern is empty and no default value could be loaded")); } @@ -360,9 +354,11 @@ netsync_connection_info::setup_default(o netsync_connection_info::setup_default(options const & opts, database & db, lua_hooks & lua, + connection_type type, shared_conn_info & info) { info.reset(new netsync_connection_info(db, opts)); + info->client.conn_type = type; info->client.ensure_completeness(); info->client.maybe_set_argv(lua); @@ -376,6 +372,7 @@ netsync_connection_info::setup_from_sync shared_conn_info & info) { info.reset(new netsync_connection_info(db, opts)); + info->client.conn_type = netsync_connection; info->client.set_raw_uri(request.address); @@ -418,10 +415,12 @@ netsync_connection_info::setup_from_uri( netsync_connection_info::setup_from_uri(options const & opts, database & db, lua_hooks & lua, + connection_type type, arg_type const & uri, shared_conn_info & info) { info.reset(new netsync_connection_info(db, opts)); + info->client.conn_type = type; info->client.set_raw_uri(uri()); @@ -448,12 +447,14 @@ netsync_connection_info::setup_from_serv netsync_connection_info::setup_from_server_and_pattern(options const & opts, database & db, lua_hooks & lua, + connection_type type, arg_type const & host, vector const & includes, vector const & excludes, shared_conn_info & info) { info.reset(new netsync_connection_info(db, opts)); + info->client.conn_type = type; info->client.set_raw_uri("mtn://" + host()); info->client.set_include_pattern(includes); @@ -471,6 +472,7 @@ netsync_connection_info::setup_for_serve { info.reset(new netsync_connection_info(db, opts)); info->server.addrs = opts.bind_uris; + info->client.conn_type = netsync_connection; if (opts.use_transport_auth) { ============================================================ --- network/connection_info.hh 4a6bf8a4ce7bcb2519ad1a993a8ab527e2ab92c7 +++ network/connection_info.hh 777e884cd05fa9559dd1c7306b31d10e0a3f0ab0 @@ -32,11 +32,6 @@ struct netsync_connection_info public: std::list addrs; } server; - enum conn_type - { - netsync_connection, - automate_connection - }; class Client { friend struct netsync_connection_info; @@ -50,7 +45,7 @@ struct netsync_connection_info globish include_pattern; globish exclude_pattern; - conn_type connection_type; + connection_type conn_type; std::istream * input_stream; automate_ostream * output_stream; @@ -64,6 +59,7 @@ struct netsync_connection_info void set_include_pattern(std::vector const & pat); void set_exclude_pattern(std::vector const & pat); void maybe_set_argv(lua_hooks & lua); + void ensure_completeness() const; public: @@ -77,10 +73,8 @@ struct netsync_connection_info uri_t get_uri() const; bool get_use_argv() const; std::vector get_argv() const; + connection_type get_connection_type() const; - void set_connection_type(conn_type type); - conn_type get_connection_type() const; - void set_connection_successful(); } client; @@ -88,6 +82,7 @@ struct netsync_connection_info setup_default(options const & opts, database & db, lua_hooks & lua, + connection_type type, shared_conn_info & info); static void @@ -101,6 +96,7 @@ struct netsync_connection_info setup_from_uri(options const & opts, database & db, lua_hooks & lua, + connection_type type, arg_type const & uri, shared_conn_info & info); @@ -108,6 +104,7 @@ struct netsync_connection_info setup_from_server_and_pattern(options const & opts, database & db, lua_hooks & lua, + connection_type type, arg_type const & host, std::vector const & includes, std::vector const & excludes, ============================================================ --- vocab.hh 925574290dd68029e94147dd05eb9e60ff247b79 +++ vocab.hh 17ac4c8f007f5b46d0c34f5140942ac8c9f8ae75 @@ -119,6 +119,13 @@ enum db_type unmanaged_db }; +// to distinguish the payload type of a sync +enum connection_type +{ + netsync_connection, + automate_connection +}; + static const std::string memory_db_identifier = ":memory:"; // do these belong here?