# # # delete "tests/netsync_dry_run" # # delete "tests/netsync_dry_run/__driver__.lua" # # patch "cmd_netsync.cc" # from [08012b1b75787b9ee18f0f60f10140d6e74aa06f] # to [f3cf1b10c6d49b1438d459f4f35eea59b57de5c2] # # patch "netsync.cc" # from [7e2ab1d800ce5a89fff62b23cefd1fb86cae13a0] # to [3640dd6b17a9a3e32f2766391d23a19a3e82aa3a] # # patch "network/connection_info.cc" # from [d03280d9dd87adce8b7b0bebf244878661d5ae6e] # to [ca442d99d973be6e4b5d6cecdd986b419896c389] # # patch "network/connection_info.hh" # from [181811d9adbba91506779f28461d29a46a40f2a1] # to [2578ebe8394cf7611bc4db06fce0f6917a390f67] # # patch "network/netsync_session.cc" # from [e3b98a67f8eba6168d692d6a29ffa66d4db2f796] # to [1ebe5e1a734cd672fdeb29705edefe6f85a2c125] # # patch "network/netsync_session.hh" # from [e5483827d8db0964dabed6565fddf1713f701a7d] # to [227867a6d5efdac111d46e129c660fba1c327b4f] # # patch "network/session.cc" # from [04f99fb3516968474cde97892d9b219ea0d5505e] # to [30e79173fce3cd35666e1f52393fa1736cc9b01e] # # patch "refiner.cc" # from [2de8131df2595d5bcff5efe133ca1f768006d38f] # to [e631259ef17957cc2e44d7b9b956db657b93bcf5] # # patch "refiner.hh" # from [543f5789aa9f74593f909e4b80cea986639228b4] # to [76a2230251b87e779d7a938ae9e6982fe69ab105] # # patch "tests/common/netsync.lua" # from [5b18be9929d1d852a5f931fd9756dd30c197c9c6] # to [2a0b34f969dc8806e497e2ec53231dfe84111e6d] # ============================================================ --- netsync.cc 7e2ab1d800ce5a89fff62b23cefd1fb86cae13a0 +++ netsync.cc 3640dd6b17a9a3e32f2766391d23a19a3e82aa3a @@ -129,8 +129,7 @@ call_server(app_state & app, app.opts, app.lua, project, keys, role, info->client.get_include_pattern(), - info->client.get_exclude_pattern(), - info)); + info->client.get_exclude_pattern())); break; case automate_connection: wrapped.reset(new automate_session(app, sess.get(), @@ -233,7 +232,6 @@ session_from_server_sync_item(app_state keys, request.role, info->client.get_include_pattern(), info->client.get_exclude_pattern(), - shared_conn_info(), true)); sess->set_inner(wrapped); return sess; ============================================================ --- refiner.cc 2de8131df2595d5bcff5efe133ca1f768006d38f +++ refiner.cc e631259ef17957cc2e44d7b9b956db657b93bcf5 @@ -157,9 +157,7 @@ refiner::refiner(netcmd_item_type type, queries_in_flight(0), calculated_items_to_send(false), done(false), - items_to_receive(0), - min_items_to_receive(0), - may_receive_more_than_min(false) + items_to_receive(0) { merkle_ptr root = merkle_ptr(new merkle_node()); root->type = type; @@ -284,33 +282,6 @@ refiner::process_refinement_command(refi if (their_node.get_slot_state(slot) == leaf_state) note_item_in_peer(their_node, slot); - // esimate how many items to receive - if (their_node.get_slot_state(slot) != empty_state - && our_node->get_slot_state(slot) != subtree_state) - { - if (our_node->get_slot_state(slot) == empty_state) - { - if (their_node.get_slot_state(slot) == leaf_state) - ++min_items_to_receive; - else - { - min_items_to_receive += 2; - may_receive_more_than_min = true; - } - } - else if (their_node.get_slot_state(slot) == leaf_state) - { - // pair of leaves - id our_slotval, their_slotval; - their_node.get_raw_slot(slot, their_slotval); - our_node->get_raw_slot(slot, our_slotval); - if (our_slotval != their_slotval) - ++min_items_to_receive; - } - // else they have a tree and we have a leaf, in which - // case there will be more queries - } - if (ty == refinement_query) { // This block handles the interesting asymmetric cases of subtree ============================================================ --- refiner.hh 543f5789aa9f74593f909e4b80cea986639228b4 +++ refiner.hh 76a2230251b87e779d7a938ae9e6982fe69ab105 @@ -93,10 +93,6 @@ public: bool done; std::set items_to_send; size_t items_to_receive; - - // Estimate of what items_to_receive will be. - size_t min_items_to_receive; - bool may_receive_more_than_min; }; ============================================================ --- cmd_netsync.cc 08012b1b75787b9ee18f0f60f10140d6e74aa06f +++ cmd_netsync.cc f3cf1b10c6d49b1438d459f4f35eea59b57de5c2 @@ -272,54 +272,6 @@ CMD_AUTOMATE_NO_STDIO(remote, F("received remote error code %d") % os.get_error()); } -void print_dryrun_info(protocol_role role, - shared_conn_info info, - project_t & project) -{ - if (role != source_role) - { - if (info->client.dryrun_incoming_keys_is_estimate) - { - P(F("would receive %d revisions, %d certs, and at least %d keys") - % info->client.dryrun_incoming_revs - % info->client.dryrun_incoming_certs - % info->client.dryrun_incoming_keys); - } - else - { - P(F("would receive %d revisions, %d certs, and %d keys") - % info->client.dryrun_incoming_revs - % info->client.dryrun_incoming_certs - % info->client.dryrun_incoming_keys); - } - } - if (role != sink_role) - { - P(F("would send %d certs and %d keys") - % info->client.dryrun_outgoing_certs - % info->client.dryrun_outgoing_keys); - P(F("would send %d revisions:") - % info->client.dryrun_outgoing_revs.size()); - map branch_counts; - for (set::const_iterator i = info->client.dryrun_outgoing_revs.begin(); - i != info->client.dryrun_outgoing_revs.end(); ++i) - { - set my_branches; - project.get_revision_branches(*i, my_branches); - for(set::iterator b = my_branches.begin(); - b != my_branches.end(); ++b) - { - ++branch_counts[*b]; - } - } - for (map::iterator i = branch_counts.begin(); - i != branch_counts.end(); ++i) - { - P(F("%9d in branch %s") % i->second % i->first); - } - } -} - CMD(push, "push", "", CMD_REF(network), N_("[URL]\n[ADDRESS[:PORTNUMBER] [PATTERN ...]]"), N_("Pushes branches to a netsync server"), @@ -327,7 +279,7 @@ CMD(push, "push", "", CMD_REF(network), "to the netsync server at the address ADDRESS."), options::opts::max_netsync_version | options::opts::min_netsync_version | options::opts::set_default | options::opts::exclude | - options::opts::keys_to_push | options::opts::dryrun) + options::opts::keys_to_push) { database db(app); key_store keys(app); @@ -339,17 +291,15 @@ CMD(push, "push", "", CMD_REF(network), run_netsync_protocol(app, app.opts, app.lua, project, keys, client_voice, source_role, info); - if (app.opts.dryrun) - print_dryrun_info(source_role, info, project); } CMD_AUTOMATE(push, N_("[URL]\n[ADDRESS[:PORTNUMBER] [PATTERN ...]]"), N_("Pushes branches to a netsync server"), "", - options::opts::max_netsync_version | - options::opts::min_netsync_version | - options::opts::set_default | options::opts::exclude | - options::opts::keys_to_push | options::opts::dryrun) + options::opts::max_netsync_version | + options::opts::min_netsync_version | + options::opts::set_default | options::opts::exclude | + options::opts::keys_to_push) { database db(app); key_store keys(app); @@ -361,8 +311,6 @@ CMD_AUTOMATE(push, N_("[URL]\n[ADDRESS[: run_netsync_protocol(app, app.opts, app.lua, project, keys, client_voice, source_role, info); - if (app.opts.dryrun) - print_dryrun_info(source_role, info, project); } CMD(pull, "pull", "", CMD_REF(network), @@ -372,7 +320,7 @@ CMD(pull, "pull", "", CMD_REF(network), "from the netsync server at the address ADDRESS."), options::opts::max_netsync_version | options::opts::min_netsync_version | options::opts::set_default | options::opts::exclude | - options::opts::auto_update | options::opts::dryrun) + options::opts::auto_update) { database db(app); key_store keys(app); @@ -391,8 +339,6 @@ CMD(pull, "pull", "", CMD_REF(network), client_voice, sink_role, info); updater.maybe_do_update(); - if (app.opts.dryrun) - print_dryrun_info(sink_role, info, project); } CMD_AUTOMATE(pull, N_("[URL]\n[ADDRESS[:PORTNUMBER] [PATTERN ...]]"), @@ -400,8 +346,7 @@ CMD_AUTOMATE(pull, N_("[URL]\n[ADDRESS[: "", options::opts::max_netsync_version | options::opts::min_netsync_version | - options::opts::set_default | options::opts::exclude | - options::opts::dryrun) + options::opts::set_default | options::opts::exclude) { database db(app); key_store keys(app); @@ -413,8 +358,6 @@ CMD_AUTOMATE(pull, N_("[URL]\n[ADDRESS[: run_netsync_protocol(app, app.opts, app.lua, project, keys, client_voice, sink_role, info); - if (app.opts.dryrun) - print_dryrun_info(sink_role, info, project); } CMD(sync, "sync", "", CMD_REF(network), @@ -424,8 +367,7 @@ CMD(sync, "sync", "", CMD_REF(network), "with the netsync server at the address ADDRESS."), options::opts::max_netsync_version | options::opts::min_netsync_version | options::opts::set_default | options::opts::exclude | - options::opts::keys_to_push | options::opts::auto_update | - options::opts::dryrun) + options::opts::keys_to_push | options::opts::auto_update) { database db(app); key_store keys(app); @@ -448,8 +390,6 @@ CMD(sync, "sync", "", CMD_REF(network), client_voice, source_and_sink_role, info); updater.maybe_do_update(); - if (app.opts.dryrun) - print_dryrun_info(source_and_sink_role, info, project); } CMD_AUTOMATE(sync, N_("[URL]\n[ADDRESS[:PORTNUMBER] [PATTERN ...]]"), @@ -457,7 +397,7 @@ CMD_AUTOMATE(sync, N_("[URL]\n[ADDRESS[: "", options::opts::max_netsync_version | options::opts::min_netsync_version | options::opts::set_default | options::opts::exclude | - options::opts::keys_to_push | options::opts::dryrun) + options::opts::keys_to_push) { database db(app); key_store keys(app); @@ -476,8 +416,6 @@ CMD_AUTOMATE(sync, N_("[URL]\n[ADDRESS[: run_netsync_protocol(app, app.opts, app.lua, project, keys, client_voice, source_and_sink_role, info); - if (app.opts.dryrun) - print_dryrun_info(source_and_sink_role, info, project); } CMD_NO_WORKSPACE(clone, "clone", "", CMD_REF(network), ============================================================ --- tests/common/netsync.lua 5b18be9929d1d852a5f931fd9756dd30c197c9c6 +++ tests/common/netsync.lua 2a0b34f969dc8806e497e2ec53231dfe84111e6d @@ -28,38 +28,29 @@ end check(getstd("common/netsync-hooks_with_notes.lua", "netsync.lua")) end -function netsync.internal.client(srv, oper, pat, n, res, save_output) - if n == nil then n = 2 end - if n == 1 then - args = {"--rcfile=netsync.lua", "--keydir=keys", - "--db=test.db", oper, srv.address} - else - args = {"--rcfile=netsync.lua", "--keydir=keys"..n, - "--db=test"..n..".db", oper, srv.address} - end - if type(pat) == "string" then - table.insert(args, pat) - elseif type(pat) == "table" then - for k, v in pairs(pat) do - table.insert(args, v) - end - elseif pat ~= nil then - err("Bad pattern type "..type(pat)) - end - if save_output == nil then - save_output = false - end - check(mtn(unpack(args)), res, save_output, save_output) +function netsync.internal.client(srv, oper, pat, n, res) + if n == nil then n = 2 end + if n == 1 then + args = {"--rcfile=netsync.lua", "--keydir=keys", + "--db=test.db", oper, srv.address} + else + args = {"--rcfile=netsync.lua", "--keydir=keys"..n, + "--db=test"..n..".db", oper, srv.address} + end + if type(pat) == "string" then + table.insert(args, pat) + elseif type(pat) == "table" then + for k, v in pairs(pat) do + table.insert(args, v) + end + elseif pat ~= nil then + err("Bad pattern type "..type(pat)) + end + check(mtn(unpack(args)), res, false, false) end -function netsync.internal.pull(srv, pat, n, res, save_output) - srv:client("pull", pat, n, res, save_output) -end -function netsync.internal.push(srv, pat, n, res, save_output) - srv:client("push", pat, n, res, save_output) -end -function netsync.internal.sync(srv, pat, n, res, save_output) - srv:client("sync", pat, n, res, save_output) -end +function netsync.internal.pull(srv, pat, n, res) srv:client("pull", pat, n, res) end +function netsync.internal.push(srv, pat, n, res) srv:client("push", pat, n, res) end +function netsync.internal.sync(srv, pat, n, res) srv:client("sync", pat, n, res) end function netsync.start(opts, n, min) if type(opts) == "number" then ============================================================ --- network/netsync_session.cc e3b98a67f8eba6168d692d6a29ffa66d4db2f796 +++ network/netsync_session.cc 1ebe5e1a734cd672fdeb29705edefe6f85a2c125 @@ -75,7 +75,6 @@ netsync_session::netsync_session(session protocol_role role, globish const & our_include_pattern, globish const & our_exclude_pattern, - shared_conn_info info, bool initiated_by_server) : wrapped_session(owner), role(role), @@ -100,9 +99,6 @@ netsync_session::netsync_session(session key_refiner(key_item, get_voice(), *this), cert_refiner(cert_item, get_voice(), *this), rev_refiner(revision_item, get_voice(), *this), - is_dry_run(opts.dryrun), - dry_run_keys_refined(false), - conn_info(info), rev_enumerator(project, *this), initiated_by_server(initiated_by_server) { @@ -439,38 +435,8 @@ bool } bool -netsync_session::dry_run_finished() const -{ - bool all = rev_refiner.done - && cert_refiner.done - && dry_run_keys_refined; - - if (all && conn_info) - { - conn_info->client.dryrun_incoming_revs = rev_refiner.items_to_receive; - conn_info->client.dryrun_incoming_certs = cert_refiner.items_to_receive; - conn_info->client.dryrun_incoming_keys = key_refiner.min_items_to_receive; - conn_info->client.dryrun_incoming_keys_is_estimate - = key_refiner.may_receive_more_than_min; - - for (set::const_iterator i = rev_refiner.items_to_send.begin(); - i != rev_refiner.items_to_send.end(); ++i) - { - conn_info->client.dryrun_outgoing_revs.insert(revision_id(*i)); - } - conn_info->client.dryrun_outgoing_certs = cert_refiner.items_to_send.size(); - conn_info->client.dryrun_outgoing_keys = key_refiner.items_to_send.size(); - } - - return all; -} - -bool netsync_session::finished_working() const { - if (dry_run_finished()) - return true; - bool all = done_all_refinements() && received_all_items() && queued_all_items() @@ -641,11 +607,6 @@ netsync_session::queue_done_cmd(netcmd_i { string typestr; netcmd_item_type_to_string(type, typestr); - if (is_dry_run && type == key_item) - { - dry_run_keys_refined = true; - return; - } L(FL("queueing 'done' command for %s (%d items)") % typestr % n_items); netcmd cmd(get_version()); ============================================================ --- network/netsync_session.hh e5483827d8db0964dabed6565fddf1713f701a7d +++ network/netsync_session.hh 227867a6d5efdac111d46e129c660fba1c327b4f @@ -22,7 +22,6 @@ #include "refiner.hh" #include "ui.hh" -#include "network/connection_info.hh" #include "network/wrapped_session.hh" class cert; @@ -73,12 +72,6 @@ netsync_session: refiner cert_refiner; refiner rev_refiner; - // dry-run info - bool is_dry_run; - bool dry_run_keys_refined; - shared_conn_info conn_info; - bool dry_run_finished() const; - // Interface to ancestry grovelling. revision_enumerator rev_enumerator; @@ -101,7 +94,6 @@ public: protocol_role role, globish const & our_include_pattern, globish const & our_exclude_pattern, - shared_conn_info info, bool initiated_by_server = false); virtual ~netsync_session(); ============================================================ --- network/session.cc 04f99fb3516968474cde97892d9b219ea0d5505e +++ network/session.cc 30e79173fce3cd35666e1f52393fa1736cc9b01e @@ -660,8 +660,7 @@ bool session::handle_service_request() keys, corresponding_role(role), their_include, - their_exclude, - shared_conn_info())); + their_exclude)); break; case is_automate: wrapped.reset(new automate_session(app, this, 0, 0)); ============================================================ --- network/connection_info.cc d03280d9dd87adce8b7b0bebf244878661d5ae6e +++ network/connection_info.cc ca442d99d973be6e4b5d6cecdd986b419896c389 @@ -38,13 +38,7 @@ netsync_connection_info::Client::Client( conn_type(netsync_connection), input_stream(0), output_stream(0), - db(d), opts(o), - dryrun_incoming_revs(0), - dryrun_incoming_certs(0), - dryrun_incoming_keys(0), - dryrun_incoming_keys_is_estimate(false), - dryrun_outgoing_certs(0), - dryrun_outgoing_keys(0) + db(d), opts(o) { var_key default_server_key(var_domain("database"), var_name("default-server")); ============================================================ --- network/connection_info.hh 181811d9adbba91506779f28461d29a46a40f2a1 +++ network/connection_info.hh 2578ebe8394cf7611bc4db06fce0f6917a390f67 @@ -76,14 +76,6 @@ struct netsync_connection_info connection_type get_connection_type() const; void set_connection_successful(); - - size_t dryrun_incoming_revs; - size_t dryrun_incoming_certs; - size_t dryrun_incoming_keys; - bool dryrun_incoming_keys_is_estimate; - std::set dryrun_outgoing_revs; - size_t dryrun_outgoing_certs; - size_t dryrun_outgoing_keys; } client; static void ============================================================ --- tests/netsync_dry_run/__driver__.lua 9a6da1188ff30933c6e060c0a6fe54cd2dc9ceee +++ /dev/null @@ -1,51 +0,0 @@ -include("common/netsync.lua") -mtn_setup() -netsync.setup() - - -addfile("foo", "bar") -commit("testbranch") -baserev = base_revision() - -addfile("aaa", "aaa") -commit("firstbranch") -check(mtn("up", "-r", baserev), 0, false, false) - -addfile("bbb", "bbb") -commit("secondbranch") - - -srv1 = netsync.start() - -srv1:pull({"--dry-run", "*"}, 2, 0, true) -check(qgrep("receive 3 revisions, 12 certs, and 1 keys", "stderr")) -check(not qgrep("send", "stderr")) - -srv1:pull("{testbranch,firstbranch}", 2) -srv1:pull("{testbranch,secondbranch}", 3) - - -srv2 = netsync.start(2) - -srv2:pull({"--dry-run", "*"}, 3, 0, true) -check(qgrep("receive 1 revisions, 4 certs, and 0 keys", "stderr")) -check(not qgrep("send", "stderr")) - -srv2:push({"--dry-run", "*"}, 3, 0, true) -check(qgrep("send 4 certs and 0 keys", "stderr")) -check(qgrep("send 1 revision", "stderr")) -check(qgrep("1 in branch secondbranch", "stderr")) -check(not qgrep("receive", "stderr")) - -srv2:sync({"--dry-run", "*"}, 3, 0, true) -check(qgrep("receive 1 revisions, 4 certs, and 0 keys", "stderr")) -check(qgrep("send 4 certs and 0 keys", "stderr")) -check(qgrep("send 1 revision", "stderr")) -check(qgrep("1 in branch secondbranch", "stderr")) - -srv2:sync({"*"}, 3, 0, true) -srv2:sync({"--dry-run", "*"}, 3, 0, true) -check(qgrep("receive 0 revisions, 0 certs, and 0 keys", "stderr")) -check(qgrep("send 0 certs and 0 keys", "stderr")) -check(qgrep("send 0 revision", "stderr")) -check(not qgrep("in branch", "stderr")) \ No newline at end of file