# # patch "app_state.cc" # from [598fd531fee72a84b3ad3f5f7eef8cf6eb541168] # to [b6383c2c304c62ce0a3d3c1fecac4b6e8edc21d6] # # patch "commands.cc" # from [e9920aa8d91f2dbe0fe7a677def45fa83e8aa00a] # to [8b0ec1d6852697ee860ef82d55d1aec076c7a242] # # patch "lua.cc" # from [245b97fe4ab5bfa555f8cb82c54404981c95faaf] # to [37f91418b85e4c296e2da82d45f4eaa7c6513aed] # # patch "lua.hh" # from [32c57c4c2a21985b7b3148506ca0180a8b06e391] # to [7e62c232b0a1e71e509ac1834170507bd776507f] # # patch "monotone.texi" # from [6606e344451eff69396d1710d8c726214ff252cb] # to [12a872e8e50355bc882f8eccab9d24f5396d5e14] # # patch "std_hooks.lua" # from [5492f69f2f273ec537f363a38de99184925cd681] # to [022238db5fafa515485cff486f746236f3e32753] # # patch "work.cc" # from [a4dff9f496fb4771119f83c4ce18252641fd53ff] # to [b99ce81d03b2405b4bb8f010e1d6d21241fe9859] # # patch "work.hh" # from [a386a87e99ce6e9750d192be7e29a9cbae9e4d52] # to [d4035d9978ebe64c62b94e35307a77c5e21a8a02] # --- app_state.cc +++ app_state.cc @@ -122,6 +122,8 @@ write_options(); + blank_user_log(); + load_rcfiles(); } --- commands.cc +++ commands.cc @@ -651,20 +651,23 @@ return tmp; } +std::string const user_log_file_name("MT/log"); + static void get_log_message(revision_set const & cs, app_state & app, string & log_message) { string commentary; - data summary; + data summary, user_log_message; write_revision_set(cs, summary); + read_user_log(user_log_message); commentary += "----------------------------------------------------------------------\n"; commentary += "Enter Log. Lines beginning with `MT:' are removed automatically\n"; commentary += "\n"; commentary += summary(); commentary += "----------------------------------------------------------------------\n"; - N(app.lua.hook_edit_comment(commentary, log_message), + N(app.lua.hook_edit_comment(commentary, user_log_message(), log_message), F("edit of log message failed")); } @@ -1359,7 +1362,7 @@ if (args.size() == 2) comment = idx(args, 1)(); else - N(app.lua.hook_edit_comment("", comment), + N(app.lua.hook_edit_comment("", "", comment), F("edit comment failed")); N(comment.find_first_not_of(" \r\t\n") != string::npos, @@ -2477,7 +2480,9 @@ put_path_rearrangement(excluded_work); put_revision_id(rid); P(F("committed revision %s\n") % rid); - + + blank_user_log(); + update_any_attrs(app); { --- lua.cc +++ lua.cc @@ -625,14 +625,16 @@ } bool -lua_hooks::hook_edit_comment(string const & commentary, +lua_hooks::hook_edit_comment(string const & commentary, + string const & user_log_message, string & result) { return Lua(st) .push_str("edit_comment") .get_fn() .push_str(commentary) - .call(1,1) + .push_str(user_log_message) + .call(2,1) .extract_str(result) .ok(); } --- lua.hh +++ lua.hh @@ -43,7 +43,9 @@ base64< arc4 > & priv_key ); bool hook_get_passphrase(rsa_keypair_id const & k, std::string & phrase); bool hook_get_author(cert_value const & branchname, std::string & author); - bool hook_edit_comment(std::string const & commentary, std::string & result); + bool hook_edit_comment(std::string const & commentary, + std::string const & user_log_message, + std::string & result); bool hook_persist_phrase_ok(); bool hook_non_blocking_rng_ok(); bool hook_get_revision_cert_trust(std::set const & signers, --- monotone.texi +++ monotone.texi @@ -2470,7 +2470,12 @@ after checking out a particular working copy. @item MT/work Contains a list of additions, deletions, and renames which have occurred -in the current working copy, relative to the base version. +in the current working copy, relative to the base version. address@hidden MT/log +Contains log messages to append to the ``changelog'' cert upon +commit. The user may add content to this file while they work. Upon a +successful commit monotone will empty the file making it ready for the +next edit/commit cycle. @end table @@ -3191,6 +3196,14 @@ copy. Specifying only the pathname "." will restrict @command{commit} to files changed within the current subdirectory of the working copy. +The @file{MT/log} file can be edited by the user during their daily work +to record the changes made to the working copy. When running the address@hidden command without a @var{logmsg} supplied, the contents +of the @file{MT/log} file will be read and passed to the Lua hook address@hidden as a second parameter named @var{user_log_content}. +If the commit is successful, the @file{MT/log} file is cleared of +all content making it ready for another edit/commit cycle. + The @command{commit} command also synthesizes a number of certificates, which it attaches to the new manifest version and copies into your database: @@ -3207,9 +3220,9 @@ A @code{changelog} cert, containing the ``log message'' for these changes. If you provided @var{logmsg} on the command line, this text will be used, otherwise @command{commit} will run the Lua hook address@hidden (@var{commentary})}, which typically invokes an -external editor program, in which you can compose a log message for -the change. address@hidden (@var{commentary}, @var{user_log_content})}, which +typically invokes an external editor program, in which you can compose +and/or review your log message for the change. @end itemize --- std_hooks.lua +++ std_hooks.lua @@ -63,7 +63,7 @@ end -function edit_comment(basetext) +function edit_comment(basetext, user_log_message) local exe = "vi" local visual = os.getenv("VISUAL") if (visual ~= nil) then exe = visual end @@ -74,6 +74,7 @@ if (tmp == nil) then return nil end basetext = "MT: " .. string.gsub(basetext, "\n", "\nMT: ") .. "\n" tmp:write(basetext) + tmp:write(user_log_message) io.close(tmp) if (execute(exe, tname) ~= 0) then --- work.cc +++ work.cc @@ -174,6 +174,38 @@ paths.insert(manifest_entry_path(i)); } +// user log file + +string const user_log_file_name("log"); + +void +get_user_log_path(local_path & ul_path) +{ + ul_path = (mkpath(book_keeping_dir) / mkpath(user_log_file_name)).string(); + L(F("user log path is %s\n") % ul_path); +} + +void +read_user_log(data & dat) +{ + local_path ul_path; + get_user_log_path(ul_path); + + if (file_exists(ul_path)) + { + read_data(ul_path, dat); + } +} + +void +blank_user_log() +{ + data empty; + local_path ul_path; + get_user_log_path(ul_path); + write_data(ul_path, empty); +} + // options map file string const options_file_name("options"); --- work.hh +++ work.hh @@ -27,7 +27,8 @@ // MT/revision -- contains the id of the checked out revision // MT/work -- (optional) a set of added, deleted or moved pathnames // this file is, syntactically, a path_rearrangement -// MT/options -- the database, branch and key options currently in use +// MT/options -- the database, branch and key options currently in use +// MT/log -- user edited log file // // as work proceeds, the files in the working directory either change their // sha1 fingerprints from those listed in the revision's manifest, or else are @@ -65,6 +66,18 @@ change_set::path_rearrangement & pr); +// the "user log" is a file the user can edit as they program to record +// changes they make to their source code. Upon commit the file is read +// and passed to the edit_comment lua hook. If the commit is a success, +// the user log is then blanked. If the commit does not succeed, no +// change is made to the user log file. + +void get_user_log_path(local_path & ul_path); + +void read_user_log(data & dat); + +void blank_user_log(); + // the "options map" is another administrative file, stored in // MT/options. it keeps a list of name/value pairs which are considered // "persistent options", associated with a particular the working copy and