3 * ====================================================================
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
20 * ====================================================================
23 * @file svn_client_shelf.h
24 * @brief Subversion's client library: experimental shelving v3
27 #ifndef SVN_CLIENT_SHELF_H
28 #define SVN_CLIENT_SHELF_H
31 #include <apr_pools.h>
35 #include "svn_client.h"
36 #include "svn_types.h"
37 #include "svn_string.h"
40 #include "private/svn_diff_tree.h"
44 #endif /* __cplusplus */
48 /** Shelving v3, with checkpoints
50 * @defgroup svn_client_shelves_checkpoints Shelves and checkpoints
56 * @warning EXPERIMENTAL.
58 typedef struct svn_client__shelf_t
60 /* Public fields (read-only for public use) */
62 int max_version; /**< @deprecated */
65 const char *wc_root_abspath;
66 const char *shelves_dir;
67 apr_hash_t *revprops; /**< non-null; allocated in POOL */
68 svn_client_ctx_t *ctx;
70 } svn_client__shelf_t;
72 /** One version of a shelved change-set.
74 * @warning EXPERIMENTAL.
76 typedef struct svn_client__shelf_version_t
78 /* Public fields (read-only for public use) */
79 svn_client__shelf_t *shelf;
80 apr_time_t mtime; /**< time-stamp of this version */
83 const char *files_dir_abspath; /**< abspath of the storage area */
84 int version_number; /**< version number starting from 1 */
85 } svn_client__shelf_version_t;
87 /** Open an existing shelf or create a new shelf.
89 * Create a new shelf (containing no versions) if a shelf named @a name
92 * The shelf should be closed after use by calling svn_client_shelf_close().
94 * @a local_abspath is any path in the WC and is used to find the WC root.
96 * @warning EXPERIMENTAL.
100 svn_client__shelf_open_or_create(svn_client__shelf_t **shelf_p,
102 const char *local_abspath,
103 svn_client_ctx_t *ctx,
104 apr_pool_t *result_pool);
106 /** Open an existing shelf named @a name, or error if it doesn't exist.
108 * The shelf should be closed after use by calling svn_client_shelf_close().
110 * @a local_abspath is any path in the WC and is used to find the WC root.
112 * @warning EXPERIMENTAL.
116 svn_client__shelf_open_existing(svn_client__shelf_t **shelf_p,
118 const char *local_abspath,
119 svn_client_ctx_t *ctx,
120 apr_pool_t *result_pool);
124 * If @a shelf is NULL, do nothing; otherwise @a shelf must be an open shelf.
126 * @warning EXPERIMENTAL.
130 svn_client__shelf_close(svn_client__shelf_t *shelf,
131 apr_pool_t *scratch_pool);
133 /** Delete the shelf named @a name, or error if it doesn't exist.
135 * @a local_abspath is any path in the WC and is used to find the WC root.
137 * @warning EXPERIMENTAL.
141 svn_client__shelf_delete(const char *name,
142 const char *local_abspath,
143 svn_boolean_t dry_run,
144 svn_client_ctx_t *ctx,
145 apr_pool_t *scratch_pool);
147 /** Get an editor that, when driven, will store changes in @a shelf_version.
149 * @warning EXPERIMENTAL.
153 svn_client__shelf_mods_editor(const svn_delta_editor_t **editor_p,
155 svn_client__shelf_version_t *shelf_version,
156 svn_wc_notify_func2_t notify_func,
158 svn_client_ctx_t *ctx,
159 apr_pool_t *result_pool);
161 /** Save the local modifications found by @a paths, @a depth,
162 * @a changelists as a new version of @a shelf.
164 * If any paths are shelved, create a new shelf-version and return the new
165 * shelf-version in @a *new_version_p, else set @a *new_version_p to null.
166 * @a new_version_p may be null if that output is not wanted; a new shelf-
167 * version is still saved and may be found through @a shelf.
169 * @a paths are relative to the CWD, or absolute.
171 * For each successfully shelved path: call @a shelved_func (if not null)
172 * with @a shelved_baton.
174 * If any paths cannot be shelved: if @a not_shelved_func is given, call
175 * it with @a not_shelved_baton for each such path, and still create a new
176 * shelf-version if any paths are shelved.
178 * This function does not revert the changes from the WC; use
179 * svn_client_shelf_unapply() for that.
181 * @warning EXPERIMENTAL.
185 svn_client__shelf_save_new_version3(svn_client__shelf_version_t **new_version_p,
186 svn_client__shelf_t *shelf,
187 const apr_array_header_t *paths,
189 const apr_array_header_t *changelists,
190 svn_client_status_func_t shelved_func,
192 svn_client_status_func_t not_shelved_func,
193 void *not_shelved_baton,
194 apr_pool_t *scratch_pool);
196 /** Delete all newer versions of @a shelf newer than @a shelf_version.
198 * If @a shelf_version is null, delete all versions of @a shelf. (The
199 * shelf will still exist, with any log message and other revprops, but
200 * with no versions in it.)
202 * Leave the shelf's log message and other revprops unchanged.
204 * Any #svn_client__shelf_version_t object that refers to a deleted version
205 * will become invalid: attempting to use it will give undefined behaviour.
206 * The given @a shelf_version will remain valid.
208 * @warning EXPERIMENTAL.
212 svn_client__shelf_delete_newer_versions(svn_client__shelf_t *shelf,
213 svn_client__shelf_version_t *shelf_version,
214 apr_pool_t *scratch_pool);
216 /** Return in @a shelf_version an existing version of @a shelf, given its
217 * @a version_number (starting from 1). Error if that version doesn't exist.
219 * There is no need to "close" it after use.
221 * @warning EXPERIMENTAL.
225 svn_client__shelf_version_open(svn_client__shelf_version_t **shelf_version_p,
226 svn_client__shelf_t *shelf,
228 apr_pool_t *result_pool,
229 apr_pool_t *scratch_pool);
231 /** Return in @a shelf_version the newest version of @a shelf.
233 * Set @a shelf_version to null if no versions exist.
235 * @warning EXPERIMENTAL.
239 svn_client__shelf_get_newest_version(svn_client__shelf_version_t **shelf_version_p,
240 svn_client__shelf_t *shelf,
241 apr_pool_t *result_pool,
242 apr_pool_t *scratch_pool);
244 /** Return in @a versions_p an array of (#svn_client__shelf_version_t *)
245 * containing all versions of @a shelf.
247 * The versions will be in chronological order, oldest to newest.
249 * @warning EXPERIMENTAL.
253 svn_client__shelf_get_all_versions(apr_array_header_t **versions_p,
254 svn_client__shelf_t *shelf,
255 apr_pool_t *result_pool,
256 apr_pool_t *scratch_pool);
258 /** Apply @a shelf_version to the WC.
260 * If @a dry_run is true, try applying the shelf-version to the WC and
261 * report the full set of notifications about successes and conflicts,
262 * but leave the WC untouched.
264 * @warning EXPERIMENTAL.
268 svn_client__shelf_apply(svn_client__shelf_version_t *shelf_version,
269 svn_boolean_t dry_run,
270 apr_pool_t *scratch_pool);
272 /** Test whether we can successfully apply the changes for @a file_relpath
273 * in @a shelf_version to the WC.
275 * Set @a *conflict_p to true if the changes conflict with the WC state,
278 * If @a file_relpath is not found in @a shelf_version, set @a *conflict_p
281 * @a file_relpath is relative to the WC root.
283 * A conflict means the shelf cannot be applied successfully to the WC
284 * because the change to be applied is not compatible with the current
285 * working state of the WC file. Examples are a text conflict, or the
286 * file does not exist or is a directory, or the shelf is trying to add
287 * the file but it already exists, or trying to delete it but it does not
290 * Return an error only if something is broken, e.g. unable to read data
291 * from the specified shelf-version.
293 * Leave the WC untouched.
295 * @warning EXPERIMENTAL.
299 svn_client__shelf_test_apply_file(svn_boolean_t *conflict_p,
300 svn_client__shelf_version_t *shelf_version,
301 const char *file_relpath,
302 apr_pool_t *scratch_pool);
304 /** Reverse-apply @a shelf_version to the WC.
306 * @warning EXPERIMENTAL.
310 svn_client__shelf_unapply(svn_client__shelf_version_t *shelf_version,
311 svn_boolean_t dry_run,
312 apr_pool_t *scratch_pool);
314 /** Send committable changes found in a shelf to a delta-editor.
316 * Push changes from the @a shelf_version subtree at @a top_relpath
317 * to @a editor : @a edit_baton.
319 * @warning EXPERIMENTAL.
323 svn_client__shelf_replay(svn_client__shelf_version_t *shelf_version,
324 const char *top_relpath,
325 const svn_delta_editor_t *editor,
327 svn_wc_notify_func2_t notify_func,
329 apr_pool_t *scratch_pool);
331 /** Set @a *affected_paths to a hash with one entry for each path affected
332 * by the @a shelf_version.
334 * The hash key is the path of the affected file, relative to the WC root.
336 * (Future possibility: When moves and copies are supported, the hash key
337 * is the old path and value is the new path.)
339 * @warning EXPERIMENTAL.
343 svn_client__shelf_paths_changed(apr_hash_t **affected_paths,
344 svn_client__shelf_version_t *shelf_version,
345 apr_pool_t *result_pool,
346 apr_pool_t *scratch_pool);
348 /** Set @a shelf's revprop @a prop_name to @a prop_val.
350 * This can be used to set or change the shelf's log message
351 * (property name "svn:log" or #SVN_PROP_REVISION_LOG).
353 * If @a prop_val is NULL, delete the property (if present).
355 * @warning EXPERIMENTAL.
359 svn_client__shelf_revprop_set(svn_client__shelf_t *shelf,
360 const char *prop_name,
361 const svn_string_t *prop_val,
362 apr_pool_t *scratch_pool);
364 /** Set @a shelf's revprops to @a revprop_table.
366 * This deletes all previous revprops.
368 * @warning EXPERIMENTAL.
372 svn_client__shelf_revprop_set_all(svn_client__shelf_t *shelf,
373 apr_hash_t *revprop_table,
374 apr_pool_t *scratch_pool);
376 /** Get @a shelf's revprop @a prop_name into @a *prop_val.
378 * If the property is not present, set @a *prop_val to NULL.
380 * This can be used to get the shelf's log message
381 * (property name "svn:log" or #SVN_PROP_REVISION_LOG).
383 * The lifetime of the result is limited to that of @a shelf and/or
386 * @warning EXPERIMENTAL.
390 svn_client__shelf_revprop_get(svn_string_t **prop_val,
391 svn_client__shelf_t *shelf,
392 const char *prop_name,
393 apr_pool_t *result_pool);
395 /** Get @a shelf's revprops into @a props.
397 * The lifetime of the result is limited to that of @a shelf and/or
400 * @warning EXPERIMENTAL.
404 svn_client__shelf_revprop_list(apr_hash_t **props,
405 svn_client__shelf_t *shelf,
406 apr_pool_t *result_pool);
408 /** Set the log message in @a shelf to @a log_message.
410 * If @a log_message is null, delete the log message.
412 * Similar to svn_client_shelf_revprop_set(... SVN_PROP_REVISION_LOG ...).
414 * @warning EXPERIMENTAL.
418 svn_client__shelf_set_log_message(svn_client__shelf_t *shelf,
419 const char *log_message,
420 apr_pool_t *scratch_pool);
422 /** Get the log message in @a shelf into @a *log_message.
424 * Set @a *log_message to NULL if there is no log message.
426 * Similar to svn_client_shelf_revprop_get(... SVN_PROP_REVISION_LOG ...).
428 * The result is allocated in @a result_pool.
430 * @warning EXPERIMENTAL.
434 svn_client__shelf_get_log_message(char **log_message,
435 svn_client__shelf_t *shelf,
436 apr_pool_t *result_pool);
438 /** Information about a shelf.
440 * @warning EXPERIMENTAL.
442 typedef struct svn_client__shelf_info_t
444 apr_time_t mtime; /**< mtime of the latest change */
445 } svn_client__shelf_info_t;
447 /** Set @a *shelf_infos to a hash, keyed by shelf name, of pointers to
448 * @c svn_client_shelf_info_t structures, one for each shelf in the
451 * @a local_abspath is any path in the WC and is used to find the WC root.
453 * @warning EXPERIMENTAL.
457 svn_client__shelf_list(apr_hash_t **shelf_infos,
458 const char *local_abspath,
459 svn_client_ctx_t *ctx,
460 apr_pool_t *result_pool,
461 apr_pool_t *scratch_pool);
463 /** Report the shelved status of all the shelved paths in @a shelf_version
464 * via @a walk_func(@a walk_baton, ...).
466 * @warning EXPERIMENTAL.
470 svn_client__shelf_version_status_walk(svn_client__shelf_version_t *shelf_version,
471 const char *wc_relpath,
472 svn_wc_status_func4_t walk_func,
474 apr_pool_t *scratch_pool);
476 /** Output the subtree of @a shelf_version rooted at @a shelf_relpath
477 * as a diff to @a diff_processor.
479 * ### depth and ignore_ancestry are currently ignored.
481 * @warning EXPERIMENTAL.
485 svn_client__shelf_diff(svn_client__shelf_version_t *shelf_version,
486 const char *shelf_relpath,
488 svn_boolean_t ignore_ancestry,
489 const svn_diff_tree_processor_t *diff_processor,
490 apr_pool_t *scratch_pool);
496 #endif /* __cplusplus */
498 #endif /* SVN_CLIENT_SHELF_H */