# # # patch "gsync.hh" # from [ce72087f6b1b5d34b400b548808596c346f9b594] # to [c7544438a00e6d3224c9886a8fbc00ed3abbcb18] # # patch "http_client.cc" # from [4bd52563930130759bd40ff3d841d00013500d20] # to [818d742b9a9e6e1ef0f51d07ccf9ff39136f591f] # # patch "json_io.hh" # from [d48db601ff48f7a46c17212542800d0d232de2a8] # to [5d45274449db7c24ee44ef874a9d96d0cb93e2d0] # # patch "restrictions.cc" # from [87c7a8736ee7c289e9de64923ef04bd8016f2801] # to [8ca8ad41abe6b031cecb37f2f34979084a5710b9] # ============================================================ --- gsync.hh ce72087f6b1b5d34b400b548808596c346f9b594 +++ gsync.hh c7544438a00e6d3224c9886a8fbc00ed3abbcb18 @@ -30,6 +30,7 @@ public: std::set & theirs) const = 0; virtual void push_rev(revision_id const & rid) const = 0; + virtual ~channel() {} }; extern void ============================================================ --- http_client.cc 4bd52563930130759bd40ff3d841d00013500d20 +++ http_client.cc 818d742b9a9e6e1ef0f51d07ccf9ff39136f591f @@ -48,19 +48,19 @@ http_client::http_client(options & opts, http_client::http_client(options & opts, lua_hooks & lua, - uri const & u, + uri const & u, globish const & include_pattern, globish const & exclude_pattern) : opts(opts), lua(lua), - u(u), - include_pattern(include_pattern), + u(u), + include_pattern(include_pattern), exclude_pattern(exclude_pattern), stream(build_stream_to_server(opts, lua, u, include_pattern, exclude_pattern, (u.port.empty() ? constants::default_http_port : lexical_cast(u.port)), - Netxx::Timeout(static_cast(constants::netsync_timeout_seconds)))), - nb(new Netbuf(*stream)), + Netxx::Timeout(static_cast(constants::netsync_timeout_seconds)))), + nb(new Netbuf(*stream)), io(new iostream(&(*nb))), open(true) {} @@ -71,7 +71,7 @@ http_client::transact_json(json_value_t if (!open) { L(FL("reopening connection")); - stream = build_stream_to_server(opts, lua, u, include_pattern, exclude_pattern, + stream = build_stream_to_server(opts, lua, u, include_pattern, exclude_pattern, constants::default_http_port, Netxx::Timeout(static_cast(constants::netsync_timeout_seconds))); nb = shared_ptr< Netbuf >(new Netbuf(*stream)); @@ -93,12 +93,12 @@ http_client::transact_json(json_value_t "Accept: application/jsonrequest\r\n" "Accept-Encoding: identity\r\n" "Connection: Keep-Alive\r\n" - "\r\n") + "\r\n") % (u.path.empty() ? "/" : u.path) - % u.host + % u.host % lexical_cast(out.buf.size())).str(); - L(FL("http_client: sending request [[POST %s HTTP/1.0]]") + L(FL("http_client: sending request [[POST %s HTTP/1.0]]") % (u.path.empty() ? "/" : u.path)); L(FL("http_client: to [[Host: %s]]") % u.host); L(FL("http_client: sending %d-byte body") % out.buf.size()); @@ -118,7 +118,7 @@ http_client::transact_json(json_value_t } -void +void http_client::parse_http_status_line() { // We're only interested in 200-series responses @@ -131,8 +131,8 @@ http_client::parse_http_status_line() E(tmp.substr(0,pat.size()) == pat, F("HTTP status line: %s") % tmp); } -void -http_client::parse_http_header_line(size_t & content_length, +void +http_client::parse_http_header_line(size_t & content_length, bool & keepalive) { string k, v, rest; @@ -140,19 +140,14 @@ http_client::parse_http_header_line(size L(FL("http_client: header: [[%s %s]]") % k % v); std::getline(*io, rest); - if (k == "Content-Length:" - || k == "Content-length:" - || k == "content-length:") + if (k == "Content-Length:" || k == "Content-length:" || k == "content-length:") content_length = lexical_cast(v); - else if (k == "Connection:" - || k == "connection:") - keepalive = (v == "Keep-Alive" - || v == "Keep-alive" - || v == "keep-alive"); + else if (k == "Connection:" || k == "connection:") + keepalive = (v == "Keep-Alive" || v == "Keep-alive" || v == "keep-alive"); } -void +void http_client::crlf() { E(io->get() == '\r', F("expected CR in HTTP response")); @@ -160,7 +155,7 @@ http_client::crlf() } -void +void http_client::parse_http_response(std::string & data) { size_t content_length = 0; @@ -181,7 +176,7 @@ http_client::parse_http_response(std::st io->flush(); - if (!keepalive) + if (!keepalive) { L(FL("http_client: closing connection")); stream->close(); @@ -203,12 +198,16 @@ http_channel::inquire_about_revs(set & theirs) const { theirs.clear(); - json_value_t query = encode_msg_inquire(query_set); + json_value_t query = encode_msg_inquire(query_set); json_value_t response = client.transact_json(query); E(decode_msg_confirm(response, theirs), F("received unexpected reply to 'inquire' message")); } +void +http_channel::push_rev(revision_id const & rid) const +{ +} // Local Variables: // mode: C++ ============================================================ --- json_io.hh d48db601ff48f7a46c17212542800d0d232de2a8 +++ json_io.hh 5d45274449db7c24ee44ef874a9d96d0cb93e2d0 @@ -16,6 +16,7 @@ #include +#include "char_classifiers.hh" #include "paths.hh" #include "sanity.hh" #include "vocab.hh" @@ -31,7 +32,7 @@ namespace json_io struct printer; - struct json_value + struct json_value { virtual void write(printer &pr) = 0; virtual ~json_value() {} @@ -39,11 +40,11 @@ namespace json_io typedef boost::shared_ptr json_value_t; - struct json_object + struct json_object : public json_value { std::map fields; - void add(std::string const &str, json_value_t v) + void add(std::string const &str, json_value_t v) { fields.insert(std::make_pair(str, v)); } virtual void write(printer &pr); virtual ~json_object() {} @@ -51,19 +52,19 @@ namespace json_io typedef boost::shared_ptr json_object_t; - struct json_array + struct json_array : public json_value { std::vector fields; - void add(json_value_t v) + void add(json_value_t v) { fields.push_back(v); } - virtual void write(printer &pr); + virtual void write(printer &pr); virtual ~json_array() {} }; typedef boost::shared_ptr json_array_t; - struct json_string + struct json_string : public json_value { json_string(std::string const &s) : data(s) {} @@ -108,7 +109,7 @@ namespace json_io inline void peek() { if (LIKELY(curr != in.end())) - // we do want to distinguish between EOF and '\xff', + // we do want to distinguish between EOF and '\xff', // so we translate '\xff' to 255u lookahead = widen(*curr); else @@ -163,7 +164,7 @@ namespace json_io inline void read_escape(std::string & val, char c) { - switch (c) + switch (c) { case '/': case '\\': @@ -351,12 +352,12 @@ namespace json_io inline json_object_t - parse_object() + parse_object() { bool first = true; json_object_t obj(new json_object()); lbrace(); - while (ttype != TOK_RBRACE) + while (ttype != TOK_RBRACE) { if (!first) comma(); @@ -372,12 +373,12 @@ namespace json_io } inline json_array_t - parse_array() + parse_array() { bool first = true; json_array_t arr(new json_array()); lbracket(); - while (ttype != TOK_RBRACKET) + while (ttype != TOK_RBRACKET) { if (!first) comma(); @@ -406,7 +407,7 @@ namespace json_io return parse_array(); else if (ttype == TOK_STRING) return parse_string(); - else + else return json_value_t(); } @@ -430,7 +431,7 @@ namespace json_io std::string escape(std::string const & s); - // Note: printer uses a static buffer; thus only one buffer + // Note: printer uses a static buffer; thus only one buffer // may be referenced (globally). An invariant will be triggered // if more than one json_io::printer is instantiated. struct @@ -445,7 +446,7 @@ namespace json_io { buf.append(s); } - void append_indent() + void append_indent() { for (size_t i = 0; i < indent; ++i) buf += '\t'; @@ -465,21 +466,21 @@ namespace json_io builder(json_value_t v) : v(v), key("") {} builder() : v(new json_object()), key("") {} - json_object_t as_obj() + json_object_t as_obj() { json_object_t ob = boost::dynamic_pointer_cast(v); I(static_cast(ob)); return ob; } - json_array_t as_arr() + json_array_t as_arr() { json_array_t a = boost::dynamic_pointer_cast(v); I(static_cast(a)); return a; } - json_string_t as_str() + json_string_t as_str() { json_string_t s = boost::dynamic_pointer_cast(v); I(static_cast(s)); @@ -498,7 +499,7 @@ namespace json_io } void add_str(std::string const &s) - { + { I(key.empty()); as_arr()->add(json_string_t(new json_string(s))); } @@ -514,7 +515,7 @@ namespace json_io builder add_arr() { - I(key.empty()); + I(key.empty()); json_array_t a = as_arr(); json_array_t a2(new json_array()); a->add(a2); @@ -527,25 +528,25 @@ namespace json_io as_arr()->add(val); } - void set(json_value_t v) + void set(json_value_t v) { I(!key.empty()); as_obj()->add(key, v); } - void str(std::string const &s) + void str(std::string const &s) { set(json_string_t(new json_string(s))); } - builder obj() + builder obj() { json_object_t ob(new json_object()); set(ob); return builder(ob); } - builder arr() + builder arr() { json_array_t a(new json_array()); set(a); @@ -557,23 +558,23 @@ namespace json_io /////////////////////// query ////////////////////////// /////////////////////////////////////////////////////////// - struct + struct query { json_value_t v; query(json_value_t v) : v(v) {} - json_object_t as_obj() + json_object_t as_obj() { return boost::dynamic_pointer_cast(v); } - json_array_t as_arr() + json_array_t as_arr() { return boost::dynamic_pointer_cast(v); } - json_string_t as_str() + json_string_t as_str() { return boost::dynamic_pointer_cast(v); } @@ -584,7 +585,7 @@ namespace json_io } - query operator[](symbol const &key) + query operator[](symbol const &key) { json_object_t ob = as_obj(); if (static_cast(ob)) @@ -596,15 +597,15 @@ namespace json_io return bad(); } - query operator[](size_t &idx) + query operator[](size_t &idx) { json_array_t a = as_arr(); - if (static_cast(a) && idx < a->fields.size()) + if (static_cast(a) && idx < a->fields.size()) return query(a->fields.at(idx)); return bad(); } - bool len(size_t & length) { + bool len(size_t & length) { json_array_t a = as_arr(); if (static_cast(a)) { length = a->fields.size(); @@ -613,20 +614,20 @@ namespace json_io return false; } - json_value_t get() + json_value_t get() { return v; } - bool get(std::string & str) { + bool get(std::string & str) { json_string_t s = as_str(); - if (static_cast(s)) + if (static_cast(s)) { str = s->data; return true; } return false; - } + } }; } ============================================================ --- restrictions.cc 87c7a8736ee7c289e9de64923ef04bd8016f2801 +++ restrictions.cc 8ca8ad41abe6b031cecb37f2f34979084a5710b9 @@ -95,6 +95,7 @@ namespace virtual bool operator()(file_path const &) const = 0; protected: unknown_p() {} + virtual ~unknown_p() {} }; struct unknown_node : public unknown_p @@ -106,7 +107,7 @@ namespace { return known_paths.find(p) == known_paths.end(); } - + private: set const & known_paths; }; @@ -134,7 +135,7 @@ namespace return (known_paths.find(p) == known_paths.end() && !work.ignore_file(p)); } - + private: set const & known_paths; workspace & work;