# # add_file "tests/t_netsync_exclude.at" # # patch "ChangeLog" # from [02d2e405d8f532cf6c05a5b14d06b8499d5e28a4] # to [344935858edbf70a69472b9c19e73dd34114e392] # # patch "app_state.cc" # from [9c37128fc8af7ad8bb4f5327dee434b430af4323] # to [34d5aae11fc52ae3b384e3b0450bc9f314413fd5] # # patch "app_state.hh" # from [2e07ee9fa9f8a9b3e25c4956cc998e63fd346dbd] # to [687cd3f0e9ff0229173f5b0815f28056f1068b65] # # patch "commands.cc" # from [2fcb423053b7dfe19cb23d9386e0454b3e57fec9] # to [be830b7f5140b32a670940776adf102456c95168] # # patch "monotone.cc" # from [edc6e4d96379486380caa5fe383a857378b2be4e] # to [240b0908b7d873c84df7cd1ca676d44a490b778f] # # patch "options.hh" # from [8c52cb173884c36f1427b428f26817806be57a26] # to [2d21f8009f424d24e5513c3894c0ff321e79feb0] # # patch "tests/t_netsync_exclude.at" # from [] # to [eea97484d1bd402e60fe263d96416c58cd09e96f] # # patch "testsuite.at" # from [9c11ce705172a7591aa56833f300c8ee1464651e] # to [299b096892b017c73743ec624bee7cd5cf2e29a3] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,13 @@ +2005-07-11 Nathaniel Smith + + * app_state.{hh,cc} (exclude_patterns, add_exclude): + * options.hh (OPT_EXCLUDE): + * monotone.cc (coptions, cpp_main): New option --exclude. + * commands.cc (pull, push, sync, serve): Accept it. + (process_netsync_args): Implement it. + * tests/t_netsync_exclude.at: New test. + * testsuite.at: Add it. + 2005-07-10 Nathaniel Smith * ChangeLog, configure.ac: Re-remove mysteriously revived --- app_state.cc +++ app_state.cc @@ -344,6 +344,12 @@ } void +app_state::add_exclude(utf8 const & exclude_pattern) +{ + exclude_patterns.insert(exclude_pattern); +} + +void app_state::set_stdhooks(bool b) { stdhooks = b; --- app_state.hh +++ app_state.hh @@ -42,6 +42,7 @@ utf8 author; utf8 search_root; std::vector revision_selectors; + std::set exclude_patterns; std::vector extra_rcfiles; path_set restrictions; file_path relative_directory; @@ -80,6 +81,7 @@ void set_last(long last); void set_pidfile(utf8 const & pidfile); void add_revision(utf8 const & selector); + void add_exclude(utf8 const & exclude_pattern); void set_stdhooks(bool b); void set_rcfiles(bool b); --- commands.cc +++ commands.cc @@ -1990,6 +1990,7 @@ bool use_defaults, app_state & app) { + // handle host argument if (args.size() >= 1) { addr = idx(args, 0); @@ -2010,16 +2011,25 @@ addr = utf8(addr_value()); L(F("using default server address: %s\n") % addr); } - if (args.size() >= 2) + + // handle include/exclude args + if (args.size() >= 2 || !app.exclude_patterns.empty()) { std::set patterns(args.begin() + 1, args.end()); combine_and_check_globish(patterns, include_pattern); + combine_and_check_globish(app.exclude_patterns, exclude_pattern); if (use_defaults && (!app.db.var_exists(default_include_pattern_key) || app.set_default)) { - P(F("setting default branch pattern to %s\n") % include_pattern); + P(F("setting default branch include pattern to '%s'\n") % include_pattern); app.db.set_var(default_include_pattern_key, var_value(include_pattern())); } + if (use_defaults && + (!app.db.var_exists(default_exclude_pattern_key) || app.set_default)) + { + P(F("setting default branch exclude pattern to '%s'\n") % exclude_pattern); + app.db.set_var(default_exclude_pattern_key, var_value(exclude_pattern())); + } } else { @@ -2029,15 +2039,21 @@ var_value pattern_value; app.db.get_var(default_include_pattern_key, pattern_value); include_pattern = utf8(pattern_value()); - L(F("using default branch pattern: %s\n") % include_pattern); + L(F("using default branch include pattern: '%s'\n") % include_pattern); + if (app.db.var_exists(default_exclude_pattern_key)) + { + app.db.get_var(default_exclude_pattern_key, pattern_value); + exclude_pattern = utf8(pattern_value()); + } + else + exclude_pattern = utf8(""); + L(F("excluding: %s\n") % exclude_pattern); } - - // For now, don't handle excludes. - exclude_pattern = utf8(""); } CMD(push, "network", "[ADDRESS[:PORTNUMBER] [PATTERN]]", - "push branches matching PATTERN to netsync server at ADDRESS", OPT_SET_DEFAULT) + "push branches matching PATTERN to netsync server at ADDRESS", + OPT_SET_DEFAULT % OPT_EXCLUDE) { utf8 addr, include_pattern, exclude_pattern; process_netsync_args(name, args, addr, include_pattern, exclude_pattern, true, app); @@ -2051,7 +2067,8 @@ } CMD(pull, "network", "[ADDRESS[:PORTNUMBER] [PATTERN]]", - "pull branches matching PATTERN from netsync server at ADDRESS", OPT_SET_DEFAULT) + "pull branches matching PATTERN from netsync server at ADDRESS", + OPT_SET_DEFAULT % OPT_EXCLUDE) { utf8 addr, include_pattern, exclude_pattern; process_netsync_args(name, args, addr, include_pattern, exclude_pattern, true, app); @@ -2064,7 +2081,8 @@ } CMD(sync, "network", "[ADDRESS[:PORTNUMBER] [PATTERN]]", - "sync branches matching PATTERN with netsync server at ADDRESS", OPT_SET_DEFAULT) + "sync branches matching PATTERN with netsync server at ADDRESS", + OPT_SET_DEFAULT % OPT_EXCLUDE) { utf8 addr, include_pattern, exclude_pattern; process_netsync_args(name, args, addr, include_pattern, exclude_pattern, true, app); @@ -2078,7 +2096,8 @@ } CMD(serve, "network", "ADDRESS[:PORTNUMBER] PATTERN ...", - "listen on ADDRESS and serve the specified branches to connecting clients", OPT_PIDFILE) + "listen on ADDRESS and serve the specified branches to connecting clients", + OPT_PIDFILE % OPT_EXCLUDE) { if (args.size() < 2) throw usage(name); --- monotone.cc +++ monotone.cc @@ -58,6 +58,7 @@ {"diffs", 0, POPT_ARG_NONE, NULL, OPT_DIFFS, "print diffs along with logs", NULL}, {"no-merges", 0, POPT_ARG_NONE, NULL, OPT_NO_MERGES, "skip merges when printing logs", NULL}, {"set-default", 0, POPT_ARG_NONE, NULL, OPT_SET_DEFAULT, "use the current arguments as the future default", NULL}, + {"exclude", 0, POPT_ARG_STRING, &argstr, OPT_EXCLUDE, "leave out branches matching a pattern", NULL}, { NULL, 0, 0, NULL, 0, NULL, NULL } }; @@ -394,6 +395,10 @@ app.set_default = true; break; + case OPT_EXCLUDE: + app.add_exclude(utf8(string(argstr))); + break; + case OPT_PIDFILE: app.set_pidfile(absolutify(tilde_expand(string(argstr)))); break; --- options.hh +++ options.hh @@ -36,3 +36,4 @@ #define OPT_LAST 27 #define OPT_VERBOSE 28 #define OPT_SET_DEFAULT 29 +#define OPT_EXCLUDE 30 --- tests/t_netsync_exclude.at +++ tests/t_netsync_exclude.at @@ -0,0 +1,49 @@ +AT_SETUP([serve/pull with --exclude]) +AT_KEYWORDS([netsync]) +MONOTONE_SETUP +NETSYNC_SETUP + +ADD_FILE(testfile, [1 +]) +COMMIT(branch1) +B1=`BASE_REVISION` + +SET_FILE(testfile, [2 +]) +COMMIT(branch2) +B2=`BASE_REVISION` + +ADD_FILE(testfile, [3 +]) +COMMIT(branch3) +B3=`BASE_REVISION` + +SET_FILE(testfile, [4 +]) +COMMIT(branch4) +B4=`BASE_REVISION` + +# Serve excluding branch2, branch4 +# attempting to pull them should fail +# pulling everything but them should give revs B1, B2, B3; and only +# give branch certs on B1, B3. + +NETSYNC_SERVE_START('*' --exclude=branch2 --exclude=branch4) + +NETSYNC_CLIENT_RUN(pull, 'branch*') +AT_CHECK(MONOTONE2 cat revision $B1, [1], [ignore], [ignore]) +AT_CHECK(MONOTONE2 cat revision $B2, [1], [ignore], [ignore]) +AT_CHECK(MONOTONE2 cat revision $B3, [1], [ignore], [ignore]) +AT_CHECK(MONOTONE2 cat revision $B4, [1], [ignore], [ignore]) + +NETSYNC_CLIENT_RUN(pull, 'branch*' --exclude=branch2 --exclude=branch4) +AT_CHECK(MONOTONE2 cat revision $B1, [], [ignore], [ignore]) +AT_CHECK(MONOTONE2 cat revision $B2, [], [ignore], [ignore]) +AT_CHECK(MONOTONE2 cat revision $B3, [], [ignore], [ignore]) +AT_CHECK(MONOTONE2 cat revision $B4, [1], [ignore], [ignore]) + +AT_CHECK(MONOTONE2 ls certs $B2 | grep -q branch2, [1]) + +NETSYNC_SERVE_STOP + +AT_CLEANUP --- testsuite.at +++ testsuite.at @@ -667,3 +667,4 @@ m4_include(tests/t_netsync_globs.at) m4_include(tests/t_set_default.at) m4_include(tests/t_netsync_read_permissions.at) +m4_include(tests/t_netsync_exclude.at)