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_shelf2.h
24 * @brief Subversion's client library: experimental shelving v2
27 #ifndef SVN_CLIENT_SHELF2_H
28 #define SVN_CLIENT_SHELF2_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 v2, with checkpoints
50 * @defgroup svn_client_shelves_checkpoints Shelves and checkpoints
56 * @warning EXPERIMENTAL.
58 typedef struct svn_client__shelf2_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__shelf2_t;
72 /** One version of a shelved change-set.
74 * @warning EXPERIMENTAL.
76 typedef struct svn_client__shelf2_version_t
78 /* Public fields (read-only for public use) */
79 svn_client__shelf2_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__shelf2_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__shelf2_open_or_create(svn_client__shelf2_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__shelf2_open_existing(svn_client__shelf2_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__shelf2_close(svn_client__shelf2_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__shelf2_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 /** Save the local modifications found by @a paths, @a depth,
148 * @a changelists as a new version of @a shelf.
150 * If any paths are shelved, create a new shelf-version and return the new
151 * shelf-version in @a *new_version_p, else set @a *new_version_p to null.
152 * @a new_version_p may be null if that output is not wanted; a new shelf-
153 * version is still saved and may be found through @a shelf.
155 * @a paths are relative to the CWD, or absolute.
157 * For each successfully shelved path: call @a shelved_func (if not null)
158 * with @a shelved_baton.
160 * If any paths cannot be shelved: if @a not_shelved_func is given, call
161 * it with @a not_shelved_baton for each such path, and still create a new
162 * shelf-version if any paths are shelved.
164 * This function does not revert the changes from the WC; use
165 * svn_client_shelf_unapply() for that.
167 * @warning EXPERIMENTAL.
171 svn_client__shelf2_save_new_version3(svn_client__shelf2_version_t **new_version_p,
172 svn_client__shelf2_t *shelf,
173 const apr_array_header_t *paths,
175 const apr_array_header_t *changelists,
176 svn_client_status_func_t shelved_func,
178 svn_client_status_func_t not_shelved_func,
179 void *not_shelved_baton,
180 apr_pool_t *scratch_pool);
182 /** Delete all newer versions of @a shelf newer than @a shelf_version.
184 * If @a shelf_version is null, delete all versions of @a shelf. (The
185 * shelf will still exist, with any log message and other revprops, but
186 * with no versions in it.)
188 * Leave the shelf's log message and other revprops unchanged.
190 * Any #svn_client_shelf_version_t object that refers to a deleted version
191 * will become invalid: attempting to use it will give undefined behaviour.
192 * The given @a shelf_version will remain valid.
194 * @warning EXPERIMENTAL.
198 svn_client__shelf2_delete_newer_versions(svn_client__shelf2_t *shelf,
199 svn_client__shelf2_version_t *shelf_version,
200 apr_pool_t *scratch_pool);
202 /** Return in @a shelf_version an existing version of @a shelf, given its
203 * @a version_number. Error if that version doesn't exist.
205 * There is no need to "close" it after use.
207 * @warning EXPERIMENTAL.
211 svn_client__shelf2_version_open(svn_client__shelf2_version_t **shelf_version_p,
212 svn_client__shelf2_t *shelf,
214 apr_pool_t *result_pool,
215 apr_pool_t *scratch_pool);
217 /** Return in @a shelf_version the newest version of @a shelf.
219 * Set @a shelf_version to null if no versions exist.
221 * @warning EXPERIMENTAL.
225 svn_client__shelf2_get_newest_version(svn_client__shelf2_version_t **shelf_version_p,
226 svn_client__shelf2_t *shelf,
227 apr_pool_t *result_pool,
228 apr_pool_t *scratch_pool);
230 /** Return in @a versions_p an array of (#svn_client_shelf_version_t *)
231 * containing all versions of @a shelf.
233 * The versions will be in chronological order, oldest to newest.
235 * @warning EXPERIMENTAL.
239 svn_client__shelf2_get_all_versions(apr_array_header_t **versions_p,
240 svn_client__shelf2_t *shelf,
241 apr_pool_t *result_pool,
242 apr_pool_t *scratch_pool);
244 /** Apply @a shelf_version to the WC.
246 * If @a dry_run is true, try applying the shelf-version to the WC and
247 * report the full set of notifications about successes and conflicts,
248 * but leave the WC untouched.
250 * @warning EXPERIMENTAL.
254 svn_client__shelf2_apply(svn_client__shelf2_version_t *shelf_version,
255 svn_boolean_t dry_run,
256 apr_pool_t *scratch_pool);
258 /** Test whether we can successfully apply the changes for @a file_relpath
259 * in @a shelf_version to the WC.
261 * Set @a *conflict_p to true if the changes conflict with the WC state,
264 * If @a file_relpath is not found in @a shelf_version, set @a *conflict_p
267 * @a file_relpath is relative to the WC root.
269 * A conflict means the shelf cannot be applied successfully to the WC
270 * because the change to be applied is not compatible with the current
271 * working state of the WC file. Examples are a text conflict, or the
272 * file does not exist or is a directory, or the shelf is trying to add
273 * the file but it already exists, or trying to delete it but it does not
276 * Return an error only if something is broken, e.g. unable to read data
277 * from the specified shelf-version.
279 * Leave the WC untouched.
281 * @warning EXPERIMENTAL.
285 svn_client__shelf2_test_apply_file(svn_boolean_t *conflict_p,
286 svn_client__shelf2_version_t *shelf_version,
287 const char *file_relpath,
288 apr_pool_t *scratch_pool);
290 /** Reverse-apply @a shelf_version to the WC.
292 * @warning EXPERIMENTAL.
296 svn_client__shelf2_unapply(svn_client__shelf2_version_t *shelf_version,
297 svn_boolean_t dry_run,
298 apr_pool_t *scratch_pool);
300 /** Set @a *affected_paths to a hash with one entry for each path affected
301 * by the @a shelf_version.
303 * The hash key is the path of the affected file, relative to the WC root.
305 * (Future possibility: When moves and copies are supported, the hash key
306 * is the old path and value is the new path.)
308 * @warning EXPERIMENTAL.
312 svn_client__shelf2_paths_changed(apr_hash_t **affected_paths,
313 svn_client__shelf2_version_t *shelf_version,
314 apr_pool_t *result_pool,
315 apr_pool_t *scratch_pool);
317 /** Set @a shelf's revprop @a prop_name to @a prop_val.
319 * This can be used to set or change the shelf's log message
320 * (property name "svn:log" or #SVN_PROP_REVISION_LOG).
322 * If @a prop_val is NULL, delete the property (if present).
324 * @warning EXPERIMENTAL.
328 svn_client__shelf2_revprop_set(svn_client__shelf2_t *shelf,
329 const char *prop_name,
330 const svn_string_t *prop_val,
331 apr_pool_t *scratch_pool);
333 /** Set @a shelf's revprops to @a revprop_table.
335 * This deletes all previous revprops.
337 * @warning EXPERIMENTAL.
341 svn_client__shelf2_revprop_set_all(svn_client__shelf2_t *shelf,
342 apr_hash_t *revprop_table,
343 apr_pool_t *scratch_pool);
345 /** Get @a shelf's revprop @a prop_name into @a *prop_val.
347 * If the property is not present, set @a *prop_val to NULL.
349 * This can be used to get the shelf's log message
350 * (property name "svn:log" or #SVN_PROP_REVISION_LOG).
352 * The lifetime of the result is limited to that of @a shelf and/or
355 * @warning EXPERIMENTAL.
359 svn_client__shelf2_revprop_get(svn_string_t **prop_val,
360 svn_client__shelf2_t *shelf,
361 const char *prop_name,
362 apr_pool_t *result_pool);
364 /** Get @a shelf's revprops into @a props.
366 * The lifetime of the result is limited to that of @a shelf and/or
369 * @warning EXPERIMENTAL.
373 svn_client__shelf2_revprop_list(apr_hash_t **props,
374 svn_client__shelf2_t *shelf,
375 apr_pool_t *result_pool);
377 /** Set the log message in @a shelf to @a log_message.
379 * If @a log_message is null, delete the log message.
381 * Similar to svn_client_shelf_revprop_set(... SVN_PROP_REVISION_LOG ...).
383 * @warning EXPERIMENTAL.
387 svn_client__shelf2_set_log_message(svn_client__shelf2_t *shelf,
388 const char *log_message,
389 apr_pool_t *scratch_pool);
391 /** Get the log message in @a shelf into @a *log_message.
393 * Set @a *log_message to NULL if there is no log message.
395 * Similar to svn_client_shelf_revprop_get(... SVN_PROP_REVISION_LOG ...).
397 * The result is allocated in @a result_pool.
399 * @warning EXPERIMENTAL.
403 svn_client__shelf2_get_log_message(char **log_message,
404 svn_client__shelf2_t *shelf,
405 apr_pool_t *result_pool);
407 /** Information about a shelf.
409 * @warning EXPERIMENTAL.
411 typedef struct svn_client__shelf2_info_t
413 apr_time_t mtime; /* mtime of the latest change */
414 } svn_client__shelf2_info_t;
416 /** Set @a *shelf_infos to a hash, keyed by shelf name, of pointers to
417 * @c svn_client_shelf_info_t structures, one for each shelf in the
420 * @a local_abspath is any path in the WC and is used to find the WC root.
422 * @warning EXPERIMENTAL.
426 svn_client__shelf2_list(apr_hash_t **shelf_infos,
427 const char *local_abspath,
428 svn_client_ctx_t *ctx,
429 apr_pool_t *result_pool,
430 apr_pool_t *scratch_pool);
432 /* Report the shelved status of all the shelved paths in SHELF_VERSION
433 * via WALK_FUNC(WALK_BATON, ...).
435 * @warning EXPERIMENTAL.
439 svn_client__shelf2_version_status_walk(svn_client__shelf2_version_t *shelf_version,
440 const char *wc_relpath,
441 svn_wc_status_func4_t walk_func,
443 apr_pool_t *scratch_pool);
445 /** Output the subtree of @a shelf_version rooted at @a shelf_relpath
446 * as a diff to @a diff_processor.
448 * ### depth and ignore_ancestry are currently ignored.
450 * @warning EXPERIMENTAL.
454 svn_client__shelf2_diff(svn_client__shelf2_version_t *shelf_version,
455 const char *shelf_relpath,
457 svn_boolean_t ignore_ancestry,
458 const svn_diff_tree_processor_t *diff_processor,
459 apr_pool_t *scratch_pool);
465 #endif /* __cplusplus */
467 #endif /* SVN_CLIENT_SHELF2_H */