Author: julianfoad
Date: Wed Jul 26 20:59:04 2017
New Revision: 1803112
URL: http://svn.apache.org/viewvc?rev=1803112&view=rev
Log:
On the 'shelve-checkpoint3' branch: Error out appropriately when
checkpointing is or is not initialized.
Modified:
subversion/branches/shelve-checkpoint3/subversion/libsvn_client/checkpoint3.c
Modified:
subversion/branches/shelve-checkpoint3/subversion/libsvn_client/checkpoint3.c
URL:
http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint3/subversion/libsvn_client/checkpoint3.c?rev=1803112&r1=1803111&r2=1803112&view=diff
==============================================================================
---
subversion/branches/shelve-checkpoint3/subversion/libsvn_client/checkpoint3.c
(original)
+++
subversion/branches/shelve-checkpoint3/subversion/libsvn_client/checkpoint3.c
Wed Jul 26 20:59:04 2017
@@ -52,6 +52,8 @@
#include "svn_private_config.h"
+#define SVN_ERR_CHECKPOINT SVN_ERR_ILLEGAL_TARGET
+
/* -------------------- checkpoint repo -------------------- */
/* Return the abspatch to the checkpoints repo.
@@ -197,6 +199,18 @@ checkpoints_repo_prune(const char *repo_
return SVN_NO_ERROR;
}
+/* */
+static svn_boolean_t
+checkpoints_initialized(const char *wc_root_abspath,
+ apr_pool_t *scratch_pool)
+{
+ const char *repo_dir = checkpoints_repo_dir(wc_root_abspath, scratch_pool);
+ svn_node_kind_t kind;
+
+ svn_error_clear(svn_io_check_path(repo_dir, &kind, scratch_pool));
+ return (kind == svn_node_dir);
+}
+
/* -------------------- transfers -------------------- */
/* Update the WC to r(checkpoint_number + 1).
@@ -557,6 +571,12 @@ svn_client_checkpoint_init(const char *l
SVN_ERR(svn_client_get_wc_root(&wc_root_abspath, local_abspath,
ctx, scratch_pool, scratch_pool));
+ if (checkpoints_initialized(wc_root_abspath, scratch_pool))
+ {
+ return svn_error_create(SVN_ERR_CHECKPOINT, NULL,
+ "Checkpoints already initialized");
+ }
+
SVN_ERR(checkpoints_init(wc_root_abspath, ctx, scratch_pool));
return SVN_NO_ERROR;
}
@@ -571,6 +591,12 @@ svn_client_checkpoint_squash(const char
SVN_ERR(svn_client_get_wc_root(&wc_root_abspath, local_abspath,
ctx, scratch_pool, scratch_pool));
+ if (! checkpoints_initialized(wc_root_abspath, scratch_pool))
+ {
+ return svn_error_create(SVN_ERR_CHECKPOINT, NULL,
+ "Checkpoints not initialized");
+ }
+
printf("-- checkpointing any uncheckpointed modifications\n");
SVN_ERR(checkpoint_save(NULL /*checkpoint_number*/,
wc_root_abspath, ctx, scratch_pool));
@@ -594,11 +620,17 @@ svn_client_checkpoint_uninit(const char
{
const char *wc_root_abspath;
- SVN_ERR(svn_client_checkpoint_squash(local_abspath, ctx, scratch_pool));
-
SVN_ERR(svn_client_get_wc_root(&wc_root_abspath, local_abspath,
ctx, scratch_pool, scratch_pool));
+ if (! checkpoints_initialized(wc_root_abspath, scratch_pool))
+ {
+ return svn_error_create(SVN_ERR_CHECKPOINT, NULL,
+ "Checkpoints not initialized");
+ }
+
+ SVN_ERR(svn_client_checkpoint_squash(local_abspath, ctx, scratch_pool));
+
SVN_ERR(checkpoints_uninit(wc_root_abspath, ctx, scratch_pool));
return SVN_NO_ERROR;
}
@@ -614,6 +646,12 @@ svn_client_checkpoint_get_current(int *c
SVN_ERR(svn_client_get_wc_root(&wc_root_abspath, local_abspath,
ctx, scratch_pool, scratch_pool));
+ if (! checkpoints_initialized(wc_root_abspath, scratch_pool))
+ {
+ return svn_error_create(SVN_ERR_CHECKPOINT, NULL,
+ "Checkpoints not initialized");
+ }
+
SVN_ERR(read_current(checkpoint_number_p, wc_root_abspath, ctx,
scratch_pool));
return SVN_NO_ERROR;
@@ -630,6 +668,12 @@ svn_client_checkpoint_save(int *checkpoi
SVN_ERR(svn_client_get_wc_root(&wc_root_abspath, local_abspath,
ctx, scratch_pool, scratch_pool));
+ if (! checkpoints_initialized(wc_root_abspath, scratch_pool))
+ {
+ return svn_error_create(SVN_ERR_CHECKPOINT, NULL,
+ "Checkpoints not initialized");
+ }
+
SVN_ERR(checkpoint_save(checkpoint_number,
wc_root_abspath, ctx, scratch_pool));
@@ -648,6 +692,12 @@ svn_client_checkpoint_revert(int checkpo
SVN_ERR(svn_client_get_wc_root(&wc_root_abspath, local_abspath,
ctx, scratch_pool, scratch_pool));
+ if (! checkpoints_initialized(wc_root_abspath, scratch_pool))
+ {
+ return svn_error_create(SVN_ERR_CHECKPOINT, NULL,
+ "Checkpoints not initialized");
+ }
+
/* ### TODO: Save the current state (of whole WC) */
/* Restore the requested checkpoint */
@@ -718,6 +768,12 @@ svn_client_checkpoint_list(apr_array_hea
apr_pool_t *repos_pool = svn_pool_create(scratch_pool);
svn_repos_t *repos;
+ if (! checkpoints_initialized(wc_root_abspath, scratch_pool))
+ {
+ return svn_error_create(SVN_ERR_CHECKPOINT, NULL,
+ "Checkpoints not initialized");
+ }
+
SVN_ERR(checkpoints_repo_open(&repos, wc_root_abspath,
repos_pool, scratch_pool));