# # # patch "cmd_netsync.cc" # from [3937fd1ac11e513f5cd453b1c5b4f52bd3b78872] # to [070e7f74fe5b02d74df01d0d9a4979dcb1282be7] # # patch "enumerator.cc" # from [569a5c9282b5073a150fb788275a5c3bd6ce5dfa] # to [4400e1ce3ef83739301e15c27f7bad6d42817736] # # patch "enumerator.hh" # from [e37159cff28065b774569dfc441b2306646965ca] # to [d1dac4129cf193b9a2531ca785690a093e4e1248] # # patch "netcmd.hh" # from [aa9e0f646f56f02d4f44beb63ab15fab554102a1] # to [ec7d86b3af44ce536db4ed266bbf8fb09f5316f1] # # patch "netsync.cc" # from [3421fdb6e901e6ee860c0322b969113fb1fd5e0e] # to [b7bc58a58a56434b4bd82fc094b763d29dd29ece] # ============================================================ --- cmd_netsync.cc 3937fd1ac11e513f5cd453b1c5b4f52bd3b78872 +++ cmd_netsync.cc 070e7f74fe5b02d74df01d0d9a4979dcb1282be7 @@ -163,7 +163,7 @@ CMD(push, "push", "", CMD_REF(network), run_netsync_protocol(client_voice, source_role, uris, include_pattern, exclude_pattern, - app.db, app.keys, app.lua, app.opts); + app.db, app.get_project(), app.keys, app.lua, app.opts); } CMD(pull, "pull", "", CMD_REF(network), @@ -187,7 +187,7 @@ CMD(pull, "pull", "", CMD_REF(network), run_netsync_protocol(client_voice, sink_role, uris, include_pattern, exclude_pattern, - app.db, app.keys, app.lua, app.opts); + app.db, app.get_project(), app.keys, app.lua, app.opts); } CMD(sync, "sync", "", CMD_REF(network), @@ -209,7 +209,7 @@ CMD(sync, "sync", "", CMD_REF(network), run_netsync_protocol(client_voice, source_and_sink_role, uris, include_pattern, exclude_pattern, - app.db, app.keys, app.lua, app.opts); + app.db, app.get_project(), app.keys, app.lua, app.opts); } class dir_cleanup_helper @@ -329,7 +329,7 @@ CMD(clone, "clone", "", CMD_REF(network) run_netsync_protocol(client_voice, sink_role, uris, include_pattern, exclude_pattern, - app.db, app.keys, app.lua, app.opts); + app.db, app.get_project(), app.keys, app.lua, app.opts); change_current_working_dir(workspace_dir); @@ -454,7 +454,7 @@ CMD_NO_WORKSPACE(serve, "serve", "", CMD run_netsync_protocol(server_voice, source_and_sink_role, app.opts.bind_uris, globish("*"), globish(""), - app.db, app.keys, app.lua, app.opts); + app.db, app.get_project(), app.keys, app.lua, app.opts); } // Local Variables: ============================================================ --- enumerator.cc 569a5c9282b5073a150fb788275a5c3bd6ce5dfa +++ enumerator.cc 4400e1ce3ef83739301e15c27f7bad6d42817736 @@ -28,29 +28,12 @@ revision_enumerator::revision_enumerator using std::vector; revision_enumerator::revision_enumerator(enumerator_callbacks & cb, - database & db, - set const & initial, - set const & terminal) - : cb(cb), db(db), terminal_nodes(terminal) + database & db, project_t & project) + : cb(cb), db(db), project(project) { - for (set::const_iterator i = initial.begin(); - i != initial.end(); ++i) - revs.push_back(*i); - load_graphs(); -} - -revision_enumerator::revision_enumerator(enumerator_callbacks & cb, - database & db) - : cb(cb), db(db) -{ revision_id root; revs.push_back(root); - load_graphs(); -} -void -revision_enumerator::load_graphs() -{ db.get_revision_ancestry(graph); for (multimap::const_iterator i = graph.begin(); i != graph.end(); ++i) @@ -75,7 +58,6 @@ revision_enumerator::get_revision_parent } } - bool revision_enumerator::all_parents_enumerated(revision_id const & child) { @@ -204,9 +186,7 @@ revision_enumerator::get_revision_certs( hashes.push_back(i->second); } if (!found_one) - { - db.get_project().get_revision_cert_hashes(rid, hashes); - } + project.get_revision_cert_hashes(rid, hashes); } void ============================================================ --- enumerator.hh e37159cff28065b774569dfc441b2306646965ca +++ enumerator.hh d1dac4129cf193b9a2531ca785690a093e4e1248 @@ -17,6 +17,7 @@ class database; #include "vocab.hh" class database; +class project_t; // The revision_enumerator struct acts as a cursor which emits files, // deltas, revisions and certs in dependency-correct order. This is @@ -48,11 +49,12 @@ enumerator_item hexenc ident_b; }; -struct +class revision_enumerator { enumerator_callbacks & cb; database & db; + project_t & project; std::set terminal_nodes; std::set enumerated_nodes; std::deque revs; @@ -61,24 +63,20 @@ revision_enumerator std::multimap inverse_graph; std::multimap > revision_certs; - void note_cert(revision_id const & rid, - hexenc const & cert_hash); + bool all_parents_enumerated(revision_id const & child); + void files_for_revision(revision_id const & r, + std::set & full_files, + std::set > & del_files); void get_revision_certs(revision_id const & rid, std::vector > & certs); - void get_revision_parents(revision_id const & rid, - std::vector & parents); +public: revision_enumerator(enumerator_callbacks & cb, - database & db, - std::set const & initial, - std::set const & terminal); - revision_enumerator(enumerator_callbacks & cb, - database & db); - void load_graphs(); - bool all_parents_enumerated(revision_id const & child); - void files_for_revision(revision_id const & r, - std::set & full_files, - std::set > & del_files); + database & db, project_t & project); + void get_revision_parents(revision_id const & rid, + std::vector & parents); + void note_cert(revision_id const & rid, + hexenc const & cert_hash); void step(); bool done(); }; ============================================================ --- netcmd.hh aa9e0f646f56f02d4f44beb63ab15fab554102a1 +++ netcmd.hh ec7d86b3af44ce536db4ed266bbf8fb09f5316f1 @@ -22,6 +22,7 @@ class database; struct globish; class database; +class project_t; class key_store; class lua_hooks; class options; @@ -180,8 +181,8 @@ void run_netsync_protocol(protocol_voice std::list const & addrs, globish const & include_pattern, globish const & exclude_pattern, - database & db, key_store & keys, - lua_hooks & lua, options & opts); + database & db, project_t & project, + key_store & keys, lua_hooks & lua, options & opts); // Local Variables: // mode: C++ ============================================================ --- netsync.cc 3421fdb6e901e6ee860c0322b969113fb1fd5e0e +++ netsync.cc b7bc58a58a56434b4bd82fc094b763d29dd29ece @@ -299,6 +299,7 @@ session: globish_matcher our_matcher; database & db; + project_t & project; key_store & keys; lua_hooks & lua; bool use_transport_auth; @@ -402,6 +403,7 @@ session: globish const & our_include_pattern, globish const & our_exclude_pattern, database & db, + project_t & project, key_store & keys, lua_hooks & lua, options & opts, @@ -521,6 +523,7 @@ session::session(protocol_role role, globish const & our_include_pattern, globish const & our_exclude_pattern, database & db, + project_t & project, key_store & keys, lua_hooks & lua, options & opts, @@ -533,6 +536,7 @@ session::session(protocol_role role, our_exclude_pattern(our_exclude_pattern), our_matcher(our_include_pattern, our_exclude_pattern), db(db), + project(project), keys(keys), lua(lua), use_transport_auth(opts.use_transport_auth), @@ -572,7 +576,7 @@ session::session(protocol_role role, key_refiner(key_item, voice, *this), cert_refiner(cert_item, voice, *this), rev_refiner(revision_item, voice, *this), - rev_enumerator(*this, db), + rev_enumerator(*this, db, project), initiated_by_server(initiated_by_server) {} @@ -1352,7 +1356,7 @@ session::process_hello_cmd(rsa_keypair_i // clients always include in the synchronization set, every branch that the // user requested set all_branches, ok_branches; - db.get_project().get_branch_list(all_branches, false); + project.get_branch_list(all_branches, false); for (set::const_iterator i = all_branches.begin(); i != all_branches.end(); i++) { @@ -1445,7 +1449,7 @@ session::process_anonymous_cmd(protocol_ } set all_branches, ok_branches; - db.get_project().get_branch_list(all_branches, false); + project.get_branch_list(all_branches, false); globish_matcher their_matcher(their_include_pattern, their_exclude_pattern); for (set::const_iterator i = all_branches.begin(); i != all_branches.end(); i++) @@ -1581,7 +1585,7 @@ session::process_auth_cmd(protocol_role } set all_branches, ok_branches; - db.get_project().get_branch_list(all_branches, false); + project.get_branch_list(all_branches, false); for (set::const_iterator i = all_branches.begin(); i != all_branches.end(); i++) { @@ -2396,6 +2400,7 @@ call_server(protocol_role role, globish const & include_pattern, globish const & exclude_pattern, database & db, + project_t & project, key_store & keys, lua_hooks & lua, options & opts, @@ -2428,7 +2433,7 @@ call_server(protocol_role role, session sess(role, client_voice, include_pattern, exclude_pattern, - db, keys, lua, opts, address(), server); + db, project, keys, lua, opts, address(), server); while (true) { @@ -2593,7 +2598,7 @@ handle_new_connection(Netxx::Address & a globish const & include_pattern, globish const & exclude_pattern, map > & sessions, - database & db, key_store & keys, + database & db, project_t & project, key_store & keys, lua_hooks & lua, options & opts) { L(FL("accepting new connection on %s : %s") @@ -2620,7 +2625,7 @@ handle_new_connection(Netxx::Address & a shared_ptr sess(new session(role, server_voice, include_pattern, exclude_pattern, - db, keys, lua, opts, + db, project, keys, lua, opts, lexical_cast(client), str)); sess->begin_service(); sessions.insert(make_pair(client.get_socketfd(), sess)); @@ -2763,6 +2768,7 @@ serve_connections(protocol_role role, globish const & include_pattern, globish const & exclude_pattern, database & db, + project_t & project, key_store & keys, lua_hooks & lua, options & opts, @@ -2894,7 +2900,7 @@ serve_connections(protocol_role role, shared_ptr sess(new session(role, client_voice, inc, exc, - db, keys, + db, project, keys, lua, opts, addr(), server, true)); @@ -2935,7 +2941,8 @@ serve_connections(protocol_role role, else if (fd == server) handle_new_connection(addr, server, timeout, role, include_pattern, exclude_pattern, - sessions, db, keys, lua, opts); + sessions, db, project, keys, + lua, opts); // or an existing session woke up else @@ -3163,7 +3170,7 @@ session::rebuild_merkle_trees(setproject).get_branch_certs(i->branch) // or so. - db.get_project().get_branch_certs(*i, certs); + project.get_branch_certs(*i, certs); for (vector< revision >::const_iterator j = certs.begin(); j != certs.end(); j++) { @@ -3292,7 +3299,7 @@ run_netsync_protocol(protocol_voice voic std::list const & addrs, globish const & include_pattern, globish const & exclude_pattern, - database & db, key_store & keys, + database & db, project_t & project, key_store & keys, lua_hooks & lua, options & opts) { if (include_pattern().find_first_of("'\"") != string::npos) @@ -3319,13 +3326,13 @@ run_netsync_protocol(protocol_voice voic shared_ptr str(new Netxx::PipeStream(0,1)); shared_ptr sess(new session(role, server_voice, include_pattern, exclude_pattern, - db, keys, lua, opts, + db, project, keys, lua, opts, "stdio", str)); serve_single_connection(sess,constants::netsync_timeout_seconds); } else serve_connections(role, include_pattern, exclude_pattern, - db, keys, lua, opts, + db, project, keys, lua, opts, addrs, static_cast(constants::netsync_default_port), static_cast(constants::netsync_timeout_seconds), static_cast(constants::netsync_connection_limit)); @@ -3334,7 +3341,7 @@ run_netsync_protocol(protocol_voice voic { I(voice == client_voice); call_server(role, include_pattern, exclude_pattern, - db, keys, lua, opts, + db, project, keys, lua, opts, addrs, static_cast(constants::netsync_default_port), static_cast(constants::netsync_timeout_seconds)); }