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 11:49:07 UTC
svn commit: r1817360 - in /subversion/branches/shelve-checkpoint/subversion:
include/svn_client.h libsvn_client/shelve.c svn/shelve-cmd.c
Author: julianfoad
Date: Thu Dec 7 11:49:07 2017
New Revision: 1817360
URL: http://svn.apache.org/viewvc?rev=1817360&view=rev
Log:
On the 'shelve-checkpoint' branch: Bail out if 'shelve' finds no modifications.
* subversion/include/svn_client.h,
subversion/libsvn_client/shelve.c
(svn_client_shelf_save_new_version): Don't bump the version number if the
attempted new version is empty.
(svn_client_shelf_get_paths): Add missing 'experimental' tag.
(write_patch): When overwriting an existing file, truncate it.
* subversion/svn/shelve-cmd.c
(shelve): If no modifications found, throw an error.
Modified:
subversion/branches/shelve-checkpoint/subversion/include/svn_client.h
subversion/branches/shelve-checkpoint/subversion/libsvn_client/shelve.c
subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.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=1817360&r1=1817359&r2=1817360&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/include/svn_client.h (original)
+++ subversion/branches/shelve-checkpoint/subversion/include/svn_client.h Thu Dec 7 11:49:07 2017
@@ -6775,6 +6775,9 @@ svn_client_shelf_delete(const char *name
/** Save the local modifications found by @a paths, @a depth,
* @a changelists as a new version of @a shelf.
*
+ * If there are no local modifications in the specified locations, do not
+ * create a new version of @a shelf.
+ *
* @since New in 1.X.
*/
SVN_EXPERIMENTAL
@@ -6858,6 +6861,7 @@ svn_client_shelf_version_get_info(svn_cl
*
* @since New in 1.X.
*/
+SVN_EXPERIMENTAL
svn_error_t *
svn_client_shelf_get_paths(apr_hash_t **affected_paths,
svn_client_shelf_t *shelf,
Modified: subversion/branches/shelve-checkpoint/subversion/libsvn_client/shelve.c
URL: http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint/subversion/libsvn_client/shelve.c?rev=1817360&r1=1817359&r2=1817360&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/libsvn_client/shelve.c (original)
+++ subversion/branches/shelve-checkpoint/subversion/libsvn_client/shelve.c Thu Dec 7 11:49:07 2017
@@ -249,7 +249,7 @@ write_patch(const char *patch_abspath,
/* ### svn_stream_open_writable() doesn't work here: the buffering
goes wrong so that diff headers appear after their hunks.
For now, fix by opening the file without APR_BUFFERED. */
- flag = APR_FOPEN_WRITE | APR_FOPEN_CREATE;
+ flag = APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE;
SVN_ERR(svn_io_file_open(&outfile, patch_abspath,
flag, APR_FPROT_OS_DEFAULT, scratch_pool));
outstream = svn_stream_from_aprfile2(outfile, FALSE /*disown*/, scratch_pool);
@@ -475,14 +475,20 @@ svn_client_shelf_save_new_version(svn_cl
{
int next_version = shelf->max_version + 1;
const char *patch_abspath;
+ apr_finfo_t file_info;
SVN_ERR(get_patch_abspath(&patch_abspath, shelf, next_version,
scratch_pool, scratch_pool));
SVN_ERR(write_patch(patch_abspath,
paths, depth, changelists,
shelf->ctx, scratch_pool));
- SVN_ERR(svn_client_shelf_set_current_version(shelf, next_version,
- scratch_pool));
+
+ SVN_ERR(svn_io_stat(&file_info, patch_abspath, APR_FINFO_MTIME, scratch_pool));
+ if (file_info.size > 0)
+ {
+ SVN_ERR(svn_client_shelf_set_current_version(shelf, next_version,
+ scratch_pool));
+ }
return SVN_NO_ERROR;
}
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=1817360&r1=1817359&r2=1817360&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c (original)
+++ subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c Thu Dec 7 11:49:07 2017
@@ -234,7 +234,12 @@ name_of_youngest(const char **name_p,
* @a depth, @a changelists. Revert the shelved changes from the WC
* unless @a keep_local is true.
*
+ * If no local modifications are found, throw an error.
+ *
* If @a dry_run is true, don't actually do it.
+ *
+ * Report in @a *new_version_p the new version number (or, with dry run,
+ * what it would be).
*/
static svn_error_t *
shelve(int *new_version_p,
@@ -249,13 +254,22 @@ shelve(int *new_version_p,
apr_pool_t *scratch_pool)
{
svn_client_shelf_t *shelf;
+ int previous_version;
SVN_ERR(svn_client_shelf_open(&shelf,
name, local_abspath, ctx, scratch_pool));
+ previous_version = shelf->max_version;
SVN_ERR(svn_client_shelf_save_new_version(shelf,
paths, depth, changelists,
scratch_pool));
+ if (shelf->max_version == previous_version)
+ {
+ SVN_ERR(svn_client_shelf_close(shelf, scratch_pool));
+ return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+ _("No local modifications found"));
+ }
+
if (!keep_local)
{
/* Reverse-apply the patch. This should be a safer way to remove those
@@ -271,8 +285,7 @@ shelve(int *new_version_p,
if (dry_run)
{
- SVN_ERR(svn_client_shelf_set_current_version(shelf,
- shelf->max_version - 1,
+ SVN_ERR(svn_client_shelf_set_current_version(shelf, previous_version,
scratch_pool));
}