Author: julianfoad
Date: Thu Aug 24 09:35:50 2017
New Revision: 1806015

URL: http://svn.apache.org/viewvc?rev=1806015&view=rev
Log:
On the 'shelve-checkpoint' branch: Support a description (log message).

* subversion/svn/svn.c
  (svn_cl__cmd_table,
   sub_main): Add log message options.

* subversion/svn/checkpoint-cmd.c
  (read_logmsg_from_patch): New.
  (checkpoint_list): Display the log message found in the patch file.
  (svn_cl__checkpoint): Initialize the standard log message callback.

* subversion/libsvn_client/checkpoint.c
  (write_checkpoint): Add 'message' parameter and pass it on to
    svn_client_shelf_write_patch().
  (svn_client_checkpoint_save): Fetch log message from the callback.
  (svn_client_checkpoint_restore): Use an empty message for the temporary
    checkpoint.

Modified:
    subversion/branches/shelve-checkpoint/subversion/libsvn_client/checkpoint.c
    subversion/branches/shelve-checkpoint/subversion/svn/checkpoint-cmd.c
    subversion/branches/shelve-checkpoint/subversion/svn/svn.c

Modified: 
subversion/branches/shelve-checkpoint/subversion/libsvn_client/checkpoint.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint/subversion/libsvn_client/checkpoint.c?rev=1806015&r1=1806014&r2=1806015&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/libsvn_client/checkpoint.c 
(original)
+++ subversion/branches/shelve-checkpoint/subversion/libsvn_client/checkpoint.c 
Thu Aug 24 09:35:50 2017
@@ -104,6 +104,7 @@ format_checkpoint_name(int checkpoint_nu
 /* Write a checkpoint patch of the whole WC. */
 static svn_error_t *
 write_checkpoint(int checkpoint_number,
+                 const char *message,
                  /*const apr_array_header_t *paths,
                    svn_depth_t depth,
                    const apr_array_header_t *changelists,*/
@@ -120,7 +121,7 @@ write_checkpoint(int checkpoint_number,
                                  ctx, scratch_pool, scratch_pool));
   APR_ARRAY_PUSH(paths, const char *) = wc_root_abspath;
   SVN_ERR(svn_client_shelf_write_patch(
-            shelf_name, "" /*message*/, wc_root_abspath,
+            shelf_name, message, wc_root_abspath,
             TRUE /*overwrite_existing*/,
             paths, svn_depth_infinity, NULL /*changelists*/,
             ctx, scratch_pool));
@@ -177,11 +178,25 @@ svn_client_checkpoint_save(int *checkpoi
                            apr_pool_t *scratch_pool)
 {
   int current;
+  const char *message = "";
 
   SVN_ERR(read_current(&current, local_abspath, ctx, scratch_pool));
   current++;
 
-  SVN_ERR(write_checkpoint(current, local_abspath, ctx, scratch_pool));
+  /* Fetch the log message */
+  if (SVN_CLIENT__HAS_LOG_MSG_FUNC(ctx))
+    {
+      const char *tmp_file;
+      apr_array_header_t *commit_items
+        = apr_array_make(scratch_pool, 1, sizeof(void *));
+
+      SVN_ERR(svn_client__get_log_msg(&message, &tmp_file, commit_items,
+                                      ctx, scratch_pool));
+      if (! message)
+        return SVN_NO_ERROR;
+    }
+
+  SVN_ERR(write_checkpoint(current, message, local_abspath, ctx, 
scratch_pool));
   SVN_ERR(write_current(current, local_abspath, ctx, scratch_pool));
 
   *checkpoint_number = current;
@@ -204,7 +219,8 @@ svn_client_checkpoint_restore(int checkp
   /* (Even with dry_run, we write and use and delete a temp checkpoint) */
   {
     /* Write a temp checkpoint */
-    SVN_ERR(write_checkpoint(-1, local_abspath, ctx, scratch_pool));
+    SVN_ERR(write_checkpoint(-1, "" /*message*/, local_abspath,
+                             ctx, scratch_pool));
 
     /* Revert it */
     SVN_ERR(apply_checkpoint(-1, wc_root_abspath,

Modified: subversion/branches/shelve-checkpoint/subversion/svn/checkpoint-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint/subversion/svn/checkpoint-cmd.c?rev=1806015&r1=1806014&r2=1806015&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/svn/checkpoint-cmd.c 
(original)
+++ subversion/branches/shelve-checkpoint/subversion/svn/checkpoint-cmd.c Thu 
Aug 24 09:35:50 2017
@@ -33,6 +33,28 @@
 #include "private/svn_sorts_private.h"
 
 
+/* ### Currently just reads the first line.
+ */
+static svn_error_t *
+read_logmsg_from_patch(const char **logmsg,
+                       const char *patch_abspath,
+                       apr_pool_t *result_pool,
+                       apr_pool_t *scratch_pool)
+{
+  apr_file_t *file;
+  svn_stream_t *stream;
+  svn_boolean_t eof;
+  svn_stringbuf_t *line;
+
+  SVN_ERR(svn_io_file_open(&file, patch_abspath,
+                           APR_FOPEN_READ, APR_FPROT_OS_DEFAULT, 
scratch_pool));
+  stream = svn_stream_from_aprfile2(file, FALSE /*disown*/, scratch_pool);
+  SVN_ERR(svn_stream_readline(stream, &line, "\n", &eof, scratch_pool));
+  SVN_ERR(svn_stream_close(stream));
+  *logmsg = line->data;
+  return SVN_NO_ERROR;
+}
+
 /*  */
 static svn_error_t *
 checkpoint_list(const char *local_abspath,
@@ -59,11 +81,20 @@ checkpoint_list(const char *local_abspat
       svn_sort__item_t *item = &APR_ARRAY_IDX(checkpoints, i, 
svn_sort__item_t);
       const char *name = item->key;
       svn_io_dirent2_t *dirent = item->value;
+      const char *patch_abspath, *logmsg;
       char marker = ((strcmp(name, current_checkpoint_name) == 0) ? '*' : ' ');
       int age = (apr_time_now() - dirent->mtime) / 1000000 / 60;
 
+      patch_abspath = svn_dirent_join_many(scratch_pool,
+                                           local_abspath, ".svn", "shelves", 
name,
+                                           SVN_VA_NULL);
+      SVN_ERR(read_logmsg_from_patch(&logmsg, patch_abspath,
+                                     scratch_pool, scratch_pool));
+
       printf("%c %s %6d mins old %10ld bytes\n",
              marker, name, age, (long)dirent->filesize);
+      printf(" %.50s\n",
+             logmsg);
 
       if (diffstat)
         {
@@ -199,6 +230,8 @@ svn_cl__checkpoint(apr_getopt_t *os,
     }
   else if (strcmp(subsubcommand, "save") == 0)
     {
+      svn_error_t *err;
+
       if (targets->nelts)
         return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                                 _("Too many arguments"));
@@ -217,8 +250,17 @@ svn_cl__checkpoint(apr_getopt_t *os,
       SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
       */
 
-      SVN_ERR(checkpoint_save(/*targets, depth, opt_state->changelists,*/
-                              opt_state->quiet, local_abspath, ctx, pool));
+      if (ctx->log_msg_func3)
+        SVN_ERR(svn_cl__make_log_msg_baton(&ctx->log_msg_baton3,
+                                           opt_state, NULL, ctx->config,
+                                           pool));
+      err = checkpoint_save(/*targets, depth, opt_state->changelists,*/
+                            opt_state->quiet, local_abspath, ctx, pool);
+      if (ctx->log_msg_func3)
+        SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3,
+                                        err, pool));
+      else
+        SVN_ERR(err);
     }
   else if (strcmp(subsubcommand, "revert") == 0)
     {

Modified: subversion/branches/shelve-checkpoint/subversion/svn/svn.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint/subversion/svn/svn.c?rev=1806015&r1=1806014&r2=1806015&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/svn/svn.c (original)
+++ subversion/branches/shelve-checkpoint/subversion/svn/svn.c Thu Aug 24 
09:35:50 2017
@@ -628,7 +628,7 @@ const svn_opt_subcommand_desc2_t svn_cl_
      "  4. List all checkpoints. A synonym for 'svn checkpoints'.\n"),
     {'q',
      /*'-N', opt_depth, opt_targets, opt_changelist,*/
-     /*SVN_CL__LOG_MSG_OPTIONS,*/
+     SVN_CL__LOG_MSG_OPTIONS,
      opt_list},
     { {opt_list, N_("list all checkpoints")} }
     },
@@ -2956,6 +2956,7 @@ sub_main(int *exit_code, int argc, const
           || subcommand->cmd_func == svn_cl__move
           || subcommand->cmd_func == svn_cl__lock
           || subcommand->cmd_func == svn_cl__propedit
+          || subcommand->cmd_func == svn_cl__checkpoint
           || subcommand->cmd_func == svn_cl__shelve))
     {
       /* If the -F argument is a file that's under revision control,


Reply via email to