subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1817394 - in /subversion/branches/shelve-checkpoint/subversion: include/svn_client.h svn/shelve-cmd.c svn/svn.c
Date Thu, 07 Dec 2017 16:25:45 GMT
Author: julianfoad
Date: Thu Dec  7 16:25:44 2017
New Revision: 1817394

URL: http://svn.apache.org/viewvc?rev=1817394&view=rev
Log:
On the 'shelve-checkpoint' branch: Implement an export-as-patch command.

svn savepoint|sp|checkpoint export NAME [VERSION]

* subversion/include/svn_client.h,
  subversion/libsvn_client/shelve.c
  (svn_client_shelf_export_patch): New.
  (svn_client_shelf_version_get_info): Bail out if not found. (Unrelated.)

* subversion/svn/shelve-cmd.c
  (export_as_patch): New.
  (svn_cl__checkpoint): Call it when 'export' command is used.

* subversion/svn/svn.c
  (svn_cl__cmd_table): Update the command help.

Modified:
    subversion/branches/shelve-checkpoint/subversion/include/svn_client.h
    subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c
    subversion/branches/shelve-checkpoint/subversion/svn/svn.c

Modified: subversion/branches/shelve-checkpoint/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint/subversion/include/svn_client.h?rev=1817394&r1=1817393&r2=1817394&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/include/svn_client.h (original)
+++ subversion/branches/shelve-checkpoint/subversion/include/svn_client.h Thu Dec  7 16:25:44
2017
@@ -6841,6 +6841,18 @@ svn_client_shelf_get_files(apr_array_hea
                            int version,
                            apr_pool_t *scratch_pool);
 
+/** Output version @a version of @a shelf as a patch to @a outstream.
+ *
+ * @since New in 1.X.
+ * @warning EXPERIMENTAL.
+ */
+SVN_EXPERIMENTAL
+svn_error_t *
+svn_client_shelf_export_patch(svn_client_shelf_t *shelf,
+                              int version,
+                              svn_stream_t *outstream,
+                              apr_pool_t *scratch_pool);
+
 /** Information about one version.
  *
  * @since New in 1.X.

Modified: subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c?rev=1817394&r1=1817393&r2=1817394&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c (original)
+++ subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c Thu Dec  7 16:25:44
2017
@@ -429,6 +429,44 @@ restore(const char *name,
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+export_as_patch(const char *name,
+                const char *arg,
+                const char *local_abspath,
+                svn_client_ctx_t *ctx,
+                apr_pool_t *scratch_pool)
+{
+  int version;
+  svn_client_shelf_t *shelf;
+  svn_stream_t *stream;
+
+  SVN_ERR(svn_client_shelf_open(&shelf, name, local_abspath,
+                                ctx, scratch_pool));
+  if (shelf->max_version <= 0)
+    {
+      return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+                               _("Shelf '%s' not found"),
+                               name);
+    }
+
+  if (arg)
+    {
+      SVN_ERR(svn_cstring_atoi(&version, arg));
+    }
+  else
+    {
+      version = shelf->max_version;
+    }
+
+  SVN_ERR(svn_stream_for_stdout(&stream, scratch_pool));
+  SVN_ERR(svn_client_shelf_export_patch(shelf, version, stream,
+                                        scratch_pool));
+  SVN_ERR(svn_stream_close(stream));
+
+  SVN_ERR(svn_client_shelf_close(shelf, scratch_pool));
+  return SVN_NO_ERROR;
+}
+
 /* This implements the `svn_opt_subcommand_t' interface. */
 svn_error_t *
 svn_cl__shelve(apr_getopt_t *os,
@@ -690,6 +728,22 @@ svn_cl__checkpoint(apr_getopt_t *os,
                       opt_state->dry_run, opt_state->quiet,
                       local_abspath, ctx, pool));
     }
+  else if (strcmp(subsubcommand, "export") == 0)
+    {
+      const char *arg;
+
+      if (targets->nelts > 1)
+        return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                _("Too many arguments"));
+
+      /* Which checkpoint number? */
+      if (targets->nelts != 1)
+        arg = NULL;
+      else
+        arg = APR_ARRAY_IDX(targets, 0, char *);
+
+      SVN_ERR(export_as_patch(name, arg, local_abspath, ctx, pool));
+    }
   else
     {
       return svn_error_createf(SVN_ERR_CL_INSUFFICIENT_ARGS, NULL,

Modified: subversion/branches/shelve-checkpoint/subversion/svn/svn.c
URL: http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint/subversion/svn/svn.c?rev=1817394&r1=1817393&r2=1817394&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/svn/svn.c (original)
+++ subversion/branches/shelve-checkpoint/subversion/svn/svn.c Thu Dec  7 16:25:44 2017
@@ -1660,6 +1660,7 @@ const svn_opt_subcommand_desc2_t svn_cl_
      "usage: 1. savepoint save NAME [PATH...]\n"
      "       2. savepoint restore NAME [VERSION]\n"
      "       3. savepoint list|--list NAME\n"
+     "       4. savepoint export NAME [VERSION]\n"
      "\n"
      "  1. Save local changes in the given PATHs as a new version of shelf NAME.\n"
      "     A new log message can be given with -m, -F, etc.\n"
@@ -1672,6 +1673,8 @@ const svn_opt_subcommand_desc2_t svn_cl_
      "\n"
      "  3. List all versions of shelf NAME.\n"
      "\n"
+     "  4. Export the shelf NAME:VERSION (default: latest) as a patch.\n"
+     "\n"
      "  The default PATH is the current working directory.\n"
      "\n"
      "  The shelving feature is EXPERIMENTAL. This command is likely to change\n"



Mime
View raw message