# # # patch "cmd_netsync.cc" # from [5afb2d0575d8b78d7a67a8f794ef34d6b0f13f9d] # to [351b6596193cc5b9f2e248f3800d594b549b8632] # # patch "monotone.texi" # from [664faca901f83ec81334a6ef225ac8c94253fb08] # to [fdb503ac6d8193d9102cb519f0219c117da9a974] # # patch "network/connection_info.cc" # from [eb5d6b6e5200db58bbc7e98ffdc0395da3170f20] # to [0b90564ed26135caec0144c33c020232c6dea4f2] # # patch "network/connection_info.hh" # from [c3d812c293840d3618951358ef562fb5eabcd429] # to [c11a6444130b267d41c0a595e51380df566d91f2] # # patch "network/netsync_session.cc" # from [76f0a94a991188f673ec088abd59fd8bfb105a93] # to [ab23d361aeb57580eea9ec8cd55eddd66edaea3d] # # patch "tests/automate_netsync_dryrun/__driver__.lua" # from [ca68f0025c9eb2fbd1043c4a152fe72c5eda0656] # to [ae9a242e0c5d35a648f44291d7db7d7921f21693] # ============================================================ --- monotone.texi 664faca901f83ec81334a6ef225ac8c94253fb08 +++ monotone.texi fdb503ac6d8193d9102cb519f0219c117da9a974 @@ -8608,11 +8608,11 @@ @section Automation The following is example dry-run main channel data: @verbatim - dryrun receive revision "0" cert "1" key "1" + send revision "1" cert "6" @@ -8655,17 +8655,17 @@ @section Automation For non-dry-run, all stanzas are optional; they are only output if the data they describe is transferred. -If revisions are received, a header stanza @code{receive -revision}. For each revision, a stanza containing the revision id. For -each cert associated with the revision, a stanza containing the cert -name, value, and key. +If revisions are received, there is a header stanza @code{receive +revision}. Then for each revision, there is a stanza containing the +revision id, followed by a stanza containing the cert name, value, and +key for each cert associated with the revision. -If certs not associated with a transmitted revision are received, a -header stanza @code{receive cert}. For each cert, a stanza giving the cert -name, value, key, and revision. +If certs not associated with a transmitted revision are received, +there is a header stanza @code{receive cert}. Then for each cert, +there is a stanza giving the cert name, value, key, and revision. -If keys are received, a stanza containing one line for each key, -giving the key id. +If keys are received, there is one stanza containing one line for each +key, giving the key id. Similarly for sent revisions, certs, and keys. @@ -8698,7 +8698,10 @@ @section Automation For dry-run, two optional stanzas are output, giving the revision, cert, and key counts for send and receive. For send, the branch names -of sent revisions are also output. +of sent revisions are also output. Note that in the branch list, +revisions that have multiple branch certs are listed twice, so the sum +of the revision counts in the branch list may be greater than the +number of revisions transferred. @item Error conditions: ============================================================ --- cmd_netsync.cc 5afb2d0575d8b78d7a67a8f794ef34d6b0f13f9d +++ cmd_netsync.cc 351b6596193cc5b9f2e248f3800d594b549b8632 @@ -304,7 +304,9 @@ print_dryrun_info_cmd(protocol_role role P(F("would send %d certs and %d keys") % counts->certs_out.min_count % counts->keys_out.min_count); - P(F("would send %d revisions:") + P(FP("would send %d revisions", // 0 revisions; nothing following, so no trailing colon + "would send %d revisions:", + counts->revs_out.min_count + 1) % counts->revs_out.min_count); map branch_counts; for (vector::const_iterator i = counts->revs_out.items.begin(); @@ -432,25 +434,10 @@ print_info_auto(protocol_role role, { // sink or sink_and_source; print sink info - // Sort received certs into those associated with a received revision, and - // others. vector unattached_certs; map > rev_certs; + sort_rev_order (counts->revs_in, counts->certs_in, unattached_certs, rev_certs); - for (vector::const_iterator i = counts->revs_in.items.begin(); - i != counts->revs_in.items.end(); ++i) - rev_certs.insert(make_pair(*i, vector())); - for (vector::const_iterator i = counts->certs_in.items.begin(); - i != counts->certs_in.items.end(); ++i) - { - map >::iterator j; - j = rev_certs.find(revision_id(i->ident)); - if (j == rev_certs.end()) - unattached_certs.push_back(*i); - else - j->second.push_back(*i); - } - if (rev_certs.size() > 0) { { @@ -515,25 +502,10 @@ print_info_auto(protocol_role role, { // source or sink_and_source; print source info - // Sort sent certs into those associated with a sent revision, and - // others. vector unattached_certs; map > rev_certs; + sort_rev_order (counts->revs_out, counts->certs_out, unattached_certs, rev_certs); - for (vector::const_iterator i = counts->revs_out.items.begin(); - i != counts->revs_out.items.end(); ++i) - rev_certs.insert(make_pair(*i, vector())); - for (vector::const_iterator i = counts->certs_out.items.begin(); - i != counts->certs_out.items.end(); ++i) - { - map >::iterator j; - j = rev_certs.find(revision_id(i->ident)); - if (j == rev_certs.end()) - unattached_certs.push_back(*i); - else - j->second.push_back(*i); - } - if (rev_certs.size() > 0) { { @@ -672,9 +644,14 @@ CMD(pull, "pull", "", CMD_REF(network), run_netsync_protocol(app, app.opts, app.lua, project, keys, client_voice, sink_role, info, counts); - updater.maybe_do_update(); if (app.opts.dryrun) - print_dryrun_info_cmd(sink_role, counts, project); + { + print_dryrun_info_cmd(sink_role, counts, project); + } + else + { + updater.maybe_do_update(); + } } CMD_AUTOMATE(pull, N_("[URL]\n[ADDRESS[:PORTNUMBER] [PATTERN ...]]"), @@ -733,9 +710,14 @@ CMD(sync, "sync", "", CMD_REF(network), run_netsync_protocol(app, app.opts, app.lua, project, keys, client_voice, source_and_sink_role, info, counts); - updater.maybe_do_update(); if (app.opts.dryrun) - print_dryrun_info_cmd(source_and_sink_role, counts, project); + { + print_dryrun_info_cmd(source_and_sink_role, counts, project); + } + else + { + updater.maybe_do_update(); + } } CMD_AUTOMATE(sync, N_("[URL]\n[ADDRESS[:PORTNUMBER] [PATTERN ...]]"), ============================================================ --- network/netsync_session.cc 76f0a94a991188f673ec088abd59fd8bfb105a93 +++ network/netsync_session.cc ab23d361aeb57580eea9ec8cd55eddd66edaea3d @@ -139,28 +139,18 @@ void netsync_session::on_end(size_t iden certs_in || certs_out || keys_in || keys_out)) error_code = error_codes::partial_transfer; + // Call Lua hooks - vector unattached_written_certs; - map > rev_written_certs; - for (vector::const_iterator i = counts->revs_in.items.begin(); - i != counts->revs_in.items.end(); ++i) - rev_written_certs.insert(make_pair(*i, vector())); - for (vector::const_iterator i = counts->certs_in.items.begin(); - i != counts->certs_in.items.end(); ++i) - { - map >::iterator j; - j = rev_written_certs.find(revision_id(i->ident)); - if (j == rev_written_certs.end()) - unattached_written_certs.push_back(*i); - else - j->second.push_back(*i); - } - if (!counts->revs_in.items.empty() || !counts->keys_in.items.empty() || !counts->certs_in.items.empty()) { + vector unattached_written_certs; + map > rev_written_certs; + sort_rev_order (counts->revs_in, counts->certs_in, + unattached_written_certs, rev_written_certs); + //Keys for (vector::const_iterator i = counts->keys_in.items.begin(); i != counts->keys_in.items.end(); ++i) @@ -211,19 +201,8 @@ void netsync_session::on_end(size_t iden vector unattached_sent_certs; map > rev_sent_certs; - for (vector::const_iterator i = counts->revs_out.items.begin(); - i != counts->revs_out.items.end(); ++i) - rev_sent_certs.insert(make_pair(*i, vector())); - for (vector::const_iterator i = counts->certs_out.items.begin(); - i != counts->certs_out.items.end(); ++i) - { - map >::iterator j; - j = rev_sent_certs.find(revision_id(i->ident)); - if (j == rev_sent_certs.end()) - unattached_sent_certs.push_back(*i); - else - j->second.push_back(*i); - } + sort_rev_order (counts->revs_out, counts->certs_out, + unattached_sent_certs, rev_sent_certs); //Keys for (vector::const_iterator i = counts->keys_out.items.begin(); @@ -368,6 +347,10 @@ netsync_session::setup_client_tickers() byte_in_ticker.reset(new ticker(N_("bytes in"), ">", 1024, true)); // xgettext: please use short message and try to avoid multibytes chars byte_out_ticker.reset(new ticker(N_("bytes out"), "<", 1024, true)); + + if (is_dry_run) + return; + if (role == sink_role) { // xgettext: please use short message and try to avoid multibytes chars ============================================================ --- network/connection_info.cc eb5d6b6e5200db58bbc7e98ffdc0395da3170f20 +++ network/connection_info.cc 0b90564ed26135caec0144c33c020232c6dea4f2 @@ -24,6 +24,7 @@ #include +using std::map; using std::vector; using std::string; using boost::lexical_cast; @@ -34,6 +35,28 @@ shared_conn_counts connection_counts::cr return shared_conn_counts(new connection_counts()); } +void +sort_rev_order (future_set & revs, + future_set & certs, + vector & unattached_certs, + map > & rev_certs) +{ + for (vector::const_iterator i = revs.items.begin(); + i != revs.items.end(); ++i) + rev_certs.insert(make_pair(*i, vector())); + + for (vector::const_iterator i = certs.items.begin(); + i != certs.items.end(); ++i) + { + map >::iterator j; + j = rev_certs.find(revision_id(i->ident)); + if (j == rev_certs.end()) + unattached_certs.push_back(*i); + else + j->second.push_back(*i); + } +} + netsync_connection_info::netsync_connection_info(database & d, options const & o) : client(d, o) { } ============================================================ --- network/connection_info.hh c3d812c293840d3618951358ef562fb5eabcd429 +++ network/connection_info.hh c11a6444130b267d41c0a595e51380df566d91f2 @@ -81,8 +81,25 @@ public: future_set keys_out; future_set certs_out; future_set revs_out; + }; +// 'revs' is a list of revs that were transferred (normally +// connection_counts.revs_in or connection_counts.revs_out). +// +// 'certs' is a list of certs that were transferred (normally +// connection_counts.certs_in or connection_counts.certs_out). +// +// Populate unattached_certs with certs that are associated with a +// revision that was _not_ transferred. +// +// Populate rev_certs with certs that are associated with a revision that +// _was_ transferred. +void sort_rev_order (future_set & revs, + future_set & certs, + std::vector & unattached_certs, + std::map > & rev_certs); + struct netsync_connection_info { class Server ============================================================ --- tests/automate_netsync_dryrun/__driver__.lua ca68f0025c9eb2fbd1043c4a152fe72c5eda0656 +++ tests/automate_netsync_dryrun/__driver__.lua ae9a242e0c5d35a648f44291d7db7d7921f21693 @@ -86,10 +86,10 @@ check(any_of(tickers, ">:bytes in")) check(any_of(tickers, "c;k;r;")) check(any_of(tickers, ">:bytes in")) -check(any_of(tickers, "<:bytes out")) -check(any_of(tickers, "r:revs in")) -check(any_of(tickers, "c:certs in")) -check(any_of(tickers, "C:certs out")) +check(not any_of(tickers, "<:bytes out")) +check(not any_of(tickers, "r:revs in")) +check(not any_of(tickers, "c:certs in")) +check(not any_of(tickers, "C:certs out")) check(not any_of(tickers, "R#1")) check(not any_of(tickers, "r#1"))