#
# patch "ChangeLog"
# from [7977112837eb09182fb6799e38a65102597ada8c]
# to [d33d68dc607d41683f065b3776e01ee923617466]
#
# patch "lua.cc"
# from [76cfc26a5a3d0c64a9f244d78ad51c8975aa8d52]
# to [8430784d91bb9e1980222576875130d56bf3403c]
#
# patch "lua.hh"
# from [a1b3877535049b77b678d864354d030f8433854c]
# to [10ff3e44271236c23ac4c316bff67e6e2b35a6f9]
#
# patch "monotone.texi"
# from [97d124d7ac72f65675b5c8187e7b1f65357302fc]
# to [495c522c60665ce62c24e353f3c2ab6227f1f080]
#
# patch "netsync.cc"
# from [4d76025ec5cac103ea22addaef89caefb36e23ae]
# to [502c6ec70bb1fea01a686c02d7569be7c7f28626]
#
# patch "packet.cc"
# from [a39402aafb0ec789aa2b8b03689d9787260885b6]
# to [bfeb9fa42d45b9254137632ae776d1721e1df6c2]
#
# patch "packet.hh"
# from [3ecd9f0de0e37c56a105cfc6bfd8a5fdb84032c7]
# to [19cb7588b015bab35eed74ca84c46ba5195870d5]
#
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,12 @@
+2005-05-30 Timothy Brownawell
+
+ * packet.{cc,hh}, netsync.cc: on_revision_written callback now takes
+ the revision_id as an argument.
+ * lua.{cc,hh}: New Lua hook, note_netsync_commit.
+ * netsync.cc: At end of netsync session, call new hook for each
+ revision received.
+ monotone.texi: Document new hook.
+
2005-05-30 Matt Johnston
* netsync.cc: cosmetic linebreak tidying for "double-check the
--- lua.cc
+++ lua.cc
@@ -1121,3 +1121,26 @@
ll.call(2, 0);
return ll.ok();
}
+
+bool
+lua_hooks::hook_note_netsync_commit(revision_id const & new_id,
+ map const & certs)
+{
+ Lua ll(st);
+ ll
+ .func("note_netsync_commit")
+ .push_str(new_id.inner()());
+
+ ll.push_table();
+
+ for (map::const_iterator i = certs.begin();
+ i != certs.end(); ++i)
+ {
+ ll.push_str(i->first());
+ ll.push_str(i->second());
+ ll.set_table();
+ }
+
+ ll.call(2, 0);
+ return ll.ok();
+}
--- lua.hh
+++ lua.hh
@@ -116,6 +116,8 @@
// notification hooks
bool hook_note_commit(revision_id const & new_id,
std::map const & certs);
+ bool hook_note_netsync_commit(revision_id const & new_id,
+ std::map const & certs);
};
#endif // __LUA_HH__
--- monotone.texi
+++ monotone.texi
@@ -5183,6 +5183,12 @@
commit-notification systems such as mailing lists or news services. It
should not perform any security-critical operations.
address@hidden note_netsync_commit (@var{new_id}, @var{certs})
+
+Called by monotone after the version @var{new_id} is recieved through
+netsync. Other than the origin of @var{new_id}, this is identical to
+the note_commit hook.
+
@item get_branch_key (@var{branchname})
Returns a string which is the name of an @sc{rsa} private key used to sign
--- netsync.cc
+++ netsync.cc
@@ -235,6 +235,8 @@
auto_ptr revision_in_ticker;
auto_ptr revision_out_ticker;
auto_ptr revision_checked_ticker;
+
+ vector written_revisions;
map< std::pair,
boost::shared_ptr > merkle_tables;
@@ -260,9 +262,9 @@
Netxx::socket_type sock,
Netxx::Timeout const & to);
- virtual ~session() {}
+ virtual ~session();
- void rev_written_callback();
+ void rev_written_callback(revision_id rid);
id mk_nonce();
void mark_recent_io();
@@ -450,7 +452,7 @@
}
dbw.set_on_revision_written(boost::bind(&session::rev_written_callback,
- this));
+ this, _1));
// we will panic here if the user doesn't like urandom and we can't give
// them a real entropy-driven random.
@@ -477,9 +479,29 @@
requested_items.insert(make_pair(epoch_item, boost::shared_ptr< set >(new set())));
}
-void session::rev_written_callback()
+session::~session()
{
+ for(vector::iterator i=written_revisions.begin();
+ i!=written_revisions.end(); ++i)
+ {
+ map certs;
+ vector< revision > ctmp;
+ app.db.get_revision_certs(*i, ctmp);
+ for (vector< revision >::const_iterator j = ctmp.begin();
+ j != ctmp.end(); ++j)
+ {
+ cert_value vtmp;
+ decode_base64(j->inner().value, vtmp);
+ certs.insert(make_pair(j->inner().name, vtmp));
+ }
+ app.lua.hook_note_netsync_commit(*i, certs);
+ }
+}
+
+void session::rev_written_callback(revision_id rid)
+{
if(revision_checked_ticker.get()) ++(*revision_checked_ticker);
+ written_revisions.push_back(rid);
}
id
--- packet.cc
+++ packet.cc
@@ -434,7 +434,9 @@
}
-void packet_consumer::set_on_revision_written(boost::function0 const & x)
+void
+packet_consumer::set_on_revision_written(boost::function1 const & x)
{
on_revision_written=x;
}
@@ -893,7 +895,7 @@
if (dp->all_prerequisites_satisfied())
{
pimpl->app.db.put_revision(ident, dat);
- if(on_revision_written) on_revision_written();
+ if(on_revision_written) on_revision_written(ident);
pimpl->accepted_revision(ident, *this);
}
}
@@ -1025,7 +1027,9 @@
#define DOIT(x) pimpl->do_packet(boost::shared_ptr(new x));
-void packet_db_valve::set_on_revision_written(boost::function0 const & x)
+void
+packet_db_valve::set_on_revision_written(boost::function1 const & x)
{
on_revision_written=x;
pimpl->writer.set_on_revision_written(x);
--- packet.hh
+++ packet.hh
@@ -37,10 +37,10 @@
struct packet_consumer
{
protected:
- boost::function0 on_revision_written;
+ boost::function1 on_revision_written;
public:
- virtual void set_on_revision_written(boost::function0 const & x);
+ virtual void set_on_revision_written(boost::function1 const & x);
virtual ~packet_consumer() {}
virtual void consume_file_data(file_id const & ident,
@@ -162,7 +162,7 @@
packet_db_valve(app_state & app,
bool take_keys = false);
virtual ~packet_db_valve();
- virtual void set_on_revision_written(boost::function0 const & x);
+ virtual void set_on_revision_written(boost::function1 const & x);
virtual void consume_file_data(file_id const & ident,
file_data const & dat);
virtual void consume_file_delta(file_id const & id_old,