# # add_file "tests/t_commit_cancelled.at" # # patch "ChangeLog" # from [9b5cdc3ff470271929e27698a1213347951be03d] # to [bb4775a567a491f567b19e86f2e4804de18b3d53] # # patch "commands.cc" # from [566e18dee0cbeed3439bf5fcb1cc8b4756790a1c] # to [e0c430d4aa93ebd2880ad8699e1c9dc2db20dbfd] # # patch "tests/t_commit_cancelled.at" # from [] # to [02bcc53fbad3f78b36ab0dbae9b047845b6ad387] # # patch "testsuite.at" # from [eec81673ce3fb8bbe0f2dc879007f2fe9f15b518] # to [7d6278fa857ee6c7324eaa5cde6ed5d86d033aae] # =============================================== --- ChangeLog 9b5cdc3ff470271929e27698a1213347951be03d +++ ChangeLog bb4775a567a491f567b19e86f2e4804de18b3d53 @@ -1,3 +1,10 @@ +2005-08-05 Nathaniel Smith + + * commands.cc (commit): Write out the log message to MT/log + _after_ making sure it's non-empty. + * tests/t_commit_cancelled.at: New test. + * testsuite.at: Add it. + 2005-08-04 Nathaniel Smith * netsync.cc (rebuild_merkle_trees): Typo. =============================================== --- commands.cc 566e18dee0cbeed3439bf5fcb1cc8b4756790a1c +++ commands.cc e0c430d4aa93ebd2880ad8699e1c9dc2db20dbfd @@ -2374,13 +2374,13 @@ else get_log_message(rs, app, log_message); + N(log_message.find_first_not_of(" \r\t\n") != string::npos, + F("empty log message")); + // we write it out so that if the commit fails, the log // message will be preserved for a retry write_user_log(data(log_message)); - N(log_message.find_first_not_of(" \r\t\n") != string::npos, - F("empty log message")); - { transaction_guard guard(app.db); packet_db_writer dbw(app); =============================================== --- tests/t_commit_cancelled.at +++ tests/t_commit_cancelled.at 02bcc53fbad3f78b36ab0dbae9b047845b6ad387 @@ -0,0 +1,34 @@ +AT_SETUP([MT/* handled correctly in aborted commit]) +MONOTONE_SETUP + +# MT/* means MT/revision and MT/work + +ADD_FILE(testfile, [blah blah +]) +COMMIT(testbranch) + +ADD_FILE(otherfile, [stuff stuff +]) + +AT_DATA(MT/log, [message message +]) + +AT_CHECK(cp MT/log good_log) +AT_CHECK(cp MT/revision good_revision) +AT_CHECK(cp MT/work good_work) + +AT_DATA(bad_edit_comment.lua, [function edit_comment(basetext, user_log_message) + return "" +end +]) + +AT_CHECK(MONOTONE commit --rcfile=bad_edit_comment.lua, [1], [ignore], [ignore]) + +# Since this commit was canceled due to a problem with the log +# message, the old log message have been preserved +AT_CHECK(cmp MT/log good_log) + +AT_CHECK(cmp MT/revision good_revision) +AT_CHECK(cmp MT/work good_work) + +AT_CLEANUP =============================================== --- testsuite.at eec81673ce3fb8bbe0f2dc879007f2fe9f15b518 +++ testsuite.at 7d6278fa857ee6c7324eaa5cde6ed5d86d033aae @@ -681,3 +681,4 @@ m4_include(tests/t_annotate_no_rev.at) m4_include(tests/t_merge_add_rename_add.at) m4_include(tests/t_update_branch.at) +m4_include(tests/t_commit_cancelled.at)