# # # patch "ChangeLog" # from [bafa1cb677b0d5be41de73e9366fd37ed1e14f4c] # to [14fff4321f781f1c13c4f9da5695bc1136e54c82] # # patch "cmd_ws_commit.cc" # from [c261cde4b2eb928ff75f57fab634f1d987443287] # to [55327636b5642956cfee1cd963a8663fee146d83] # # patch "monotone.texi" # from [b17357a14a40f60e2b3420f07c43e49e717bf242] # to [b89072b90d05f10d52208df461a5908ce9ed89b4] # # patch "tests/commit_using__MTN_log/__driver__.lua" # from [08cabfe47577eb8f6c1c2c44d7f262a47f3c39c9] # to [527603c2d0931a7576c34088d085ac689cf93236] # ============================================================ --- ChangeLog bafa1cb677b0d5be41de73e9366fd37ed1e14f4c +++ ChangeLog 14fff4321f781f1c13c4f9da5695bc1136e54c82 @@ -1,3 +1,13 @@ +2006-12-11 Ben Walton + + * cmd_ws_commit.cc, + tests/commit_using__MTN_log/commit_log_modified_return.lua, + tests/commit_using__MTN_log/__driver__.lua: + Added the requirement that when _MTN/log is pre-specified by + the user, that the user remove a 'magic' line prior to the + commit being accepted. Modified the units tests to verify this. + Updated texinfo to match this new behaviour. + 2006-12-10 Timothy Brownawell Implement a "mtn log --to ", that doesn't log the ============================================================ --- cmd_ws_commit.cc c261cde4b2eb928ff75f57fab634f1d987443287 +++ cmd_ws_commit.cc 55327636b5642956cfee1cd963a8663fee146d83 @@ -40,6 +40,7 @@ get_log_message_interactively(revision_t external summary_external; utf8_to_system(utf8(summary.inner()()), summary_external); + string magic_line = _("*****DELETE THIS LINE TO CONFIRM YOUR COMMIT*****"); string commentary_str; commentary_str += string(70, '-') + "\n"; commentary_str += _("Enter a description of this change.\n" @@ -53,13 +54,25 @@ get_log_message_interactively(revision_t utf8 user_log_message; app.work.read_user_log(user_log_message); + + //if the _MTN/log file was non-empty, we'll append the 'magic' line + utf8 user_log; + if (user_log_message().length() > 0) + user_log = magic_line + "\n" + user_log_message(); + else + user_log = user_log_message(); + external user_log_message_external; - utf8_to_system(user_log_message, user_log_message_external); + utf8_to_system(user_log, user_log_message_external); external log_message_external; N(app.lua.hook_edit_comment(commentary, user_log_message_external, log_message_external), F("edit of log message failed")); + + N(log_message_external().find(magic_line) == string::npos, + F("failed to remove magic line; commit cancelled")); + system_to_utf8(log_message_external, log_message); } ============================================================ --- monotone.texi b17357a14a40f60e2b3420f07c43e49e717bf242 +++ monotone.texi b89072b90d05f10d52208df461a5908ce9ed89b4 @@ -4287,13 +4287,16 @@ @section Workspace The log message will be formed by concatenating the @option{--message} options provided, with each one starting at the beginning of a new line. -The @file{_MTN/log} file can be edited by the user during their daily work -to record the changes made to the workspace. When running the address@hidden command without a @var{logmsg} supplied, the contents -of the @file{_MTN/log} file will be read and passed to the Lua hook +The @file{_MTN/log} file can be edited by the user during their daily +work to record the changes made to the workspace. When running the address@hidden command without a @var{logmsg} supplied, the contents of +the @file{_MTN/log} file will be read and passed to the Lua hook @code{edit_comment} as a second parameter named @var{user_log_content}. -If the commit is successful, the @file{_MTN/log} file is cleared of -all content making it ready for another edit/commit cycle. +The log message will be prepended with a 'magic' string that must be +removed to confirm the commit. This allows the user to easily cancel a +commit, without emptying the entire log message. If the commit is +successful, the @file{_MTN/log} file is cleared of all content making it +ready for another edit/commit cycle. If a @option{--branch} option is specified, the @command{commit} command commits to this branch (creating it if necessary). The branch becomes ============================================================ --- tests/commit_using__MTN_log/__driver__.lua 08cabfe47577eb8f6c1c2c44d7f262a47f3c39c9 +++ tests/commit_using__MTN_log/__driver__.lua 527603c2d0931a7576c34088d085ac689cf93236 @@ -1,7 +1,8 @@ check(get("commit_log.lua")) mtn_setup() check(get("commit_log.lua")) +check(get("commit_log_modified_return.lua")) writefile("_MTN/log", "Log entry") @@ -9,8 +10,18 @@ check(mtn("add", "input.txt"), 0, false, check(mtn("add", "input.txt"), 0, false, false) -check(mtn("--branch=testbranch", "--rcfile=commit_log.lua", "commit"), 0, false, false) +--this should now fail, given that the log file has content and we don't +--remove the 'magic' line +check(mtn("--branch=testbranch", "--rcfile=commit_log.lua", "commit"), 1, false, true) +check(qgrep('magic line; commit cancelled', "stderr")) +check(exists("_MTN/log")) +check(fsize("_MTN/log") > 0) + +--this should pass, as the lua hook now returns a string that doesn't contain +--the 'magic' line +check(mtn("--branch=testbranch", "--rcfile=commit_log_modified_return.lua", "commit"), 0, false, false) + tsha = base_revision() check(exists("_MTN/log")) check(fsize("_MTN/log") == 0)