# # # patch "network/connection_info.cc" # from [5edac2dd1159084bc7451cb7f2d733602772819e] # to [ea3efb9cd7ce7bfcf01def5b587b6e13eb95c14c] # # patch "network/connection_info.hh" # from [777e884cd05fa9559dd1c7306b31d10e0a3f0ab0] # to [25de3ca6cdb36b10c3f08cd44c3814edf8836dbe] # ============================================================ --- network/connection_info.cc 5edac2dd1159084bc7451cb7f2d733602772819e +++ network/connection_info.cc ea3efb9cd7ce7bfcf01def5b587b6e13eb95c14c @@ -48,7 +48,7 @@ netsync_connection_info::Client::Client( var_name("default-exclude-pattern")); if (db.var_exists(default_server_key)) - { + { var_value addr_value; db.get_var(default_server_key, addr_value); try @@ -61,38 +61,34 @@ netsync_connection_info::Client::Client( W(F("ignoring invalid default server address '%s': %s") % addr_value() % e.what()); } - } + } if (db.var_exists(default_include_pattern_key)) - { - var_value pattern_value; - db.get_var(default_include_pattern_key, pattern_value); - try - { - include_pattern = globish(pattern_value(), origin::user); - L(FL("loaded default branch include pattern: '%s'") % include_pattern); - } - catch (recoverable_failure & e) - { - W(F("ignoring invalid default branch include pattern '%s': %s") - % include_pattern % e.what()); - } + { + vector includes, excludes; + var_value pattern_value; - if (db.var_exists(default_exclude_pattern_key)) - { - db.get_var(default_exclude_pattern_key, pattern_value); - try - { - exclude_pattern = globish(pattern_value(), origin::user); - L(FL("loaded default branch exclude pattern: '%s'") % exclude_pattern); - } - catch (recoverable_failure & e) - { - W(F("ignoring invalid default branch exclude pattern '%s': %s") - % exclude_pattern % e.what()); - } - } - } + db.get_var(default_include_pattern_key, pattern_value); + includes.push_back(typecast_vocab(pattern_value)); + + if (db.var_exists(default_exclude_pattern_key)) + { + db.get_var(default_exclude_pattern_key, pattern_value); + excludes.push_back(typecast_vocab(pattern_value)); + } + + // we don't want to fail on faulty database defaults, + // but just ignore them altogether + try + { + set_include_exclude_pattern(includes, excludes); + } + catch (recoverable_failure & e) + { + W(F("ignoring invalid default include / exclude pattern: %s") + % e.what()); + } + } } netsync_connection_info::Client::~Client() @@ -194,13 +190,10 @@ void } void -netsync_connection_info::Client::set_include_pattern(vector const & pat) +netsync_connection_info::Client::set_include_exclude_pattern(vector const & inc, + vector const & exc) { - // do not overwrite default patterns - if (pat.size() == 0) - return; - - for (vector::const_iterator p = pat.begin(); p != pat.end(); p++) + for (vector::const_iterator p = inc.begin(); p != inc.end(); p++) { if ((*p)().find_first_of("'\"") != string::npos) { @@ -208,34 +201,42 @@ netsync_connection_info::Client::set_inc "%s") % (*p)()); } } - include_pattern = globish(pat); -} -globish -netsync_connection_info::Client::get_include_pattern() const -{ - return include_pattern; -} + globish new_include_pattern(inc); + L(FL("setting include pattern to '%s' (previously '%s')") + % new_include_pattern % include_pattern); + include_pattern = new_include_pattern; -void -netsync_connection_info::Client::set_exclude_pattern(vector const & pat) -{ - // do not overwrite default patterns - if (pat.size() == 0) - return; - - for (vector::const_iterator p = pat.begin(); p != pat.end(); p++) + if (exc.size() > 0) { - if ((*p)().find_first_of("'\"") != string::npos) + for (vector::const_iterator p = exc.begin(); p != exc.end(); p++) { - W(F("exclude branch pattern contains a quote character:\n" - "%s") % (*p)()); + if ((*p)().find_first_of("'\"") != string::npos) + { + W(F("exclude branch pattern contains a quote character:\n" + "%s") % (*p)()); + } } + globish new_exclude_pattern(exc); + L(FL("setting exclude pattern to '%s' (previously '%s')") + % new_exclude_pattern % exclude_pattern); + exclude_pattern = globish(exc); } - exclude_pattern = globish(pat); + else + { + // this is important, otherwise a specific include might get + // overwritten by an earlier default exclude + exclude_pattern = globish(); + } } globish +netsync_connection_info::Client::get_include_pattern() const +{ + return include_pattern; +} + +globish netsync_connection_info::Client::get_exclude_pattern() const { return exclude_pattern; @@ -253,19 +254,19 @@ netsync_connection_info::Client::set_raw if (db.var_exists(server_include)) { + vector includes, excludes; var_value pattern_value; + db.get_var(server_include, pattern_value); - include_pattern = globish(pattern_value(), origin::user); - L(FL("loaded default branch include pattern for resource %s: '%s'") - % uri.resource % include_pattern); + includes.push_back(typecast_vocab(pattern_value)); if (db.var_exists(server_exclude)) { db.get_var(server_exclude, pattern_value); - exclude_pattern = globish(pattern_value(), origin::user); - L(FL("loaded default branch exclude pattern for resource %s: '%s'") - % uri.resource % exclude_pattern); + excludes.push_back(typecast_vocab(pattern_value)); } + + set_include_exclude_pattern(includes, excludes); } } @@ -404,8 +405,7 @@ netsync_connection_info::setup_from_sync excludes); } - info->client.set_include_pattern(includes); - info->client.set_exclude_pattern(excludes); + info->client.set_include_exclude_pattern(includes, excludes); info->client.ensure_completeness(); info->client.maybe_set_argv(lua); @@ -435,8 +435,7 @@ netsync_connection_info::setup_from_uri( } else { - info->client.set_include_pattern(includes); - info->client.set_exclude_pattern(excludes); + info->client.set_include_exclude_pattern(includes, excludes); } info->client.ensure_completeness(); @@ -457,8 +456,7 @@ netsync_connection_info::setup_from_serv info->client.conn_type = type; info->client.set_raw_uri("mtn://" + host()); - info->client.set_include_pattern(includes); - info->client.set_exclude_pattern(excludes); + info->client.set_include_exclude_pattern(includes, excludes); info->client.ensure_completeness(); info->client.maybe_set_argv(lua); ============================================================ --- network/connection_info.hh 777e884cd05fa9559dd1c7306b31d10e0a3f0ab0 +++ network/connection_info.hh 25de3ca6cdb36b10c3f08cd44c3814edf8836dbe @@ -56,8 +56,8 @@ struct netsync_connection_info ~Client(); void set_raw_uri(std::string const & uri); - void set_include_pattern(std::vector const & pat); - void set_exclude_pattern(std::vector const & pat); + void set_include_exclude_pattern(std::vector const & inc, + std::vector const & pat); void maybe_set_argv(lua_hooks & lua); void ensure_completeness() const;