OK,
So I went ahead after a few days of looking around in the code and decided
to hack away at it.
I made sure to follow the formatting and coding style and the naming scheme.
Attached or 3 patches for the files that I changed and below is a small
description of the changes.
1) work.hh & work.cc - Added to functions:
+ void get_message_file_path(file_path & msgf_path);
+ void read_message_file(utf8 & dat);
Now I was not sure if this would be the best place to put this since
work.xxdeals with the contents of _MTN.
But since the .mtn-message file is somewhat of administration file I went
ahead and wrote it there. If this code
should live elsewhere please let me know. Now, the file lives in the root
dir of the project so that it took can be
version and is automatically checked out when the developer checks out the
project.
2) cmd_ws_commit.cc - Here I edited the function:
+ static void get_log_message_interactively(revision_t const & cs, app_state
& app, utf8 & log_message)
The behavior is as follows, First it reads the .mtn-message if it exist. If
it is not empty then it inserts the
contents of the file into user_log. Then it continues with the previously
coded behavior which is it reads and
checks _MTN/log and if not empty it will append it to user_log right after
the .mtn-message file content and the
MAGIC_LINE is perpended at the beginning of the file. This way the user can
still continue to use the _MTN/log file
for recording their work.
Please let me know how this sounds.
Regards,
Pablo Delgado
#
# old_revision [133d7c3ff21229143d27ccd7cca5d64d2b117335]
#
# patch "cmd_ws_commit.cc"
# from [c526804d60744f302780eaf3fd89663836591710]
# to [675d50749b86961c856607852b288f4d601d6553]
#
============================================================
--- cmd_ws_commit.cc c526804d60744f302780eaf3fd89663836591710
+++ cmd_ws_commit.cc 675d50749b86961c856607852b288f4d601d6553
@@ -118,16 +118,25 @@ get_log_message_interactively(revision_t
commentary_str += string(70, '-') + "\n";
external commentary(commentary_str);
+
+ utf8 message_file_message;
+ app.work.read_message_file(message_file_message);
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 the .mtn-message is non-empty we will insert this first into
+ // the user_log. The contents of _MTN/log should be appended at the
+ // end.
+ if (message_file_message().length() > 0)
+ user_log = message_file_message;
+
+ // if the _MTN/log file was non-empty, we'll append the 'magic' line
if (user_log_message().length() > 0)
- user_log = utf8( magic_line + "\n" + user_log_message());
+ user_log = utf8( magic_line + "\n" + user_log() + "\n" + user_log_message());
else
- user_log = user_log_message;
+ user_log = utf8( user_log() + "\n" + user_log_message());
external user_log_message_external;
utf8_to_system_best_effort(user_log, user_log_message_external);
#
# old_revision [133d7c3ff21229143d27ccd7cca5d64d2b117335]
#
# patch "work.cc"
# from [e0fe90634bfe1aa58632bfbb9158416a793b5e08]
# to [06b487dfeed9d4b142dba5318bcfcb6a13c925e5]
#
============================================================
--- work.cc e0fe90634bfe1aa58632bfbb9158416a793b5e08
+++ work.cc 06b487dfeed9d4b142dba5318bcfcb6a13c925e5
@@ -49,6 +49,7 @@ static char const revision_file_name[] =
static char const options_file_name[] = "options";
static char const user_log_file_name[] = "log";
static char const revision_file_name[] = "revision";
+static char const message_file_name[] = ".mtn-message";
static void
get_revision_path(bookkeeping_path & m_path)
@@ -251,6 +252,28 @@ workspace::has_contents_user_log()
return user_log_message().length() > 0;
}
+// .mtn-message template file
+void
+workspace::get_message_file_path(file_path & msgf_path)
+{
+ msgf_path = file_path_internal(message_file_name);
+ L(FL("mtn message file path is %s") % msgf_path);
+}
+
+void
+workspace::read_message_file(utf8 & dat)
+{
+ file_path msgf_path;
+ get_message_file_path(msgf_path);
+
+ if (file_exists(msgf_path))
+ {
+ data tmp;
+ read_data(msgf_path, tmp);
+ system_to_utf8(external(tmp()), dat);
+ }
+}
+
// _MTN/options handling.
void
#
# old_revision [133d7c3ff21229143d27ccd7cca5d64d2b117335]
#
# patch "work.hh"
# from [49bf298fac3d660308c2b7106ff46854546401bd]
# to [3199d166945136921f2e4ef8ba5e8d4a692df15a]
#
============================================================
--- work.hh 49bf298fac3d660308c2b7106ff46854546401bd
+++ work.hh 3199d166945136921f2e4ef8ba5e8d4a692df15a
@@ -152,6 +152,14 @@ struct workspace
void blank_user_log();
bool has_contents_user_log();
+ // The ".mtn-message" file is used to define a template for the commit
+ // message that is presented when obtaining the message interactivly.
+ // This file resides in the project root directory and not in the _MTN
+ // becuase it should be kept in the database so that it is version and
+ // all the project developers get a copy upon checking out a revision.
+ void get_message_file_path(file_path & msgf_path);
+ void read_message_file(utf8 & dat);
+
// the "options map" is another administrative file, stored in
// _MTN/options. it keeps a list of name/value pairs which are considered
// "persistent options", associated with a particular workspace and
_______________________________________________
Monotone-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monotone-devel