# # # patch "commands.cc" # from [0ecc7f73a96dba3dffa5740d3b9b26999dd907dd] # to [bf901c2a0acc2b1fcb966d031010aa02dc693cbb] # # patch "monotone.texi" # from [36cd4f467f885aa3b64eced4e17fc07cecdefc07] # to [7b7f58e955bee5324ccb1773c0d002147314cd58] # # patch "tests/t_revert_restrict.at" # from [2adc434743c0816d8a34b0b3dd7507da5a37f184] # to [388d1de8c7a2d50910c1316b052a4fcbb5ae25e1] # # patch "work.cc" # from [7162c5181095ffbb848d1443de24b82fb6b86125] # to [f3a80d9f0f9466e6bc2d6a8a78d94ec86d2c10ef] # ============================================================ --- commands.cc 0ecc7f73a96dba3dffa5740d3b9b26999dd907dd +++ commands.cc bf901c2a0acc2b1fcb966d031010aa02dc693cbb @@ -3249,7 +3249,7 @@ cset work, included_work, excluded_work; path_set old_paths; - if (args.size() < 1 && !app.missing) + if (args.size() < 1) throw usage(name); app.require_working_copy(); @@ -3264,28 +3264,29 @@ extract_rearranged_paths(work, valid_paths); add_intermediate_paths(valid_paths); - vector args_copy(args); if (app.missing) { - L(F("revert adding find_missing entries to %d original args elements\n") % args_copy.size()); path_set missing; - find_missing(app, args_copy, missing); + find_missing(app, args, missing); + if (missing.empty()) + { + L(F("no missing files in restriction.")); + return; + } - // chose as_external because app_state::set_restriction turns utf8s into file_paths - // using file_path_external()... + vector missing_args; for (path_set::const_iterator i = missing.begin(); i != missing.end(); i++) - args_copy.push_back(file_path(*i).as_external()); - - L(F("after adding everything from find_missing, revert args_copy has %d elements\n") % args_copy.size()); - - // when given --missing, never revert if there's nothing missing and no - // specific files were specified. - if (args_copy.size() == 0) - return; + { + L(F("missing files are '%s'") % file_path(*i)); + missing_args.push_back(file_path(*i).as_external()); + } + app.set_restriction(valid_paths, missing_args, false); } + else + { + app.set_restriction(valid_paths, args, false); + } - app.set_restriction(valid_paths, args_copy, false); - restrict_cset(work, included_work, excluded_work, app); node_map const & nodes = old_roster.all_nodes(); @@ -3317,7 +3318,8 @@ continue; } - P(F("reverting %s to [%s]\n") % fp % f->content); + P(F("reverting %s") % fp); + L(F("reverting %s to [%s]\n") % fp % f->content); N(app.db.file_version_exists(f->content), F("no file version %s found in database for %s") ============================================================ --- monotone.texi 36cd4f467f885aa3b64eced4e17fc07cecdefc07 +++ monotone.texi 7b7f58e955bee5324ccb1773c0d002147314cd58 @@ -3693,34 +3693,20 @@ and/or review your log message for the change. @end itemize - address@hidden monotone revert address@hidden monotone revert @var{pathname...} address@hidden monotone revert --missing address@hidden monotone revert @var{pathname...} @itemx monotone revert --missing @var{pathname...} -With no files given, this command changes your working copy, so that -changes you have made since the last checkout or update are discarded. -It does this by changing every file listed in the working copy's base -manifest to have contents equal to the @sc{sha1} value listed in the -manifest, and by erasing the @file{MT/work} file. +This command changes your working copy, so that changes you have made +since the last checkout or update are discarded. The command is +restricted the set of files or directories given as arguments. To +revert the entire working copy, use @command{revert} "." in the +top-level directory. Specifying "." in a subdirectory will restrict address@hidden to files changed within the current subdirectory. -If files or directories are given as arguments, only those files and -directories are affected instead of the entirety of your working copy. +If the flag @option{--missing} is given it reverts (ie, restores) any +files which monotone has listed in its manifest, but which have been +deleted from the working copy. Only missing files matching the given +file or directory arguments are reverted. -If the flag @option{--missing} is given, in addition to files or -directories given as arguments, it reverts (ie, restores) any files -which monotone has listed in its manifest, but which have been deleted -from the working copy. If you specify @option{--missing} with no -additional path arguments, and there are no files missing from the -working copy, revert is conservative and does nothing. - -From within a subdirectory of the working copy the @command{revert} -command will, by default, revert @emph{all changes} in the working copy. -Specifying only the pathname "." will restrict @command{revert} to files -changed within the current subdirectory of the working copy. @i{Caution -should be used when reverting files to ensure that the correct set of -files is reverted.} - @item monotone update @itemx monotone update address@hidden Without a @option{--revision} argument, this command incorporates ============================================================ --- tests/t_revert_restrict.at 2adc434743c0816d8a34b0b3dd7507da5a37f184 +++ tests/t_revert_restrict.at 388d1de8c7a2d50910c1316b052a4fcbb5ae25e1 @@ -62,7 +62,7 @@ AT_CHECK(cp modified2 file.ignore) AT_CHECK(rm file2) -AT_CHECK(MONOTONE --rcfile=ignore_hook.lua revert --missing --debug, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --rcfile=ignore_hook.lua revert --missing . --debug, [], [ignore], [ignore]) AT_CHECK(cmp testfile modified1, [0], [ignore], [ignore]) AT_CHECK(cmp file.ignore modified2, [0], [ignore], [ignore]) @@ -76,7 +76,7 @@ AT_CHECK(cp orig.ignore file.ignore) AT_CHECK(cp orig2 file2) -AT_CHECK(MONOTONE --rcfile=ignore_hook.lua revert --missing --debug, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --rcfile=ignore_hook.lua revert --missing . --debug, [], [ignore], [ignore]) AT_CHECK(cmp testfile modified1, [0], [ignore], [ignore]) AT_CHECK(cmp file.ignore orig.ignore, [0], [ignore], [ignore]) ============================================================ --- work.cc 7162c5181095ffbb848d1443de24b82fb6b86125 +++ work.cc f3a80d9f0f9466e6bc2d6a8a78d94ec86d2c10ef @@ -638,14 +638,17 @@ for (node_map::const_iterator i = nodes.begin(); i != nodes.end(); ++i) { + split_path sp; + new_roster.get_name(i->first, sp); + if (!app.restriction_includes(sp)) + continue; + node_t n = i->second; for (full_attr_map_t::const_iterator j = n->attrs.begin(); j != n->attrs.end(); ++j) { if (j->second.first) { - split_path sp; - new_roster.get_name(i->first, sp); app.lua.hook_apply_attribute (j->first(), file_path(sp), j->second.second());