# # # patch "ChangeLog" # from [363d195dfbdedc2d95947fb8f7d3ea334ce34d42] # to [c127509c7849c8f84b689ad5af2a9bfcccd09f8e] # # patch "lua.cc" # from [a9045fcf6d8283a12a96f422b79fb54ae2da727c] # to [15ce9164245ecdd634e1bbc24f3199df5ccf17e3] # # patch "lua.hh" # from [5691c7c116dc402741a8a9ba7f5ab7d2ebe7b2e0] # to [51b76a94c93113194a0ab5ab2698a71619874487] # # patch "monotone.texi" # from [c5bea87b22f67e3404db5a4b5bcf0fe767919223] # to [fff70064e03cdf1cbeba0ae031155833f81458dd] # # patch "netsync.cc" # from [7957659288b88cd39c43958b7720d5fd073776f4] # to [9900897d44dfc2ab65bcd3525183f27a1b680ff1] # ============================================================ --- ChangeLog 363d195dfbdedc2d95947fb8f7d3ea334ce34d42 +++ ChangeLog c127509c7849c8f84b689ad5af2a9bfcccd09f8e @@ -1,3 +1,24 @@ +2006-03-17 Richard Levitte + + There are times when it is good to be able to prepare for a + bunch of calls to note_netsync* hooks, as well as to know when + there are not more such calls to be expected. To that end, I've + added note_netsync_start and note_netsync_end, and changed the + others to take the exact same nonce as those two. The purpose + of the nonce is to differentiate between different runs, if they + ever would run in parallel. + + * lua.cc, lua.hh (lua_hooks::hook_note_netsync_start, + lua_hooks::hook_note_netsync_end): Added methods. + (lua_hooks::hook_note_netsync_revision_received, + lua_hooks::hook_note_netsync_pubkey_received, + lua_hooks::hook_note_netsync_cert_received): Modified to take a + nonce. + * monotone.texi (Hooks): Documented. + * netsync.cc (session::~session): Modified to call + app.lua.hook_note_netsync_start and app.lua.hook_note_netsync_end + as well as the others with the nonce argument. + 2006-03-16 Benoît Dejean * commands.cc (log): Don't include , my mistake. ============================================================ --- lua.cc a9045fcf6d8283a12a96f422b79fb54ae2da727c +++ lua.cc 15ce9164245ecdd634e1bbc24f3199df5ccf17e3 @@ -1416,7 +1416,19 @@ } bool -lua_hooks::hook_note_netsync_revision_received(revision_id const & new_id, +lua_hooks::hook_note_netsync_start(string nonce) +{ + Lua ll(st); + return ll + .func("note_netsync_start") + .push_str(nonce) + .call(1, 0) + .ok(); +} + +bool +lua_hooks::hook_note_netsync_revision_received(string nonce, + revision_id const & new_id, revision_data const & rdat, set const & certs); - bool hook_note_netsync_revision_received(revision_id const & new_id, + bool hook_note_netsync_start(std::string nonce); + bool hook_note_netsync_revision_received(std::string nonce, + revision_id const & new_id, revision_data const & rdat, std::set > > const & certs); - bool hook_note_netsync_pubkey_received(rsa_keypair_id const & kid); - bool hook_note_netsync_cert_received(revision_id const & rid, + bool hook_note_netsync_pubkey_received(std::string nonce, + rsa_keypair_id const & kid); + bool hook_note_netsync_cert_received(std::string nonce, + revision_id const & rid, rsa_keypair_id const & kid, cert_name const & name, cert_value const & value); + bool hook_note_netsync_end(std::string nonce); }; #endif // __LUA_HH__ ============================================================ --- monotone.texi c5bea87b22f67e3404db5a4b5bcf0fe767919223 +++ monotone.texi fff70064e03cdf1cbeba0ae031155833f81458dd @@ -6129,8 +6129,15 @@ commit-notification systems such as mailing lists or news services. It should not perform any security-critical operations. address@hidden note_netsync_revision_received (@var{new_id}, @var{revision}, @var{certs}) address@hidden note_netsync_start (@var{nonce}) +Called by monotone before any other of the netsync notification hooks +are called. The @var{nonce} helps keep track of the current netsync +session in case several are happening at the same time, and is used +throughout all netsync notification hooks. + address@hidden note_netsync_revision_received (@var{nonce}, @var{new_id}, @var{revision}, @var{certs}) + Called by monotone after the revision @var{new_id} is received through netsync. @var{revision} is the text of the revision, what would be given by "monotone cat revision @var{new_id}". @var{certs} is a lua table @@ -6140,7 +6147,7 @@ the name of the cert, and the value of the cert. There is no default definition for this hook. address@hidden note_netsync_cert_received (@var{rev_id}, @var{key}, @var{name}, @var{value}) address@hidden note_netsync_cert_received (@var{nonce}, @var{rev_id}, @var{key}, @var{name}, @var{value}) Called by monotone after a cert is received through netsync, iff the revision that the cert is attached to was not also received in the same netsync @@ -6149,11 +6156,20 @@ of the cert, and @var{value} is the cert value. There is no default definition for this hook. address@hidden note_netsync_pubkey_received (@var{keyname}) address@hidden note_netsync_pubkey_received (@var{nonce}, @var{keyname}) Called by monotone after a pubkey is received through netsync. @var{keyname} is the name of the key received. There is no default definition for this hook. address@hidden note_netsync_end (@var{nonce}) + +Called by monotone after all other the netsync notification hooks have +been called. This hook would usually be used for post-netsync purposes, +like collecting all the data from all other netsync notification hooks, +make some nice output from them and finally send the result somewhere. +It could also be used to prepare parallell databases with all the data +to be displayed through something like viewmtn. + @end ftable @subsection User Defaults ============================================================ --- netsync.cc 7957659288b88cd39c43958b7720d5fd073776f4 +++ netsync.cc 9900897d44dfc2ab65bcd3525183f27a1b680ff1 @@ -496,6 +496,12 @@ session::~session() { + static const char letters[] = "0123456789abcdef"; + string nonce; + for (int i = 0; i < 16; i++) + nonce.append(1, letters[Botan::Global_RNG::random(Botan::Nonce) + % sizeof(letters)]); + vector unattached_certs; map > revcerts; for (vector::iterator i = written_revisions.begin(); @@ -512,11 +518,14 @@ j->second.push_back(*i); } + //Start + app.lua.hook_note_netsync_start(nonce); + //Keys for (vector::iterator i = written_keys.begin(); i != written_keys.end(); ++i) { - app.lua.hook_note_netsync_pubkey_received(*i); + app.lua.hook_note_netsync_pubkey_received(nonce, *i); } //Revisions @@ -534,7 +543,7 @@ } revision_data rdat; app.db.get_revision(*i, rdat); - app.lua.hook_note_netsync_revision_received(*i, rdat, certs); + app.lua.hook_note_netsync_revision_received(nonce, *i, rdat, certs); } //Certs (not attached to a new revision) @@ -543,10 +552,13 @@ { cert_value tmp; decode_base64(i->value, tmp); - app.lua.hook_note_netsync_cert_received(i->ident, i->key, + app.lua.hook_note_netsync_cert_received(nonce, i->ident, i->key, i->name, tmp); } + + //Start + app.lua.hook_note_netsync_end(nonce); } bool