# # # patch "NEWS" # from [93b544aac93014b1d06be2626e7be2bb03bcb724] # to [f0fa7fa355da6228b4088971d00599f484f90e93] # # patch "cmd_ws_commit.cc" # from [70986e6ed4d55eec1ed9894caea8d975ca5344b1] # to [e6842ca03166637e9c04c2415e5eec798aa96180] # # patch "monotone.texi" # from [b8af75f3cda3b4abf12590536ef63ae6b3314fdc] # to [c3eb4173d3410c998b74a26384e5304e2616c212] # # patch "tests/changelog_editor/__driver__.lua" # from [8a0027f25dc5933548ff2bf9aa46564bef466193] # to [5e7b3272a2620ff1f924cdf20c4b853f07eaa4e3] # # patch "tests/changelog_editor/changelog.lua" # from [77dc2058a61be80b4067c2e2c772085f3ee41a65] # to [2765b2b10c3778e9091a77c969a2fc87f862109e] # ============================================================ --- NEWS 93b544aac93014b1d06be2626e7be2bb03bcb724 +++ NEWS f0fa7fa355da6228b4088971d00599f484f90e93 @@ -4,6 +4,10 @@ Xxx Xxx 99 99:99:99 UTC 2010 Changes + - Changelog editor format simplified; user entered text at top + of file, instructions reduced. Edited text is saved if + commit is canceled. + - On Win32 native, '--no-format-dates' is the default for 'commit', since dates are not parseable on Win32 native. ============================================================ --- monotone.texi b8af75f3cda3b4abf12590536ef63ae6b3314fdc +++ monotone.texi c3eb4173d3410c998b74a26384e5304e2616c212 @@ -1553,8 +1553,8 @@ @section Adding Files # content [ad88bbbb1b7507ddff26be67efd91d95e069afb6] # ============================================================ ---- include/jb.h f6996ce2dfc5d32bda8b574c3e9ce75db8d55492 -+++ include/jb.h f6996ce2dfc5d32bda8b574c3e9ce75db8d55492 +--- include/jb.h f6996ce2dfc5d32bda8b574c3e9ce75db8d55492 ++++ include/jb.h f6996ce2dfc5d32bda8b574c3e9ce75db8d55492 @@ -0,0 +1,13 @@ +/* Standard JuiceBot hw interface */ + @@ -1570,8 +1570,8 @@ @section Adding Files +void dispense_apple_juice (); +void dispense_banana_juice (); ============================================================ ---- src/apple.c 1ce885d2cc59842ff16785834391e864068fbc3c -+++ src/apple.c 1ce885d2cc59842ff16785834391e864068fbc3c +--- src/apple.c 1ce885d2cc59842ff16785834391e864068fbc3c ++++ src/apple.c 1ce885d2cc59842ff16785834391e864068fbc3c @@ -0,0 +1,7 @@ +#include "jb.h" + @@ -1581,8 +1581,8 @@ @section Adding Files + /* Fill this in please, Abe. */ address@hidden ============================================================ ---- src/banana.c ad88bbbb1b7507ddff26be67efd91d95e069afb6 -+++ src/banana.c ad88bbbb1b7507ddff26be67efd91d95e069afb6 +--- src/banana.c ad88bbbb1b7507ddff26be67efd91d95e069afb6 ++++ src/banana.c ad88bbbb1b7507ddff26be67efd91d95e069afb6 @@ -0,0 +1,7 @@ +#include "jb.h" + @@ -1881,8 +1881,8 @@ @section Making Changes # to [e2c64f6bde75a192d48d2256385df3dd7a963349] # ============================================================ ---- src/apple.c 1ce885d2cc59842ff16785834391e864068fbc3c -+++ src/apple.c e2c64f6bde75a192d48d2256385df3dd7a963349 +--- src/apple.c 1ce885d2cc59842ff16785834391e864068fbc3c ++++ src/apple.c e2c64f6bde75a192d48d2256385df3dd7a963349 @@ -3,5 +3,8 @@ dispense_apple_juice() void dispense_apple_juice() @@ -1905,30 +1905,23 @@ @section Making Changes @end smallexample Abe neglected to provide a @option{--message} option specifying the -change log on the command line and the file @file{_MTN/log} is empty -because he did not document his changes there. Monotone therefore -invokes an external ``log message editor'' --- typically an editor -like @command{vi} --- with an explanation of the changes being -committed and the opportunity to enter a log message. +change log on the command line. Monotone therefore invokes an +external ``log message editor'' --- typically an editor like address@hidden --- with an explanation of the changes being committed +and the opportunity to enter a log message. @smallexample @group -Enter a description of this change following the Changelog line below. -The values of Author, Date and Branch may be modified as required. -*** REMOVE THIS LINE TO CANCEL THE COMMIT *** ----------------------------------------------------------------------- -Revision: 42eae36587508faa664b111cefc291f0b85ef83a -Parent: 493bda86628fd72c992eb56f73899db9ead3cf6f -Author: abe@@juicebot.co.jp -Date: 2004-10-26T02:53:08 -Branch: jp.co.juicebot.jb7 -Changelog: +*** REMOVE THIS LINE TO CANCEL THE COMMIT *** +-- Enter a description of this change above -- +-- Edit fields below to modify certificate values -- +Branch: right +Author: tester@@test.net +Date: 2010-09-11T12:03:15 -polling implementation of src/apple.c - ----------------------------------------------------------------------- +-- Modifications below this line are ignored -- Changes against parent 493bda86628fd72c992eb56f73899db9ead3cf6f patched src/apple.c @@ -1936,12 +1929,10 @@ @section Making Changes @end group @end smallexample -Abe enters a single line below the Changelog: header, saying ``polling +Abe enters a single line at the top of the file, saying ``polling implementation of src/apple.c''. He then saves the file and quits the -editor. Monotone confirms that no other lines have been changed and -extracts the message to be stored in the associated ``changelog'' -cert, leaving only Abe's short message. Returning to the shell, Abe's -commit completes: +editor. Monotone extracts the message to be stored in the associated +``changelog'' cert. Returning to the shell, Abe's commit completes: @smallexample @group @@ -2127,8 +2118,8 @@ @section Dealing with a Fork # to [dd979c3c880e6a7221fcecd7148bd4afcfb3e964] # ============================================================ ---- src/banana.c d7e28a01cf6fc0f9ac04c6901dcafd77c2d32fb8 -+++ src/banana.c dd979c3c880e6a7221fcecd7148bd4afcfb3e964 +--- src/banana.c d7e28a01cf6fc0f9ac04c6901dcafd77c2d32fb8 ++++ src/banana.c dd979c3c880e6a7221fcecd7148bd4afcfb3e964 @@ -1,10 +1,15 @@ #include "jb.h" @@ -2327,6 +2318,9 @@ @section Branching and Merging @end group @end smallexample +Alternately, she could not specify a message on the command line, and +edit the ``Branch'' field in the changelog editor. + That's all there is to it --- there is now a @code{jp.co.juicebot.jb7.muffins} branch, with her initial checkin on it. She can make further checkins from the same workspace, and they @@ -5398,12 +5392,59 @@ @section Workspace @command{commit} 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 parameter named @var{user_log_message}. The -log message passed to the user's editor will contain a line that the -user may remove allowing them user to easily cancel a commit, without -emptying the entire log message. If the commit is successful, the address@hidden/log} file is cleared of all content making it ready for -another edit/commit cycle. +log message passed to the user's editor will contain additional text +formatted as follows: address@hidden address@hidden + + +*** REMOVE THIS LINE TO CANCEL THE COMMIT *** +-- Enter a description of this change above -- +-- Edit fields below to modify certificate values -- +Branch: +Author: +Date: + +-- Modifications below this line are ignored -- +Changes against parent + + + address@hidden group address@hidden smallexample +When the user quits the editor, the text is processed as follows: + address@hidden @bullet address@hidden +The final @var{logmsg} is all text up to the line ``*** REMOVE THIS LINE +...'' (the @dfn{cancel} line). + address@hidden +If the @var{logmsg} is empty, the commit is aborted. + address@hidden +If the cancel line is deleted or modified, the edited @var{logmsg} is +saved in @file{_MTN/log}, and the commit is aborted. + address@hidden +The next two lines (instructions) are confirmed to be present. If not, +the commit is aborted, and the entire file is saved in @file{_MTN/commit}, +so the user may recover. + address@hidden +The @dfn{Branch}, @dfn{Author}, and @dfn{Date} fields are parsed, and +the new values used for the commit. If the parsing fails, the commit +is aborted, and the entire file is saved in @file{_MTN/commit}, +so the user may recover. + address@hidden +The rest of the text is ignored. address@hidden itemize + +If the commit is successful, the @file{_MTN/log} file is cleared of +all content making it ready for another edit/commit cycle. + If @option{--message-file=_MTN/log} is specified, the contents of @file{_MTN/log} will be used without confirmation. ============================================================ --- cmd_ws_commit.cc 70986e6ed4d55eec1ed9894caea8d975ca5344b1 +++ cmd_ws_commit.cc e6842ca03166637e9c04c2415e5eec798aa96180 @@ -185,29 +185,23 @@ get_log_message_interactively(lua_hooks "-- Edit fields below to modify certificate values --\n")); utf8 ignored( - _("\n-- Modifications below this line are ignored entirely --\n")); + _("\n-- Modifications below this line are ignored --\n")); utf8 cancel(_("*** REMOVE THIS LINE TO CANCEL THE COMMIT ***\n")); - utf8 const BRANCH(trim_right(_("Branch: ")).c_str()); - utf8 const AUTHOR(trim_right(_("Author: ")).c_str()); - utf8 const DATE(trim_right(_("Date: ")).c_str()); + utf8 const BRANCH(_("Branch: ")); + utf8 const AUTHOR(_("Author: ")); + utf8 const DATE( _("Date: ")); bool is_date_fmt_valid = date_fmt_valid(date_fmt); utf8 changelog; work.read_user_log(changelog); - // ensure changelog ends in a newline + // ensure there are two blank lines after the changelog - string text = changelog(); + changelog = utf8(changelog() + "\n\n", origin::user); - if (text.empty() || text[text.length()-1] != '\n') - { - text += '\n'; - changelog = utf8(text, origin::user); - } - // build editable fields utf8 editable; { @@ -287,6 +281,11 @@ get_log_message_interactively(lua_hooks size_t changelog_end = full_message().find(cancel()); if (changelog_end == string::npos) { + // try to save the edited changelog, now delimited by the instructions. + changelog_end = full_message().find(instructions()); + if (changelog_end != string::npos) + work.write_user_log(utf8(trim_right(full_message().substr(0, changelog_end)) + '\n', origin::user)); + E(false, origin::user, F("Commit cancelled.")); } @@ -309,7 +308,7 @@ get_log_message_interactively(lua_hooks // Branch: - E(message.read(BRANCH()), origin::user, + E(message.read(trim_right(BRANCH())), origin::user, F("Commit failed. Branch header not found.")); string b = message.readline(); @@ -321,7 +320,7 @@ get_log_message_interactively(lua_hooks // Author: - E(message.read(AUTHOR()), origin::user, + E(message.read(trim_right(AUTHOR())), origin::user, F("Commit failed. Author header not found.")); author = message.readline(); @@ -331,7 +330,7 @@ get_log_message_interactively(lua_hooks // Date: - E(message.read(DATE()), origin::user, + E(message.read(trim_right(DATE())), origin::user, F("Commit failed. Date header not found.")); string d = message.readline(); ============================================================ --- tests/changelog_editor/__driver__.lua 8a0027f25dc5933548ff2bf9aa46564bef466193 +++ tests/changelog_editor/__driver__.lua 5e7b3272a2620ff1f924cdf20c4b853f07eaa4e3 @@ -15,12 +15,13 @@ check(not exists("_MTN/commit")) check(qgrep("empty log message", "stderr")) check(not exists("_MTN/commit")) --- commit can be cancelled +-- commit can be cancelled, with modified changelog saved writefile("_MTN/log", "cancel hint removed") check(mtn("commit", "--rcfile=changelog.lua"), 1, false, true) check(qgrep("Commit cancelled.", "stderr")) check(not exists("_MTN/commit")) +check(readfile("_MTN/log") == "changelog modified, cancel hint removed\n") -- commit fails with modified/missing instructions ============================================================ --- tests/changelog_editor/changelog.lua 77dc2058a61be80b4067c2e2c772085f3ee41a65 +++ tests/changelog_editor/changelog.lua 2765b2b10c3778e9091a77c969a2fc87f862109e @@ -6,7 +6,7 @@ function edit_comment(user_log_file) if (string.find(user_log_file, "empty message\n")) then return string.gsub(user_log_file, "empty message\n", "") elseif (string.find(user_log_file, "cancel hint removed\n")) then - return string.gsub(user_log_file, "... REMOVE THIS LINE TO CANCEL THE COMMIT ...\n", "") + return "changelog modified, " .. string.gsub(user_log_file, "... REMOVE THIS LINE TO CANCEL THE COMMIT ...\n", "") elseif (string.find(user_log_file, "missing instructions\n")) then return string.gsub(user_log_file, "Enter a description", "\n") elseif (string.find(user_log_file, "missing author\n")) then @@ -27,9 +27,10 @@ function edit_comment(user_log_file) if (string.find(user_log_file, "change author/date/branch\n")) then result = user_log_file - result = string.gsub(result, "\nBranch: left\n", "\nBranch: right\n") - result = string.gsub(result, "\nAuthor: bobo\n", "\nAuthor: baba\n") + result = string.gsub(result, "\nBranch: left\n", "\nBranch: right\n") + result = string.gsub(result, "\nAuthor: bobo\n", "\nAuthor: baba\n") result = string.gsub(result, "\nDate: [^\n]*\n", "\nDate: 2010-02-02T02:02:02\n") + io.stderr:write("result:\n" .. result) return result elseif (string.find(user_log_file, "sleep\n")) then date = string.match(user_log_file, "\nDate: ([^\n]*)")