I took a look at adding support for limiting monotone's recursive predilections, which seems to be important option for some. I need it for better zsh file completion. Anyway I was able to add it in suprisingly few (to me at least) # of lines.
I used --depth=X as the option and tested the code by adding it to "ls known". X above is used as a mechanism to indicate how many times the restrictions code in app_state.cc:restriction_includes may do a branch_path to walk up the directory tree. Thus for a tree: ./a ./a/b ./a/b/c ./a/b/c/d ./a/b/c/d/file ./a/b/c/file ./a/b/file ./a/file ./file (%:~/tmp/root) monotone --db=../mt.db --depth=1 ls known . file (%:~/tmp/root) monotone --db=../mt.db --depth=2 ls known . a/file file (%:~/tmp/root) monotone --db=../mt.db --depth=3 ls known . a/b/file a/file file and after "cd a/b/" (%:~/tmp/root/a/b) monotone --db=../../../mt.db --depth=1 ls known . a/b/file (%:~/tmp/root/a/b) monotone --db=../../../mt.db --depth=2 ls known . a/b/c/file a/b/file and after "cd .." (%:~/tmp/root/a) monotone --db=../../mt.db --depth=2 ls known b a/b/c/file a/b/file etc. This gives me what I need. When no --depth is provided "." works as before. Giving the whole subtree from that point. A few questions: 1) functionality look ok? 2) --depth as param name ok? 3) patch look ok (-testcase & Changelog!) 4) I want to add this to "list" obviously, but any other subcommands you'd nominate for working with this option? (must be something that uses restriction code!) jr
# # patch "app_state.cc" # from [392734be5cdd5ba62dd214b28aa434e67b678171] # to [07daa7280d90fa32feb7769eed2a97fd4b10a940] # # patch "commands.cc" # from [711e8e878e0b90261086a5a2118f9bc221c692a1] # to [0fa1311866b0e30bee3d3b21ea3976f2d936ea7d] # --- app_state.cc +++ app_state.cc @@ -195,12 +195,13 @@ // 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 ((-1 == depth) && restrictions.find(dot) != restrictions.end()) { return true; } fs::path test = mkpath(path()); + long branch_depth = 0; while (!test.empty()) { @@ -220,9 +221,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 ((-1 != depth) && (restrictions.find(dot) != restrictions.end())) + { + return (branch_depth <= depth); + } + return false; } --- commands.cc +++ commands.cc @@ -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);
_______________________________________________ Monotone-devel mailing list Monotone-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/monotone-devel