69
69
svn_client__checkout_internal(svn_revnum_t *result_rev,
70
svn_boolean_t *timestamp_sleep,
71
72
const char *local_abspath,
72
73
const svn_opt_revision_t *peg_revision,
75
76
svn_boolean_t ignore_externals,
76
77
svn_boolean_t allow_unver_obstructions,
77
svn_boolean_t *timestamp_sleep,
78
svn_ra_session_t *ra_session,
78
79
svn_client_ctx_t *ctx,
80
apr_pool_t *scratch_pool)
81
82
svn_node_kind_t kind;
82
apr_pool_t *session_pool = svn_pool_create(pool);
83
svn_ra_session_t *ra_session;
84
83
svn_client__pathrev_t *pathrev;
86
85
/* Sanity check. Without these, the checkout is meaningless. */
87
86
SVN_ERR_ASSERT(local_abspath != NULL);
88
SVN_ERR_ASSERT(svn_uri_is_canonical(url, pool));
87
SVN_ERR_ASSERT(svn_uri_is_canonical(url, scratch_pool));
89
88
SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
91
90
/* Fulfill the docstring promise of svn_client_checkout: */
94
93
&& (revision->kind != svn_opt_revision_head))
95
94
return svn_error_create(SVN_ERR_CLIENT_BAD_REVISION, NULL, NULL);
97
/* Get the RA connection. */
98
SVN_ERR(svn_client__ra_session_from_path2(&ra_session, &pathrev,
99
url, NULL, peg_revision, revision,
102
pathrev = svn_client__pathrev_dup(pathrev, pool);
103
SVN_ERR(svn_ra_check_path(ra_session, "", pathrev->rev, &kind, pool));
105
svn_pool_destroy(session_pool);
96
/* Get the RA connection, if needed. */
99
svn_error_t *err = svn_ra_reparent(ra_session, url, scratch_pool);
103
if (err->apr_err == SVN_ERR_RA_ILLEGAL_URL)
105
svn_error_clear(err);
109
return svn_error_trace(err);
113
SVN_ERR(svn_client__resolve_rev_and_url(&pathrev,
115
peg_revision, revision,
122
SVN_ERR(svn_client__ra_session_from_path2(&ra_session, &pathrev,
123
url, NULL, peg_revision,
124
revision, ctx, scratch_pool));
127
SVN_ERR(svn_ra_check_path(ra_session, "", pathrev->rev, &kind, scratch_pool));
107
129
if (kind == svn_node_none)
108
130
return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
112
134
(SVN_ERR_UNSUPPORTED_FEATURE , NULL,
113
135
_("URL '%s' refers to a file, not a directory"), pathrev->url);
115
SVN_ERR(svn_io_check_path(local_abspath, &kind, pool));
137
SVN_ERR(svn_io_check_path(local_abspath, &kind, scratch_pool));
117
139
if (kind == svn_node_none)
119
141
/* Bootstrap: create an incomplete working-copy root dir. Its
120
142
entries file should only have an entry for THIS_DIR with a
121
143
URL, revnum, and an 'incomplete' flag. */
122
SVN_ERR(svn_io_make_dir_recursively(local_abspath, pool));
123
SVN_ERR(initialize_area(local_abspath, pathrev, depth, ctx, pool));
144
SVN_ERR(svn_io_make_dir_recursively(local_abspath, scratch_pool));
145
SVN_ERR(initialize_area(local_abspath, pathrev, depth, ctx,
125
148
else if (kind == svn_node_dir)
128
151
const char *entry_url;
130
SVN_ERR(svn_wc_check_wc2(&wc_format, ctx->wc_ctx, local_abspath, pool));
153
SVN_ERR(svn_wc_check_wc2(&wc_format, ctx->wc_ctx, local_abspath,
133
SVN_ERR(initialize_area(local_abspath, pathrev, depth, ctx, pool));
158
SVN_ERR(initialize_area(local_abspath, pathrev, depth, ctx,
137
163
/* Get PATH's URL. */
138
164
SVN_ERR(svn_wc__node_get_url(&entry_url, ctx->wc_ctx, local_abspath,
165
scratch_pool, scratch_pool));
141
167
/* If PATH's existing URL matches the incoming one, then
142
168
just update. This allows 'svn co' to restart an
146
172
SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL,
147
173
_("'%s' is already a working copy for a"
148
174
" different URL"),
149
svn_dirent_local_style(local_abspath, pool));
175
svn_dirent_local_style(local_abspath, scratch_pool));
154
180
return svn_error_createf(SVN_ERR_WC_NODE_KIND_CHANGE, NULL,
155
181
_("'%s' already exists and is not a directory"),
156
svn_dirent_local_style(local_abspath, pool));
182
svn_dirent_local_style(local_abspath,
159
186
/* Have update fix the incompleteness. */
160
SVN_ERR(svn_client__update_internal(result_rev, local_abspath,
161
revision, depth, TRUE,
187
SVN_ERR(svn_client__update_internal(result_rev, timestamp_sleep,
188
local_abspath, revision, depth, TRUE,
162
189
ignore_externals,
163
190
allow_unver_obstructions,
164
191
TRUE /* adds_as_modification */,
166
timestamp_sleep, ctx, pool));
192
FALSE, FALSE, ra_session,
168
195
return SVN_NO_ERROR;
187
214
SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
189
err = svn_client__checkout_internal(result_rev, URL, local_abspath,
216
err = svn_client__checkout_internal(result_rev, &sleep_here,
190
218
peg_revision, revision, depth,
191
219
ignore_externals,
192
allow_unver_obstructions, &sleep_here,
220
allow_unver_obstructions,
221
NULL /* ra_session */,
195
224
svn_io_sleep_for_timestamps(local_abspath, pool);