#
#
# patch "ChangeLog"
# from [d5b9e93384498832851a2c10d85b5567da68b387]
# to [a9581a90d81332a9c0e353e7e6f978057282d921]
#
# patch "automate.cc"
# from [5bba76ec5f876b32c8dae8f064196cac46a6e59e]
# to [6ef98ec9058f9730edd0fe03ee677e06ea42a10b]
#
# patch "basic_io.cc"
# from [dd67a9179add62505ba6388e4137d9407e1cf3dd]
# to [5c8f164d4a3f4829497c834164cb09ac6341467c]
#
# patch "basic_io.hh"
# from [f3f011170676902c459bd3b714a0f4110daaad7a]
# to [2f590c89a77dd2c425ecc8ce5a0922124f120284]
#
# patch "cset.cc"
# from [6d52ab1736e3c9abe066d2696c8c8e9a78130f5d]
# to [17cc4461f4e98e06986d4543b0952be1272ef3e9]
#
# patch "legacy.cc"
# from [f0e7de059d21606fe99593a481adc9ad5a021858]
# to [56eba9490503059bb62f34ca4d04007d3b56bbd5]
#
# patch "revision.cc"
# from [ad08cf6223f0c96a4719a71fd8e8b0a28a32af26]
# to [aec2bbf225b60c4611b36a6434788375cab0410d]
#
# patch "roster.cc"
# from [f8dadb5487d8385b6572fdc658dd30f1c4481e3f]
# to [61e2bb7bd0c0616543f6973abc2be585a5872860]
#
# patch "vocab.cc"
# from [f74bcb1c80f9c49a91923861feaef0b8693da0c6]
# to [26b5217388292d2f21560bdcf929ff691aa9cf76]
#
# patch "vocab.hh"
# from [cd8bcbabc1b8b4d26809c8c90beee68289902f00]
# to [bd9e900a5b68d224173b97078797768aec6b6cc3]
#
# patch "vocab_terms.hh"
# from [3e28281bce1cc56b544dd17c356ba139f9bd5e22]
# to [346786c6c93907481a5c0691b3d60811827df9a3]
#
============================================================
--- ChangeLog d5b9e93384498832851a2c10d85b5567da68b387
+++ ChangeLog a9581a90d81332a9c0e353e7e6f978057282d921
@@ -1,3 +1,27 @@
+2006-05-20 Derek Scherger
+
+ * automate.cc: add basic_io symbols
+ (hook_get_revision_cert_trust, automate_certs): push symbols
+ (automate_keys): push symbols and hexenc's
+ * basic_io.{cc,hh}
+ (is_xdigit, is_alpha, is_alnum, is_space): move to vocab.hh
+ (push_hex_pair, push_hex_triple, push_str_pair, push_file_pair,
+ push_str_multi, push_str_triple, print_stanza): use symbol and
+ hexenc in place of strings to avoid repeated/redundant
+ validations which account for 4% of the client profile of a fresh
+ pull of the monotone db
+ * cset.cc (print_cset): push symbols and hexenc's
+ * legacy.cc (read_dot_mt_attrs, extract_renames,
+ get_manifest_and_renames_for_rev): parse symbols
+ * revision.cc (print_edge, print_stanza): push symbols and hexenc's
+ * roster.cc (push_marking, print_to): push symbols and hexenc's
+ * vocab.cc (is_xdigit): move to vocab.hh
+ (verify): new verification for symbol type
+ * vocab.hh (is_xdigit, is_alpha, is_alnum, is_space): add functions
+ from basic_io.hh
+ * vocab_terms.hh (symbol): new ATOMIC type for basic_io symbols
+ which allow only [a-zA-Z0-9_]
+
2006-05-16 Timothy Brownawell
* automate.cc: Uncomment automate_common_ancestors.
============================================================
--- automate.cc 5bba76ec5f876b32c8dae8f064196cac46a6e59e
+++ automate.cc 6ef98ec9058f9730edd0fe03ee677e06ea42a10b
@@ -779,6 +779,23 @@
}
}
+namespace
+{
+ namespace syms
+ {
+ symbol const key("key");
+ symbol const signature("signature");
+ symbol const name("name");
+ symbol const value("value");
+ symbol const trust("trust");
+
+ symbol const public_hash("public_hash");
+ symbol const private_hash("private_hash");
+ symbol const public_location("public_location");
+ symbol const private_location("private_location");
+ }
+};
+
// Name: certs
// Arguments:
// 1: a revision id
@@ -862,7 +879,7 @@
bool trusted = app.lua.hook_get_revision_cert_trust(signers, ident,
name, tv);
- st.push_str_pair("key", keyid());
+ st.push_str_pair(syms::key, keyid());
std::string stat;
switch (status)
@@ -877,11 +894,11 @@
stat = "unknown";
break;
}
- st.push_str_pair("signature", stat);
+ st.push_str_pair(syms::signature, stat);
- st.push_str_pair("name", name());
- st.push_str_pair("value", tv());
- st.push_str_pair("trust", (trusted ? "trusted" : "untrusted"));
+ st.push_str_pair(syms::name, name());
+ st.push_str_pair(syms::value, tv());
+ st.push_str_pair(syms::trust, (trusted ? "trusted" : "untrusted"));
pr.print_stanza(st);
}
@@ -1595,13 +1612,13 @@
i = items.begin(); i != items.end(); ++i)
{
basic_io::stanza stz;
- stz.push_str_pair("name", i->first);
- stz.push_hex_pair("public_hash", i->second.get<0>()());
+ stz.push_str_pair(syms::name, i->first);
+ stz.push_hex_pair(syms::public_hash, i->second.get<0>());
if (!i->second.get<1>()().empty())
- stz.push_hex_pair("private_hash", i->second.get<1>()());
- stz.push_str_multi("public_location", i->second.get<2>());
+ stz.push_hex_pair(syms::private_hash, i->second.get<1>());
+ stz.push_str_multi(syms::public_location, i->second.get<2>());
if (!i->second.get<3>().empty())
- stz.push_str_multi("private_location", i->second.get<3>());
+ stz.push_str_multi(syms::private_location, i->second.get<3>());
prt.print_stanza(stz);
}
output.write(prt.buf.data(), prt.buf.size());
============================================================
--- basic_io.cc dd67a9179add62505ba6388e4137d9407e1cf3dd
+++ basic_io.cc 5c8f164d4a3f4829497c834164cb09ac6341467c
@@ -62,55 +62,37 @@
basic_io::stanza::stanza() : indent(0)
{}
-void basic_io::stanza::push_hex_pair(std::string const & k, std::string const & v)
+void basic_io::stanza::push_hex_pair(symbol const & k, hexenc const & v)
{
- for (std::string::const_iterator i = k.begin(); i != k.end(); ++i)
- I(is_alnum(*i) || *i == '_');
-
- for (std::string::const_iterator i = v.begin(); i != v.end(); ++i)
- I(is_xdigit(*i));
-
- entries.push_back(std::make_pair(k, "[" + v + "]"));
- if (k.size() > indent)
- indent = k.size();
+ entries.push_back(std::make_pair(k, "[" + v() + "]"));
+ if (k().size() > indent)
+ indent = k().size();
}
-void basic_io::stanza::push_hex_triple(std::string const & k,
+void basic_io::stanza::push_hex_triple(symbol const & k,
std::string const & n,
- std::string const & v)
+ hexenc const & v)
{
- for (std::string::const_iterator i = k.begin(); i != k.end(); ++i)
- I(is_alnum(*i) || *i == '_');
-
- for (std::string::const_iterator i = v.begin(); i != v.end(); ++i)
- I(is_xdigit(*i));
-
- entries.push_back(std::make_pair(k, escape(n) + " " + "[" + v + "]"));
- if (k.size() > indent)
- indent = k.size();
+ entries.push_back(std::make_pair(k, escape(n) + " " + "[" + v() + "]"));
+ if (k().size() > indent)
+ indent = k().size();
}
-void basic_io::stanza::push_str_pair(std::string const & k, std::string const & v)
+void basic_io::stanza::push_str_pair(symbol const & k, std::string const & v)
{
- for (std::string::const_iterator i = k.begin(); i != k.end(); ++i)
- I(is_alnum(*i) || *i == '_');
-
entries.push_back(std::make_pair(k, escape(v)));
- if (k.size() > indent)
- indent = k.size();
+ if (k().size() > indent)
+ indent = k().size();
}
-void basic_io::stanza::push_file_pair(std::string const & k, file_path const & v)
+void basic_io::stanza::push_file_pair(symbol const & k, file_path const & v)
{
push_str_pair(k, v.as_internal());
}
-void basic_io::stanza::push_str_multi(std::string const & k,
+void basic_io::stanza::push_str_multi(symbol const & k,
std::vector const & v)
{
- for (std::string::const_iterator i = k.begin(); i != k.end(); ++i)
- I(is_alnum(*i) || *i == '_');
-
std::string val;
bool first = true;
for (std::vector::const_iterator i = v.begin();
@@ -122,20 +104,17 @@
first = false;
}
entries.push_back(std::make_pair(k, val));
- if (k.size() > indent)
- indent = k.size();
+ if (k().size() > indent)
+ indent = k().size();
}
-void basic_io::stanza::push_str_triple(std::string const & k,
+void basic_io::stanza::push_str_triple(symbol const & k,
std::string const & n,
std::string const & v)
{
- for (std::string::const_iterator i = k.begin(); i != k.end(); ++i)
- I(is_alnum(*i) || *i == '_');
-
entries.push_back(std::make_pair(k, escape(n) + " " + escape(v)));
- if (k.size() > indent)
- indent = k.size();
+ if (k().size() > indent)
+ indent = k().size();
}
@@ -151,12 +130,12 @@
if (LIKELY(!buf.empty()))
buf += '\n';
- for (std::vector >::const_iterator i = st.entries.begin();
+ for (std::vector >::const_iterator i = st.entries.begin();
i != st.entries.end(); ++i)
{
- for (size_t k = i->first.size(); k < st.indent; ++k)
+ for (size_t k = i->first().size(); k < st.indent; ++k)
buf += ' ';
- buf.append(i->first);
+ buf.append(i->first());
buf += ' ';
buf.append(i->second);
buf += '\n';
============================================================
--- basic_io.hh f3f011170676902c459bd3b714a0f4110daaad7a
+++ basic_io.hh 2f590c89a77dd2c425ecc8ce5a0922124f120284
@@ -11,6 +11,7 @@
// revision_set. every revision_set contains a number of change_sets, so
// their i/o routines are somewhat related.
+#include
#include
#include
#include
@@ -18,44 +19,11 @@
#include "paths.hh"
#include "sanity.hh"
+#include "vocab.hh"
-#include
-
namespace basic_io
{
- inline bool is_xdigit(char x)
- {
- return ((x >= '0' && x <= '9')
- || (x >= 'a' && x <= 'f')
- || (x >= 'A' && x <= 'F'));
- }
-
- inline bool is_alpha(char x)
- {
- return ((x >= 'a' && x <= 'z')
- || (x >= 'A' && x <= 'Z'));
- }
-
- inline bool is_alnum(char x)
- {
- return ((x >= '0' && x <= '9')
- || (x >= 'a' && x <= 'z')
- || (x >= 'A' && x <= 'Z'));
- }
-
- inline bool is_space(char x)
- {
- return (x == ' ')
- || (x == '\n')
- || (x == '\t')
- || (x == '\r')
- || (x == '\v')
- || (x == '\f');
- }
-
-
-
typedef enum
{
TOK_SYMBOL,
@@ -250,13 +218,13 @@
{
stanza();
size_t indent;
- std::vector > entries;
- void push_hex_pair(std::string const & k, std::string const & v);
- void push_hex_triple(std::string const & k, std::string const & n, std::string const & v);
- void push_str_pair(std::string const & k, std::string const & v);
- void push_str_triple(std::string const & k, std::string const & n, std::string const & v);
- void push_file_pair(std::string const & k, file_path const & v);
- void push_str_multi(std::string const & k,
+ std::vector > entries;
+ void push_hex_pair(symbol const & k, hexenc const & v);
+ void push_hex_triple(symbol const & k, std::string const & n, hexenc const & v);
+ void push_str_pair(symbol const & k, std::string const & v);
+ void push_str_triple(symbol const & k, std::string const & n, std::string const & v);
+ void push_file_pair(symbol const & k, file_path const & v);
+ void push_str_multi(symbol const & k,
std::vector const & v);
};
@@ -310,15 +278,15 @@
inline void sym(std::string & v) { v = token; sym(); }
inline void hex(std::string & v) { v = token; hex(); }
inline bool symp() { return ttype == basic_io::TOK_SYMBOL; }
- inline bool symp(std::string const & val)
+ inline bool symp(symbol const & val)
{
- return ttype == basic_io::TOK_SYMBOL && token == val;
+ return ttype == basic_io::TOK_SYMBOL && token == val();
}
- inline void esym(std::string const & val)
+ inline void esym(symbol const & val)
{
- if (!(ttype == basic_io::TOK_SYMBOL && token == val))
+ if (!(ttype == basic_io::TOK_SYMBOL && token == val()))
err("wanted symbol '"
- + val +
+ + val() +
+ "', got "
+ tt2str(ttype)
+ (token.empty()
============================================================
--- cset.cc 6d52ab1736e3c9abe066d2696c8c8e9a78130f5d
+++ cset.cc 17cc4461f4e98e06986d4543b0952be1272ef3e9
@@ -238,18 +238,18 @@
namespace syms
{
// cset symbols
- string const delete_node("delete");
- string const rename_node("rename");
- string const content("content");
- string const add_file("add_file");
- string const add_dir("add_dir");
- string const patch("patch");
- string const from("from");
- string const to("to");
- string const clear("clear");
- string const set("set");
- string const attr("attr");
- string const value("value");
+ symbol const delete_node("delete");
+ symbol const rename_node("rename");
+ symbol const content("content");
+ symbol const add_file("add_file");
+ symbol const add_dir("add_dir");
+ symbol const patch("patch");
+ symbol const from("from");
+ symbol const to("to");
+ symbol const clear("clear");
+ symbol const set("set");
+ symbol const attr("attr");
+ symbol const value("value");
}
}
@@ -291,7 +291,7 @@
file_path p(i->first);
basic_io::stanza st;
st.push_file_pair(syms::add_file, file_path(i->first));
- st.push_hex_pair(syms::content, i->second.inner()());
+ st.push_hex_pair(syms::content, i->second.inner());
printer.print_stanza(st);
}
@@ -301,8 +301,8 @@
file_path p(i->first);
basic_io::stanza st;
st.push_file_pair(syms::patch, file_path(i->first));
- st.push_hex_pair(syms::from, i->second.first.inner()());
- st.push_hex_pair(syms::to, i->second.second.inner()());
+ st.push_hex_pair(syms::from, i->second.first.inner());
+ st.push_hex_pair(syms::to, i->second.second.inner());
printer.print_stanza(st);
}
============================================================
--- legacy.cc f0e7de059d21606fe99593a481adc9ad5a021858
+++ legacy.cc 56eba9490503059bb62f34ca4d04007d3b56bbd5
@@ -10,6 +10,14 @@
namespace legacy
{
+ namespace
+ {
+ namespace syms
+ {
+ symbol const file("file");
+ }
+ };
+
// cf. work.cc:read_attr_map in the pre-roster code.
void
read_dot_mt_attrs(data const & dat, dot_mt_attrs_map & attr)
@@ -22,14 +30,14 @@
attr.clear();
- while (parser.symp("file"))
+ while (parser.symp(syms::file))
{
parser.sym();
parser.str(file);
file_path fp = file_path_internal(file);
while (parser.symp() &&
- !parser.symp("file"))
+ !parser.symp(syms::file))
{
parser.sym(name);
parser.str(value);
@@ -42,17 +50,17 @@
{
namespace syms
{
- std::string const new_manifest("new_manifest");
- std::string const old_revision("old_revision");
- std::string const old_manifest("old_manifest");
- std::string const patch("patch");
- std::string const from("from");
- std::string const to("to");
- std::string const add_file("add_file");
- std::string const delete_file("delete_file");
- std::string const delete_dir("delete_dir");
- std::string const rename_file("rename_file");
- std::string const rename_dir("rename_dir");
+ symbol const new_manifest("new_manifest");
+ symbol const old_revision("old_revision");
+ symbol const old_manifest("old_manifest");
+ symbol const patch("patch");
+ symbol const from("from");
+ symbol const to("to");
+ symbol const add_file("add_file");
+ symbol const delete_file("delete_file");
+ symbol const delete_dir("delete_dir");
+ symbol const rename_file("rename_file");
+ symbol const rename_dir("rename_dir");
}
}
============================================================
--- revision.cc ad08cf6223f0c96a4719a71fd8e8b0a28a32af26
+++ revision.cc aec2bbf225b60c4611b36a6434788375cab0410d
@@ -1491,9 +1491,9 @@
{
namespace syms
{
- std::string const format_version("format_version");
- std::string const old_revision("old_revision");
- std::string const new_manifest("new_manifest");
+ symbol const format_version("format_version");
+ symbol const old_revision("old_revision");
+ symbol const new_manifest("new_manifest");
}
}
@@ -1502,7 +1502,7 @@
edge_entry const & e)
{
basic_io::stanza st;
- st.push_hex_pair(syms::old_revision, edge_old_revision(e).inner()());
+ st.push_hex_pair(syms::old_revision, edge_old_revision(e).inner());
printer.print_stanza(st);
print_cset(printer, edge_changes(e));
}
@@ -1519,7 +1519,7 @@
printer.print_stanza(format_stanza);
basic_io::stanza manifest_stanza;
- manifest_stanza.push_hex_pair(syms::new_manifest, rev.new_manifest.inner()());
+ manifest_stanza.push_hex_pair(syms::new_manifest, rev.new_manifest.inner());
printer.print_stanza(manifest_stanza);
for (edge_map::const_iterator edge = rev.edges.begin();
============================================================
--- roster.cc f8dadb5487d8385b6572fdc658dd30f1c4481e3f
+++ roster.cc 61e2bb7bd0c0616543f6973abc2be585a5872860
@@ -2266,20 +2266,20 @@
namespace syms
{
// roster symbols
- string const format_version("format_version");
- string const dir("dir");
- string const file("file");
- string const content("content");
- string const attr("attr");
+ symbol const format_version("format_version");
+ symbol const dir("dir");
+ symbol const file("file");
+ symbol const content("content");
+ symbol const attr("attr");
// 'local' roster and marking symbols
- string const ident("ident");
- string const birth("birth");
- string const dormant_attr("dormant_attr");
+ symbol const ident("ident");
+ symbol const birth("birth");
+ symbol const dormant_attr("dormant_attr");
- string const path_mark("path_mark");
- string const content_mark("content_mark");
- string const attr_mark("attr_mark");
+ symbol const path_mark("path_mark");
+ symbol const content_mark("content_mark");
+ symbol const attr_mark("attr_mark");
}
}
@@ -2291,17 +2291,17 @@
{
I(!null_id(mark.birth_revision));
- st.push_hex_pair(syms::birth, mark.birth_revision.inner()());
+ st.push_hex_pair(syms::birth, mark.birth_revision.inner());
for (set::const_iterator i = mark.parent_name.begin();
i != mark.parent_name.end(); ++i)
- st.push_hex_pair(syms::path_mark, i->inner()());
+ st.push_hex_pair(syms::path_mark, i->inner());
if (is_file_t(curr))
{
for (set::const_iterator i = mark.file_content.begin();
i != mark.file_content.end(); ++i)
- st.push_hex_pair(syms::content_mark, i->inner()());
+ st.push_hex_pair(syms::content_mark, i->inner());
}
else
I(mark.file_content.empty());
@@ -2313,7 +2313,7 @@
I(am != mark.attrs.end());
for (set::const_iterator j = am->second.begin();
j != am->second.end(); ++j)
- st.push_hex_triple(syms::attr_mark, i->first(), j->inner()());
+ st.push_hex_triple(syms::attr_mark, i->first(), j->inner());
}
}
@@ -2392,7 +2392,7 @@
{
file_t ftmp = downcast_to_file_t(curr);
st.push_file_pair(syms::file, fp);
- st.push_hex_pair(syms::content, ftmp->content.inner()());
+ st.push_hex_pair(syms::content, ftmp->content.inner());
// L(FL("printing file %s\n") % fp);
}
============================================================
--- vocab.cc f74bcb1c80f9c49a91923861feaef0b8693da0c6
+++ vocab.cc 26b5217388292d2f21560bdcf929ff691aa9cf76
@@ -48,13 +48,6 @@
val.ok = true;
}
-inline bool is_xdigit(char x)
-{
- return ((x >= '0' && x <= '9')
- || (x >= 'a' && x <= 'f')
- || (x >= 'A' && x <= 'F'));
-}
-
inline void
verify(hexenc & val)
{
@@ -87,7 +80,21 @@
val.ok = true;
}
+inline void
+verify(symbol & val)
+{
+ if (val.ok)
+ return;
+ for (string::const_iterator i = val().begin(); i != val().end(); ++i)
+ {
+ N(is_alnum(*i) || *i == '_',
+ F("bad character '%c' in symbol '%s'") % *i % val);
+ }
+
+ val.ok = true;
+}
+
inline void
verify(cert_name & val)
{
============================================================
--- vocab.hh cd8bcbabc1b8b4d26809c8c90beee68289902f00
+++ vocab.hh bd9e900a5b68d224173b97078797768aec6b6cc3
@@ -20,7 +20,36 @@
template
void dump(T const &, std::string &);
+inline bool is_xdigit(char x)
+{
+ return ((x >= '0' && x <= '9')
+ || (x >= 'a' && x <= 'f')
+ || (x >= 'A' && x <= 'F'));
+}
+inline bool is_alpha(char x)
+{
+ return ((x >= 'a' && x <= 'z')
+ || (x >= 'A' && x <= 'Z'));
+}
+
+inline bool is_alnum(char x)
+{
+ return ((x >= '0' && x <= '9')
+ || (x >= 'a' && x <= 'z')
+ || (x >= 'A' && x <= 'Z'));
+}
+
+inline bool is_space(char x)
+{
+ return (x == ' ')
+ || (x == '\n')
+ || (x == '\t')
+ || (x == '\r')
+ || (x == '\v')
+ || (x == '\f');
+}
+
#define ENCODING(enc) \
\
template \
============================================================
--- vocab_terms.hh 3e28281bce1cc56b544dd17c356ba139f9bd5e22
+++ vocab_terms.hh 346786c6c93907481a5c0691b3d60811827df9a3
@@ -10,6 +10,7 @@
ATOMIC_NOVERIFY(external); // "external" string in unknown system charset
ATOMIC_NOVERIFY(utf8); // unknown string in UTF8 charset
ATOMIC(ace); // unknown string in ACE form
+ATOMIC(symbol); // valid basic io symbol (alphanumeric or _ chars)
ATOMIC(path_component); // piece of a path (see paths.hh)
@@ -44,7 +45,7 @@
DECORATE(revision); // thing associated with a revision
DECORATE(manifest); // thing associated with a manifest
DECORATE(file); // thing associated with a file
-DECORATE(key); // thing associated with a key
+DECORATE(key); // thing associated with a key
DECORATE(epoch); // thing associated with an epoch
ENCODING(gzip); // thing which is gzipped