Hello,
I'm slowly hacking monotone dumb transport for my personal
use (i don't have time to polish it to publishable state)
and found that it's very slow in creating merkle tree of
revisions and certs. It's because there is no access to
cert_id (it's SHA1 of all cert values joined with colon).
For dumb protocol and any other tool that could simulate
monotone server it's a must to have possibility to query for:
- packet of specific cert
- ids of certificates for given selector (or only revision)
Currently cert packet api provids only "get all cert packets
of revision". It's usually redundant information because we
usually need only cert_id and packet is needed only if
algrorithm decides that it's to be transfered.
So my proposition is to add new public entity 'cert_id' and
commands to retrieve it. For sake of simplicity it will be the
same as database cert_id (hash field of revision_certs table).
Automate commands:
get_packet_for_cert CERTID
Get single packet for cert with given certificate id.
select_certs SELECTOR
Get certs identifiers for revisions specified by SELECTOR.
Each output line contains pair <REVID,CERTID> separated by one
space character.
That would render mtndumb as fast as netsync when it comes
to build merkle tree. I bet it would be usable also for databases
as big as monotone.ca. Only difference would be transport.
Question:
Any objections for adding these kind of commands ?
[_Draft_ of implementation attached]
PS1. I know about nuskool effort but i also realize that it's
still lot to be done to make it work so i think that mtndumb
is really feasible tool for small personal projects.
Currently it works reasonably well with database of size ~12MB
(1200 revisions) i know it's not much but it's something.
PS2. Anybody uses mtndumb ?
PS3. Monotone dumb is file/sftp/ftp/http* transport for synchronizing
montone database.
Best regards,
--
Zbigniew Zagórski
/ software developer / geek / happy daddy /
#
# old_revision [9b264ec9247ce99cd1fdc5293e869c1a60b01c4c]
#
# patch "automate.cc"
# from [9a700bfc52a6a21e3b5d2d930ad634d455dafcae]
# to [1ca44a73bf87274762a68c436f3b6b628b94d4aa]
#
============================================================
--- automate.cc 9a700bfc52a6a21e3b5d2d930ad634d455dafcae
+++ automate.cc 1ca44a73bf87274762a68c436f3b6b628b94d4aa
@@ -517,6 +517,41 @@ CMD_AUTOMATE(select, N_("SELECTOR"),
output << *i << '\n';
}
+// Name: select_cert
+// Arguments:
+// 1: selector
+// Added in: 8.1
+// Purpose: Prints all the certs for revisions that match the given selector.
+// Output format: A list of pairs [cert_id, revision_id], both in hexadecimal, each followed by a
+// newline. There is no particular order of values.
+// Error conditions: None.
+CMD_AUTOMATE(select_cert, N_("SELECTOR"),
+ N_("Lists certs for revisions that match a selector"),
+ "",
+ options::opts::none)
+{
+ N(args.size() == 1,
+ F("wrong argument count"));
+
+ database db(app);
+ project_t project(db);
+ set<revision_id> completions;
+ expand_selector(app.opts, app.lua, project, idx(args, 0)(), completions);
+
+
+ for (set<revision_id>::const_iterator i = completions.begin();
+ i != completions.end(); ++i)
+ {
+ std::vector<id> cert_ids;
+ project.get_revision_cert_hashes(*i, cert_ids);
+ for(std::vector<id>::const_iterator ii = cert_ids.begin();
+ ii != cert_ids.end(); ++ii )
+ {
+ output << *i << ' ' << *ii << '\n';
+ }
+ }
+}
+
struct node_info
{
bool exists;
@@ -1499,6 +1534,37 @@ CMD_AUTOMATE(packets_for_certs, N_("REVI
pw.consume_revision_cert(*i);
}
+// Name: packet_for_cert
+// Arguments:
+// 1: a cert id
+// Added in: 8.1
+// Purpose: Prints the cert associated/
+//
+// Output format: certs in "monotone read" compatible packet format
+//
+// Error conditions: If the cert id specified is unknown or
+// invalid prints an error message to stderr and exits with status 1.
+CMD_AUTOMATE(packet_for_cert, N_("CERTID"),
+ N_("Prints the certs in packet format"),
+ "",
+ options::opts::none)
+{
+ N(args.size() == 1,
+ F("wrong argument count"));
+
+ database db(app);
+ //project_t project(db);
+ packet_writer pw(output);
+
+ id c_id(decode_hexenc(idx(args, 0)()));
+ revision<cert> cert;
+
+ //N(db.cert_exists(c_id), F("no such cert '%s'") % c_id);
+ db.get_revision_cert(c_id, cert);
+
+ pw.consume_revision_cert(cert);
+}
+
// Name: packet_for_fdata
// Arguments:
// 1: a file id
_______________________________________________
Monotone-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monotone-devel