# # patch "ChangeLog" # from [bf8a4a75eddeb0270a5b05945234ee5aa2e9ca88] # to [b3687813627bd57c7be0c482ead1181baaadac31] # # patch "app_state.cc" # from [392734be5cdd5ba62dd214b28aa434e67b678171] # to [dbfc37bd407b9d7f58979c07e8b7b5e4b4a964cf] # # patch "app_state.hh" # from [d0009cab364bc2ee2fa53170aa4bc61ce16a6f11] # to [433dcbd86d2fe9c42c3dea7f040fb91c46b50181] # # patch "commands.cc" # from [e5ee84935ff22ffd003a051b04b984e94396f709] # to [5734841465849ab57d9882e9b6b52280398f6052] # # patch "monotone.cc" # from [c16834cd4c67d32acc773d866596d4a41d26a035] # to [a757a2bc5e96c1020a8fb9a206a4df2ca7571584] # # patch "monotone.texi" # from [1ba82432e678b8b56e6c8546930e30b85c277955] # to [487e6ce3aced892322391286780a0913f3d60e59] # # patch "options.hh" # from [31fd46bd9a90626226c5d382c34652bfc47b2323] # to [7d6df419138742a4831a9db4a2c4a5b8225e38ba] # # patch "tests/t_log_depth.at" # from [e4c1de5715712b6f980ffc494281ba8ffb5345c2] # to [850fc51a2454f9e2a9a352bed17e9f2e485f13b6] # # patch "tests/t_log_depth_single.at" # from [7c0591b0193c56f1455fe8db3930677122111274] # to [98a2f3d7517c097dafa83024dc6b3b5d2303242c] # # patch "tests/t_options.at" # from [44bc7db4f21ffbb28051d8a3aa7352be6d4108c1] # to [e3f96656874c0fbafa2c0092b338d2948f0c2bda] # # patch "tests/t_restrictions.at" # from [5a3ee79ac754dc7533a2778b40dbb87b4faff4c1] # to [9d83817ca09a3dafe812cb6024da45c6fdbf8b22] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,13 @@ +2005-05-28 Joel Reed + + * app_state.cc, app_state.hh, commands.cc, monotone.cc, options.h: + add new --depth command, and rename log's --depth to --last + * monotone.texi: update documentation + * tests/t_log_depth.at, tests/t_log_depth_single.at: update + log tests to use --last instead of --depth + * tests/t_options.at, tests/t_restrictions.at: test usage of + --depth for commands using restrictions + 2005-05-23 Timothy Brownawell Fix "automate stdio" input/output format according to ML discussion --- app_state.cc +++ app_state.cc @@ -31,7 +31,7 @@ app_state::app_state() : branch_name(""), db(""), stdhooks(true), rcfiles(true), - search_root("/"), depth(-1) + search_root("/"), depth(-1), last(-1) { db.set_app(this); } @@ -177,6 +177,13 @@ L(F("'%s' added to restricted path set\n") % p()); restrictions.insert(p); } + + // if user supplied a depth but provided no paths + // assume current directory + if ((depth != -1) && restrictions.empty()) + { + restrictions.insert(dot); + } } bool @@ -189,18 +196,21 @@ { return true; } - + + bool user_supplied_depth = (depth != -1); + // a path that normalizes to "." means that the restriction has been // essentially cleared (all files are included). rather than be // careful about what goes in to the restricted path set we just // check for this special case here. - if (restrictions.find(dot) != restrictions.end()) + if ((!user_supplied_depth) && restrictions.find(dot) != restrictions.end()) { return true; } fs::path test = mkpath(path()); + long branch_depth = 0; while (!test.empty()) { @@ -220,9 +230,17 @@ L(F("path '%s' not found in restricted path set; '%s' excluded\n") % test.string() % path()); } + + if (depth==branch_depth) return false; test = test.branch_path(); + ++branch_depth; } - + + if (user_supplied_depth && (restrictions.find(dot) != restrictions.end())) + { + return (branch_depth <= depth); + } + return false; } @@ -300,6 +318,14 @@ } void +app_state::set_last(long l) +{ + N(l > 0, + F("negative or zero last not allowed\n")); + last = l; +} + +void app_state::set_pidfile(utf8 const & p) { pidfile = mkpath(p()); --- app_state.hh +++ app_state.hh @@ -43,6 +43,7 @@ file_path relative_directory; bool found_working_copy; long depth; + long last; fs::path pidfile; void allow_working_copy(); @@ -70,6 +71,7 @@ void set_date(utf8 const & date); void set_author(utf8 const & author); void set_depth(long depth); + void set_last(long last); void set_pidfile(utf8 const & pidfile); void add_revision(utf8 const & selector); --- commands.cc +++ commands.cc @@ -1255,7 +1255,7 @@ } -CMD(status, "informative", "[PATH]...", "show status of working copy", OPT_NONE) +CMD(status, "informative", "[PATH]...", "show status of working copy", OPT_DEPTH) { revision_set rs; manifest_map m_old, m_new; @@ -1705,7 +1705,7 @@ "missing", "show database objects, or the current working copy manifest,\n" "or unknown, intentionally ignored, or missing state files", - OPT_NONE) + OPT_DEPTH) { if (args.size() == 0) throw usage(name); @@ -2232,7 +2232,7 @@ CMD(commit, "working copy", "[PATH]...", "commit working copy to database", - OPT_BRANCH_NAME % OPT_MESSAGE % OPT_MSGFILE % OPT_DATE % OPT_AUTHOR) + OPT_BRANCH_NAME % OPT_MESSAGE % OPT_MSGFILE % OPT_DATE % OPT_AUTHOR % OPT_DEPTH) { string log_message(""); revision_set rs; @@ -2679,7 +2679,7 @@ CMD(diff, "informative", "[--revision=REVISION [--revision=REVISION]] [PATH]...", "show current unified diffs on stdout", - OPT_BRANCH_NAME % OPT_REVISION) + OPT_BRANCH_NAME % OPT_REVISION % OPT_DEPTH) { do_diff(name, app, args, unified_diff); } @@ -3310,7 +3310,7 @@ CMD(revert, "working copy", "[PATH]...", - "revert file(s), dir(s) or entire working copy", OPT_NONE) + "revert file(s), dir(s) or entire working copy", OPT_DEPTH) { manifest_map m_old; revision_id old_revision_id; @@ -3488,7 +3488,7 @@ CMD(log, "informative", "[file] [--revision=REVISION [--revision=REVISION [...]]]", "print history in reverse order (filtering by 'file'). If one or more revisions\n" "are given, use them as a starting point.", - OPT_DEPTH % OPT_REVISION % OPT_BRIEF) + OPT_LAST % OPT_REVISION % OPT_BRIEF) { file_path file; @@ -3527,10 +3527,10 @@ cert_name comment_name(comment_cert_name); set seen; - long depth = app.depth; + long last = app.last; revision_set rev; - while(! frontier.empty() && (depth == -1 || depth > 0)) + while(! frontier.empty() && (last == -1 || last > 0)) { set< pair > next_frontier; for (set< pair >::const_iterator i = frontier.begin(); @@ -3630,9 +3630,9 @@ log_certs(app, rid, comment_name, "Comments: ", true); } - if (depth > 0) + if (last > 0) { - depth--; + last--; } } } --- monotone.cc +++ monotone.cc @@ -47,7 +47,8 @@ {"message-file", 0, POPT_ARG_STRING, &argstr, OPT_MSGFILE, "set filename containing commit changelog message", NULL}, {"date", 0, POPT_ARG_STRING, &argstr, OPT_DATE, "override date/time for commit", NULL}, {"author", 0, POPT_ARG_STRING, &argstr, OPT_AUTHOR, "override author for commit", NULL}, - {"depth", 0, POPT_ARG_LONG, &arglong, OPT_DEPTH, "limit the log output to the given number of entries", NULL}, + {"depth", 0, POPT_ARG_LONG, &arglong, OPT_DEPTH, "limit the number of levels of directories to descend", NULL}, + {"last", 0, POPT_ARG_LONG, &arglong, OPT_LAST, "limit the log output to the given number of entries", NULL}, {"pid-file", 0, POPT_ARG_STRING, &argstr, OPT_PIDFILE, "record process id of server", NULL}, {"brief", 0, POPT_ARG_NONE, NULL, OPT_BRIEF, "print a brief version of the normal output", NULL}, { NULL, 0, 0, NULL, 0, NULL, NULL } @@ -351,6 +352,10 @@ app.set_root(string(argstr)); break; + case OPT_LAST: + app.set_last(arglong); + break; + case OPT_DEPTH: app.set_depth(arglong); break; --- monotone.texi +++ monotone.texi @@ -2412,6 +2412,10 @@ ensure that the expected files are included or excluded by a restriction. +Commands which support restrictions also support the address@hidden@var{n} } option, where @var{n} specifies the maximum +number of directories to descend. + One variant of the @command{diff} command takes two @option{--revision} options and does not operate on a working copy, but instead compares two arbitrary database revisions. In this form the @command{diff} command @@ -3717,7 +3721,7 @@ to files changed within the current subdirectory of the working copy. @item monotone log address@hidden monotone log address@hidden address@hidden [...]] [--brief] address@hidden [...]] address@hidden monotone log address@hidden address@hidden [...]] [--brief] address@hidden [...]] This command prints out a log, in reverse-ancestry order, of small history summaries. Each summary contains author, date, changelog and @@ -3725,7 +3729,7 @@ given, the output consists of one line per revision with the revision ID, the author, the date and the branches (separated with commas). -If @address@hidden is given, at most that many log entries will be +If @address@hidden is given, at most that many log entries will be given. If one or more revision IDs are given, the command starts tracing back --- options.hh +++ options.hh @@ -31,3 +31,4 @@ #define OPT_PIDFILE 22 #define OPT_MSGFILE 23 #define OPT_BRIEF 24 +#define OPT_LAST 25 --- tests/t_log_depth.at +++ tests/t_log_depth.at @@ -1,4 +1,4 @@ -AT_SETUP([log --depth=N]) +AT_SETUP([log --last=N]) MONOTONE_SETUP ADD_FILE(foo, [foo @@ -16,12 +16,12 @@ AT_CHECK(MONOTONE --branch=testbranch commit --message "Addition of baz.", [], [ignore], [ignore]) -AT_CHECK(MONOTONE log --depth=0, [1], [], [ignore]) +AT_CHECK(MONOTONE log --last=0, [1], [], [ignore]) -AT_CHECK(MONOTONE log --depth=1 | grep '^Revision:', [], [stdout], [ignore]) +AT_CHECK(MONOTONE log --last=1 | grep '^Revision:', [], [stdout], [ignore]) AT_CHECK(test 1 -eq "`wc -l