Author: julianfoad
Date: Thu Mar 15 16:01:45 2018
New Revision: 1826834
URL: http://svn.apache.org/viewvc?rev=1826834&view=rev
Log:
Shelving: fix problems when a shelf has zero versions.
* subversion/libsvn_client/shelf.c
(shelf_read_revprops): Document better.
(shelf_read_current): Distinguish no versions from non-existent.
(svn_client_shelf_open_existing): Allow opening a shelf with no versions.
(svn_client_shelf_open_or_create): Handle creating a shelf with no
versions.
* subversion/svn/shelf-cmd.c
(shelves_list): Display the shelf name even if it has no versions.
Modified:
subversion/trunk/subversion/libsvn_client/shelf.c
subversion/trunk/subversion/svn/shelf-cmd.c
Modified: subversion/trunk/subversion/libsvn_client/shelf.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/shelf.c?rev=1826834&r1=1826833&r2=1826834&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/shelf.c (original)
+++ subversion/trunk/subversion/libsvn_client/shelf.c Thu Mar 15 16:01:45 2018
@@ -187,7 +187,9 @@ get_log_abspath(char **log_abspath,
return SVN_NO_ERROR;
}
-/* Set SHELF->revprops by reading from its file storage.
+/* Set SHELF->revprops by reading from its storage (the '.log' file).
+ * Set SHELF->revprops to empty if the storage file does not exist; this
+ * is not an error.
*/
static svn_error_t *
shelf_read_revprops(svn_client_shelf_t *shelf,
@@ -295,7 +297,9 @@ get_current_abspath(char **current_abspa
return SVN_NO_ERROR;
}
-/* */
+/* Read SHELF->max_version from its storage (the '.current' file).
+ * Set SHELF->max_version to -1 if that file does not exist.
+ */
static svn_error_t *
shelf_read_current(svn_client_shelf_t *shelf,
apr_pool_t *scratch_pool)
@@ -307,7 +311,7 @@ shelf_read_current(svn_client_shelf_t *s
fp = fopen(current_abspath, "r");
if (! fp)
{
- shelf->max_version = 0;
+ shelf->max_version = -1;
return SVN_NO_ERROR;
}
fscanf(fp, "%d", &shelf->max_version);
@@ -449,7 +453,7 @@ svn_client_shelf_open_existing(svn_clien
local_abspath, ctx, result_pool));
SVN_ERR(shelf_read_revprops(*shelf_p, result_pool));
SVN_ERR(shelf_read_current(*shelf_p, result_pool));
- if ((*shelf_p)->max_version <= 0)
+ if ((*shelf_p)->max_version < 0)
{
return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
_("Shelf '%s' not found"),
@@ -465,10 +469,18 @@ svn_client_shelf_open_or_create(svn_clie
svn_client_ctx_t *ctx,
apr_pool_t *result_pool)
{
- SVN_ERR(shelf_construct(shelf_p, name,
+ svn_client_shelf_t *shelf;
+
+ SVN_ERR(shelf_construct(&shelf, name,
local_abspath, ctx, result_pool));
- SVN_ERR(shelf_read_revprops(*shelf_p, result_pool));
- SVN_ERR(shelf_read_current(*shelf_p, result_pool));
+ SVN_ERR(shelf_read_revprops(shelf, result_pool));
+ SVN_ERR(shelf_read_current(shelf, result_pool));
+ if (shelf->max_version < 0)
+ {
+ shelf->max_version = 0;
+ SVN_ERR(shelf_write_current(shelf, result_pool));
+ }
+ *shelf_p = shelf;
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/svn/shelf-cmd.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/shelf-cmd.c?rev=1826834&r1=1826833&r2=1826834&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/shelf-cmd.c (original)
+++ subversion/trunk/subversion/svn/shelf-cmd.c Thu Mar 15 16:01:45 2018
@@ -267,7 +267,7 @@ shelves_list(const char *local_abspath,
ctx, scratch_pool));
SVN_ERR(svn_client_shelf_get_newest_version(&shelf_version, shelf,
scratch_pool, scratch_pool));
- if (quiet)
+ if (quiet || !shelf_version)
SVN_ERR(svn_cmdline_printf(scratch_pool, "%s\n", shelf->name));
else
SVN_ERR(stats(shelf, shelf->max_version, shelf_version, time_now,