# # patch "ChangeLog" # from [6f56a0eef7a9d00b2e300b92be8507a894285c29] # to [96b212e1483a8f673f6a6698f1a4d27dd940ba07] # # patch "commands.cc" # from [ab102f3d6e50d2a96a1f53358114a3b993adcf4d] # to [6c142e074fc47c0d2fd22e4a326480e8d507b512] # # patch "monotone.texi" # from [043ea0030fb5d5b3cdab0ff487a39ae06c8a731a] # to [85b132611b62bec54be47190f07d3d0402ca31ed] # # patch "tests/t_revert_restrict.at" # from [ca9b1e167516b4b92a5d285da56b7ca076dbd587] # to [f6d1a1494daed11b4166446d584c2a13ce1622b6] # ======================================================================== --- ChangeLog 6f56a0eef7a9d00b2e300b92be8507a894285c29 +++ ChangeLog 96b212e1483a8f673f6a6698f1a4d27dd940ba07 @@ -1,5 +1,11 @@ 2005-10-13 Emile Snyder + * commands.cc (CMD(revert)): use --missing for revert a'la drop. + * monotone.texi: document it. + * tests/t_revert_restrict.at: test it. + +2005-10-13 Emile Snyder + * app_state.{cc,hh}: new missing class member for --missing flag. * commands.cc (CMD(drop), ls_missing, find_missing): use new --missing flag to drop any files already deleted in the working copy. ======================================================================== --- commands.cc ab102f3d6e50d2a96a1f53358114a3b993adcf4d +++ commands.cc 6c142e074fc47c0d2fd22e4a326480e8d507b512 @@ -3406,7 +3406,7 @@ CMD(revert, N_("working copy"), N_("[PATH]..."), - N_("revert file(s), dir(s) or entire working copy"), OPT_DEPTH % OPT_EXCLUDE) + N_("revert file(s), dir(s) or entire working copy"), OPT_DEPTH % OPT_EXCLUDE % OPT_MISSING) { manifest_map m_old; revision_id old_revision_id; @@ -3427,8 +3427,28 @@ extract_rearranged_paths(work, valid_paths); add_intermediate_paths(valid_paths); - app.set_restriction(valid_paths, args, false); + 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); + + // chose as_external because app_state::set_restriction turns utf8s into file_paths + // using file_path_external()... + for (path_set::const_iterator i = missing.begin(); i != missing.end(); i++) + args_copy.push_back(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; + } + app.set_restriction(valid_paths, args_copy, false); + restrict_path_rearrangement(work, included, excluded, app); for (manifest_map::const_iterator i = m_old.begin(); i != m_old.end(); ++i) ======================================================================== --- monotone.texi 043ea0030fb5d5b3cdab0ff487a39ae06c8a731a +++ monotone.texi 85b132611b62bec54be47190f07d3d0402ca31ed @@ -3681,6 +3681,13 @@ 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 --missing is given, in addition to files or directories given +as arguments, it reverts any files which monotone +has listed in it's manifest, but which have been deleted from the working +copy. If you specify --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 ======================================================================== --- tests/t_revert_restrict.at ca9b1e167516b4b92a5d285da56b7ca076dbd587 +++ tests/t_revert_restrict.at f6d1a1494daed11b4166446d584c2a13ce1622b6 @@ -55,4 +55,31 @@ AT_CHECK(cmp file.ignore orig.ignore, [0], [ignore], [ignore]) AT_CHECK(cmp file2 modified3, [0], [ignore], [ignore]) + +# now try just reverting missing files + +AT_CHECK(cp modified1 testfile) +AT_CHECK(cp modified2 file.ignore) +AT_CHECK(rm file2) + +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]) +AT_CHECK(cmp file2 orig2, [0], [ignore], [ignore]) + + +# make sure that 'revert --missing' when there are no missing files doesn't +# revert existing changes + +AT_CHECK(cp modified1 testfile) +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(cmp testfile modified1, [0], [ignore], [ignore]) +AT_CHECK(cmp file.ignore orig.ignore, [0], [ignore], [ignore]) +AT_CHECK(cmp file2 orig2, [0], [ignore], [ignore]) + AT_CLEANUP