You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2017/12/07 20:48:04 UTC
svn commit: r1817418 - in /subversion/trunk/subversion: include/svn_client.h
libsvn_client/shelve.c svn/shelve-cmd.c
Author: julianfoad
Date: Thu Dec 7 20:48:04 2017
New Revision: 1817418
URL: http://svn.apache.org/viewvc?rev=1817418&view=rev
Log:
Bail out if 'shelve' finds no modifications.
A rough equivalent of r1817360 on the 'shelve-checkpoint' branch.
* subversion/include/svn_client.h,
subversion/libsvn_client/shelve.c
(svn_client_shelf_has_changes): New.
* subversion/svn/shelve-cmd.c
(svn_cl__shelve): Throw an error if the resulting shelf contains no changes.
Modified:
subversion/trunk/subversion/include/svn_client.h
subversion/trunk/subversion/libsvn_client/shelve.c
subversion/trunk/subversion/svn/shelve-cmd.c
Modified: subversion/trunk/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1817418&r1=1817417&r2=1817418&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Thu Dec 7 20:48:04 2017
@@ -6845,6 +6845,21 @@ svn_client_shelf_get_paths(apr_hash_t **
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
+/** Set @a *has_changes to indicate whether the shelf @a name
+ * contains any modifications, in other words if svn_client_shelf_get_paths()
+ * would return a non-empty set of paths.
+ *
+ * @since New in 1.10.
+ * @warning EXPERIMENTAL.
+ */
+SVN_EXPERIMENTAL
+svn_error_t *
+svn_client_shelf_has_changes(svn_boolean_t *has_changes,
+ const char *name,
+ const char *local_abspath,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *scratch_pool);
+
/** Write local changes to a patch file for shelved change @a name.
*
* @a message: An optional log message.
Modified: subversion/trunk/subversion/libsvn_client/shelve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/shelve.c?rev=1817418&r1=1817417&r2=1817418&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/shelve.c (original)
+++ subversion/trunk/subversion/libsvn_client/shelve.c Thu Dec 7 20:48:04 2017
@@ -384,6 +384,21 @@ svn_client_shelf_get_paths(apr_hash_t **
return SVN_NO_ERROR;
}
+svn_error_t *
+svn_client_shelf_has_changes(svn_boolean_t *has_changes,
+ const char *name,
+ const char *local_abspath,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *scratch_pool)
+{
+ apr_hash_t *patch_paths;
+
+ SVN_ERR(svn_client_shelf_get_paths(&patch_paths, name, local_abspath,
+ ctx, scratch_pool, scratch_pool));
+ *has_changes = (apr_hash_count(patch_paths) != 0);
+ return SVN_NO_ERROR;
+}
+
/* Set *LOGMSG to the log message stored in the file PATCH_ABSPATH.
*
* ### Currently just reads the first line.
Modified: subversion/trunk/subversion/svn/shelve-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/shelve-cmd.c?rev=1817418&r1=1817417&r2=1817418&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/shelve-cmd.c (original)
+++ subversion/trunk/subversion/svn/shelve-cmd.c Thu Dec 7 20:48:04 2017
@@ -167,6 +167,7 @@ svn_cl__shelve(apr_getopt_t *os,
const char *local_abspath;
const char *name;
apr_array_header_t *targets;
+ svn_boolean_t has_changes;
if (opt_state->quiet)
ctx->notify_func2 = NULL; /* Easy out: avoid unneeded work */
@@ -234,11 +235,22 @@ svn_cl__shelve(apr_getopt_t *os,
err, pool));
else
SVN_ERR(err);
-
- if (! opt_state->quiet)
- SVN_ERR(svn_cmdline_printf(pool, "shelved '%s'\n", name));
}
+ /* If no modifications were shelved, throw an error. */
+ SVN_ERR(svn_client_shelf_has_changes(&has_changes,
+ name, local_abspath, ctx, pool));
+ if (! has_changes)
+ {
+ SVN_ERR(svn_client_shelves_delete(name, local_abspath,
+ opt_state->dry_run, ctx, pool));
+ return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+ _("No changes were shelved"));
+ }
+
+ if (! opt_state->quiet)
+ SVN_ERR(svn_cmdline_printf(pool, "shelved '%s'\n", name));
+
return SVN_NO_ERROR;
}