1251881Speter/**
2251881Speter * @copyright
3251881Speter * ====================================================================
4251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
5251881Speter *    or more contributor license agreements.  See the NOTICE file
6251881Speter *    distributed with this work for additional information
7251881Speter *    regarding copyright ownership.  The ASF licenses this file
8251881Speter *    to you under the Apache License, Version 2.0 (the
9251881Speter *    "License"); you may not use this file except in compliance
10251881Speter *    with the License.  You may obtain a copy of the License at
11251881Speter *
12251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
13251881Speter *
14251881Speter *    Unless required by applicable law or agreed to in writing,
15251881Speter *    software distributed under the License is distributed on an
16251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17251881Speter *    KIND, either express or implied.  See the License for the
18251881Speter *    specific language governing permissions and limitations
19251881Speter *    under the License.
20251881Speter * ====================================================================
21251881Speter * @endcopyright
22251881Speter *
23251881Speter * @file svn_wc_db.h
24251881Speter * @brief The Subversion Working Copy Library - Metadata/Base-Text Support
25251881Speter *
26251881Speter * Requires:
27251881Speter *            - A working copy
28251881Speter *
29251881Speter * Provides:
30251881Speter *            - Ability to manipulate working copy's administrative files.
31251881Speter *
32251881Speter * Used By:
33251881Speter *            - The main working copy library
34251881Speter */
35251881Speter
36251881Speter#ifndef SVN_WC_DB_H
37251881Speter#define SVN_WC_DB_H
38251881Speter
39251881Speter#include "svn_wc.h"
40251881Speter
41251881Speter#include "svn_types.h"
42251881Speter#include "svn_error.h"
43251881Speter#include "svn_config.h"
44251881Speter#include "svn_io.h"
45251881Speter
46251881Speter#include "private/svn_skel.h"
47251881Speter#include "private/svn_sqlite.h"
48251881Speter#include "private/svn_wc_private.h"
49251881Speter
50251881Speter#include "svn_private_config.h"
51251881Speter
52251881Speter#ifdef __cplusplus
53251881Speterextern "C" {
54251881Speter#endif /* __cplusplus */
55251881Speter
56251881Speter/* INTERFACE CONVENTIONS
57251881Speter
58251881Speter   "OUT" PARAMETERS
59251881Speter
60251881Speter   There are numerous functions within this API which take a (large) number
61251881Speter   of "out" parameters. These are listed individually, rather than combined
62251881Speter   into a struct, so that a caller can be fine-grained about the which
63251881Speter   pieces of information are being requested. In many cases, only a subset
64251881Speter   is required, so the implementation can perform various optimizations
65251881Speter   to fulfill the limited request for information.
66251881Speter
67251881Speter
68251881Speter   POOLS
69251881Speter
70251881Speter   wc_db uses the dual-pool paradigm for all of its functions. Any OUT
71251881Speter   parameter will be allocated within the result pool, and all temporary
72251881Speter   allocations will be performed within the scratch pool.
73251881Speter
74251881Speter   The pool that DB is allocated within (the "state" pool) is only used
75251881Speter   for a few, limited allocations to track each of the working copy roots
76251881Speter   that the DB is asked to operate upon. The memory usage on this pool
77251881Speter   is O(# wcroots), which should normally be one or a few. Custom clients
78251881Speter   which hold open structures over a significant period of time should
79251881Speter   pay particular attention to the number of roots touched, and the
80251881Speter   resulting impact on memory consumption (which should still be minimal).
81251881Speter
82251881Speter
83251881Speter   PARAMETER CONVENTIONS
84251881Speter
85251881Speter   * Parameter Order
86251881Speter     - any output arguments
87251881Speter     - DB
88251881Speter     - LOCAL_ABSPATH
89251881Speter     - any other input arguments
90251881Speter     - RESULT_POOL
91251881Speter     - SCRATCH_POOL
92251881Speter
93251881Speter   * DB
94251881Speter     This parameter is the primary context for all operations on the
95251881Speter     metadata for working copies. This parameter is passed to almost every
96251881Speter     function, and maintains information and state about every working
97251881Speter     copy "touched" by any of the APIs in this interface.
98251881Speter
99251881Speter   * *_ABSPATH
100251881Speter     All *_ABSPATH parameters in this API are absolute paths in the local
101251881Speter     filesystem, represented in Subversion internal canonical form.
102251881Speter
103251881Speter   * LOCAL_ABSPATH
104251881Speter     This parameter specifies a particular *versioned* node in the local
105251881Speter     filesystem. From this node, a working copy root is implied, and will
106251881Speter     be used for the given API operation.
107251881Speter
108251881Speter   * LOCAL_DIR_ABSPATH
109251881Speter     This parameter is similar to LOCAL_ABSPATH, but the semantics of the
110251881Speter     parameter and operation require the node to be a directory within
111251881Speter     the working copy.
112251881Speter
113251881Speter   * WRI_ABSPATH
114251881Speter     This is a "Working copy Root Indicator" path. This refers to a location
115251881Speter     in the local filesystem that is anywhere inside a working copy. The given
116251881Speter     operation will be performed within the context of the root of that
117251881Speter     working copy. This does not necessarily need to refer to a specific
118251881Speter     versioned node or the root of a working copy (although it can) -- any
119251881Speter     location, existing or not, is sufficient, as long as it is inside a
120251881Speter     working copy.
121251881Speter     ### TODO: Define behaviour for switches and externals.
122251881Speter     ### Preference has been stated that WRI_ABSPATH should imply the root
123251881Speter     ### of the parent WC of all switches and externals, but that may
124251881Speter     ### not play out well, especially with multiple repositories involved.
125251881Speter*/
126251881Speter
127251881Speter/* Context data structure for interacting with the administrative data. */
128251881Spetertypedef struct svn_wc__db_t svn_wc__db_t;
129251881Speter
130251881Speter
131251881Speter/* Enumerated values describing the state of a node. */
132251881Spetertypedef enum svn_wc__db_status_t {
133251881Speter    /* The node is present and has no known modifications applied to it. */
134251881Speter    svn_wc__db_status_normal,
135251881Speter
136251881Speter    /* The node has been added (potentially obscuring a delete or move of
137251881Speter       the BASE node; see HAVE_BASE param [### What param? This is an enum
138251881Speter       not a function.] ). The text will be marked as
139251881Speter       modified, and if properties exist, they will be marked as modified.
140251881Speter
141251881Speter       In many cases svn_wc__db_status_added means any of added, moved-here
142251881Speter       or copied-here. See individual functions for clarification and
143251881Speter       svn_wc__db_scan_addition() to get more details. */
144251881Speter    svn_wc__db_status_added,
145251881Speter
146251881Speter    /* This node has been added with history, based on the move source.
147251881Speter       Text and property modifications are based on whether changes have
148251881Speter       been made against their pristine versions. */
149251881Speter    svn_wc__db_status_moved_here,
150251881Speter
151251881Speter    /* This node has been added with history, based on the copy source.
152251881Speter       Text and property modifications are based on whether changes have
153251881Speter       been made against their pristine versions. */
154251881Speter    svn_wc__db_status_copied,
155251881Speter
156251881Speter    /* This node has been deleted. No text or property modifications
157251881Speter       will be present. */
158251881Speter    svn_wc__db_status_deleted,
159251881Speter
160251881Speter    /* This node was named by the server, but no information was provided. */
161251881Speter    svn_wc__db_status_server_excluded,
162251881Speter
163251881Speter    /* This node has been administratively excluded. */
164251881Speter    svn_wc__db_status_excluded,
165251881Speter
166251881Speter    /* This node is not present in this revision. This typically happens
167251881Speter       when a node is deleted and committed without updating its parent.
168251881Speter       The parent revision indicates it should be present, but this node's
169251881Speter       revision states otherwise. */
170251881Speter    svn_wc__db_status_not_present,
171251881Speter
172251881Speter    /* This node is known, but its information is incomplete. Generally,
173251881Speter       it should be treated similar to the other missing status values
174251881Speter       until some (later) process updates the node with its data.
175251881Speter
176251881Speter       When the incomplete status applies to a directory, the list of
177251881Speter       children and the list of its base properties as recorded in the
178251881Speter       working copy do not match their working copy versions.
179251881Speter       The update editor can complete a directory by using a different
180251881Speter       update algorithm. */
181251881Speter    svn_wc__db_status_incomplete,
182251881Speter
183251881Speter    /* The BASE node has been marked as deleted. Only used as an internal
184251881Speter       status in wc_db.c and entries.c.  */
185251881Speter    svn_wc__db_status_base_deleted
186251881Speter
187251881Speter} svn_wc__db_status_t;
188251881Speter
189251881Speter/* Lock information.  We write/read it all as one, so let's use a struct
190251881Speter   for convenience.  */
191251881Spetertypedef struct svn_wc__db_lock_t {
192251881Speter  /* The lock token */
193251881Speter  const char *token;
194251881Speter
195251881Speter  /* The owner of the lock, possibly NULL */
196251881Speter  const char *owner;
197251881Speter
198251881Speter  /* A comment about the lock, possibly NULL */
199251881Speter  const char *comment;
200251881Speter
201251881Speter  /* The date the lock was created */
202251881Speter  apr_time_t date;
203251881Speter} svn_wc__db_lock_t;
204251881Speter
205251881Speter
206251881Speter/* ### NOTE: I have not provided docstrings for most of this file at this
207251881Speter   ### point in time. The shape and extent of this API is still in massive
208251881Speter   ### flux. I'm iterating in public, but do not want to doc until it feels
209251881Speter   ### like it is "Right".
210251881Speter*/
211251881Speter
212251881Speter/* ### where/how to handle: text_time, locks, working_size */
213251881Speter
214251881Speter
215251881Speter/*
216251881Speter  @defgroup svn_wc__db_admin  General administrative functions
217251881Speter  @{
218251881Speter*/
219251881Speter
220251881Speter/* Open a working copy administrative database context.
221251881Speter
222251881Speter   This context is (initially) not associated with any particular working
223251881Speter   copy directory or working copy root (wcroot). As operations are performed,
224251881Speter   this context will load the appropriate wcroot information.
225251881Speter
226251881Speter   The context is returned in DB.
227251881Speter
228251881Speter   CONFIG should hold the various configuration options that may apply to
229251881Speter   the administrative operation. It should live at least as long as the
230251881Speter   RESULT_POOL parameter.
231251881Speter
232251881Speter   When OPEN_WITHOUT_UPGRADE is TRUE, then the working copy databases will
233251881Speter   be opened even when an old database format is found/detected during
234251881Speter   the operation of a wc_db API). If open_without_upgrade is FALSE and an
235251881Speter   upgrade is required, then SVN_ERR_WC_UPGRADE_REQUIRED will be returned
236251881Speter   from that API.
237251881Speter   Passing TRUE will allow a bare minimum of APIs to function (most notably,
238251881Speter   the temp_get_format() function will always return a value) since most of
239251881Speter   these APIs expect a current-format database to be present.
240251881Speter
241251881Speter   If ENFORCE_EMPTY_WQ is TRUE, then any databases with stale work items in
242251881Speter   their work queue will raise an error when they are opened. The operation
243251881Speter   will raise SVN_ERR_WC_CLEANUP_REQUIRED. Passing FALSE for this routine
244251881Speter   means that the work queue is being processed (via 'svn cleanup') and all
245251881Speter   operations should be allowed.
246251881Speter
247251881Speter   The DB will be closed when RESULT_POOL is cleared. It may also be closed
248251881Speter   manually using svn_wc__db_close(). In particular, this will close any
249251881Speter   SQLite databases that have been opened and cached.
250251881Speter
251251881Speter   The context is allocated in RESULT_POOL. This pool is *retained* and used
252251881Speter   for future allocations within the DB. Be forewarned about unbounded
253251881Speter   memory growth if this DB is used across an unbounded number of wcroots
254251881Speter   and versioned directories.
255251881Speter
256251881Speter   Temporary allocations will be made in SCRATCH_POOL.
257251881Speter*/
258251881Spetersvn_error_t *
259251881Spetersvn_wc__db_open(svn_wc__db_t **db,
260251881Speter                svn_config_t *config,
261251881Speter                svn_boolean_t open_without_upgrade,
262251881Speter                svn_boolean_t enforce_empty_wq,
263251881Speter                apr_pool_t *result_pool,
264251881Speter                apr_pool_t *scratch_pool);
265251881Speter
266251881Speter
267251881Speter/* Close DB.  */
268251881Spetersvn_error_t *
269251881Spetersvn_wc__db_close(svn_wc__db_t *db);
270251881Speter
271251881Speter
272251881Speter/* Initialize the SDB for LOCAL_ABSPATH, which should be a working copy path.
273251881Speter
274251881Speter   A REPOSITORY row will be constructed for the repository identified by
275251881Speter   REPOS_ROOT_URL and REPOS_UUID. Neither of these may be NULL.
276251881Speter
277251881Speter   A BASE_NODE row will be created for the directory at REPOS_RELPATH at
278251881Speter   revision INITIAL_REV.
279251881Speter   If INITIAL_REV is greater than zero, then the node will be marked as
280251881Speter   "incomplete" because we don't know its children. Contrary, if the
281251881Speter   INITIAL_REV is zero, then this directory should represent the root and
282251881Speter   we know it has no children, so the node is complete.
283251881Speter
284251881Speter   ### Is there any benefit to marking it 'complete' if rev==0?  Seems like
285251881Speter   ### an unnecessary special case.
286251881Speter
287251881Speter   DEPTH is the initial depth of the working copy; it must be a definite
288251881Speter   depth, not svn_depth_unknown.
289251881Speter
290251881Speter   Use SCRATCH_POOL for temporary allocations.
291251881Speter*/
292251881Spetersvn_error_t *
293251881Spetersvn_wc__db_init(svn_wc__db_t *db,
294251881Speter                const char *local_abspath,
295251881Speter                const char *repos_relpath,
296251881Speter                const char *repos_root_url,
297251881Speter                const char *repos_uuid,
298251881Speter                svn_revnum_t initial_rev,
299251881Speter                svn_depth_t depth,
300251881Speter                apr_pool_t *scratch_pool);
301251881Speter
302251881Speter
303251881Speter/* Compute the LOCAL_RELPATH for the given LOCAL_ABSPATH, relative
304251881Speter   from wri_abspath.
305251881Speter
306251881Speter   The LOCAL_RELPATH is a relative path to the working copy's root. That
307251881Speter   root will be located by this function, and the path will be relative to
308251881Speter   that location. If LOCAL_ABSPATH is the wcroot directory, then "" will
309251881Speter   be returned.
310251881Speter
311251881Speter   The LOCAL_RELPATH should ONLY be used for persisting paths to disk.
312251881Speter   Those paths should not be abspaths, otherwise the working copy cannot
313251881Speter   be moved. The working copy library should not make these paths visible
314251881Speter   in its API (which should all be abspaths), and it should not be using
315251881Speter   relpaths for other processing.
316251881Speter
317251881Speter   LOCAL_RELPATH will be allocated in RESULT_POOL. All other (temporary)
318251881Speter   allocations will be made in SCRATCH_POOL.
319251881Speter
320251881Speter   This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
321251881Speter   option.
322251881Speter*/
323251881Spetersvn_error_t *
324251881Spetersvn_wc__db_to_relpath(const char **local_relpath,
325251881Speter                      svn_wc__db_t *db,
326251881Speter                      const char *wri_abspath,
327251881Speter                      const char *local_abspath,
328251881Speter                      apr_pool_t *result_pool,
329251881Speter                      apr_pool_t *scratch_pool);
330251881Speter
331251881Speter
332251881Speter/* Compute the LOCAL_ABSPATH for a LOCAL_RELPATH located within the working
333251881Speter   copy identified by WRI_ABSPATH.
334251881Speter
335251881Speter   This is the reverse of svn_wc__db_to_relpath. It should be used for
336251881Speter   returning a persisted relpath back into an abspath.
337251881Speter
338251881Speter   LOCAL_ABSPATH will be allocated in RESULT_POOL. All other (temporary)
339251881Speter   allocations will be made in SCRATCH_POOL.
340251881Speter
341251881Speter   This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
342251881Speter   option.
343251881Speter */
344251881Spetersvn_error_t *
345251881Spetersvn_wc__db_from_relpath(const char **local_abspath,
346251881Speter                        svn_wc__db_t *db,
347251881Speter                        const char *wri_abspath,
348251881Speter                        const char *local_relpath,
349251881Speter                        apr_pool_t *result_pool,
350251881Speter                        apr_pool_t *scratch_pool);
351251881Speter
352251881Speter/* Compute the working copy root WCROOT_ABSPATH for WRI_ABSPATH using DB.
353251881Speter
354251881Speter   This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
355251881Speter   option.
356251881Speter */
357251881Spetersvn_error_t *
358251881Spetersvn_wc__db_get_wcroot(const char **wcroot_abspath,
359251881Speter                      svn_wc__db_t *db,
360251881Speter                      const char *wri_abspath,
361251881Speter                      apr_pool_t *result_pool,
362251881Speter                      apr_pool_t *scratch_pool);
363251881Speter
364251881Speter
365251881Speter/* @} */
366251881Speter
367251881Speter/* Different kinds of trees
368251881Speter
369251881Speter   The design doc mentions three different kinds of trees, BASE, WORKING and
370251881Speter   ACTUAL: http://svn.apache.org/repos/asf/subversion/trunk/notes/wc-ng-design
371251881Speter   We have different APIs to handle each tree, enumerated below, along with
372251881Speter   a blurb to explain what that tree represents.
373251881Speter*/
374251881Speter
375251881Speter/* @defgroup svn_wc__db_base  BASE tree management
376251881Speter
377251881Speter   BASE is what we get from the server.  It is the *absolute* pristine copy.
378251881Speter   You need to use checkout, update, switch, or commit to alter your view of
379251881Speter   the repository.
380251881Speter
381251881Speter   In the BASE tree, each node corresponds to a particular node-rev in the
382251881Speter   repository.  It can be a mixed-revision tree.  Each node holds either a
383251881Speter   copy of the node-rev as it exists in the repository (if presence =
384251881Speter   'normal'), or a place-holder (if presence = 'server-excluded' or 'excluded' or
385251881Speter   'not-present').
386251881Speter
387251881Speter   @{
388251881Speter*/
389251881Speter
390251881Speter/* Add or replace a directory in the BASE tree.
391251881Speter
392251881Speter   The directory is located at LOCAL_ABSPATH on the local filesystem, and
393251881Speter   corresponds to <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID> in the
394251881Speter   repository, at revision REVISION.
395251881Speter
396251881Speter   The directory properties are given by the PROPS hash (which is
397251881Speter   const char *name => const svn_string_t *).
398251881Speter
399251881Speter   The last-change information is given by <CHANGED_REV, CHANGED_DATE,
400251881Speter   CHANGED_AUTHOR>.
401251881Speter
402251881Speter   The directory's children are listed in CHILDREN, as an array of
403251881Speter   const char *. The child nodes do NOT have to exist when this API
404251881Speter   is called. For each child node which does not exists, an "incomplete"
405251881Speter   node will be added. These child nodes will be added regardless of
406251881Speter   the DEPTH value. The caller must sort out which must be recorded,
407251881Speter   and which must be omitted.
408251881Speter
409251881Speter   This subsystem does not use DEPTH, but it can be recorded here in
410251881Speter   the BASE tree for higher-level code to use.
411251881Speter
412251881Speter   If DAV_CACHE is not NULL, sets LOCAL_ABSPATH's dav cache to the specified
413251881Speter   data.
414251881Speter
415251881Speter   If CONFLICT is not NULL, then it describes a conflict for this node. The
416251881Speter   node will be record as conflicted (in ACTUAL).
417251881Speter
418251881Speter   If UPDATE_ACTUAL_PROPS is TRUE, set the properties store NEW_ACTUAL_PROPS
419251881Speter   as the new set of properties in ACTUAL. If NEW_ACTUAL_PROPS is NULL or
420251881Speter   when the value of NEW_ACTUAL_PROPS matches NEW_PROPS, store NULL in
421251881Speter   ACTUAL, to mark the properties unmodified.
422251881Speter
423251881Speter   If NEW_IPROPS is not NULL, then it is a depth-first ordered array of
424251881Speter   svn_prop_inherited_item_t * structures that is set as the base node's
425251881Speter   inherited_properties.
426251881Speter
427251881Speter   Any work items that are necessary as part of this node construction may
428251881Speter   be passed in WORK_ITEMS.
429251881Speter
430251881Speter   All temporary allocations will be made in SCRATCH_POOL.
431251881Speter*/
432251881Spetersvn_error_t *
433251881Spetersvn_wc__db_base_add_directory(svn_wc__db_t *db,
434251881Speter                              const char *local_abspath,
435251881Speter                              const char *wri_abspath,
436251881Speter                              const char *repos_relpath,
437251881Speter                              const char *repos_root_url,
438251881Speter                              const char *repos_uuid,
439251881Speter                              svn_revnum_t revision,
440251881Speter                              const apr_hash_t *props,
441251881Speter                              svn_revnum_t changed_rev,
442251881Speter                              apr_time_t changed_date,
443251881Speter                              const char *changed_author,
444251881Speter                              const apr_array_header_t *children,
445251881Speter                              svn_depth_t depth,
446251881Speter                              apr_hash_t *dav_cache,
447251881Speter                              const svn_skel_t *conflict,
448251881Speter                              svn_boolean_t update_actual_props,
449251881Speter                              apr_hash_t *new_actual_props,
450251881Speter                              apr_array_header_t *new_iprops,
451251881Speter                              const svn_skel_t *work_items,
452251881Speter                              apr_pool_t *scratch_pool);
453251881Speter
454251881Speter/* Add a new directory in BASE, whether WORKING nodes exist or not. Mark it
455251881Speter   as incomplete and with revision REVISION. If REPOS_RELPATH is not NULL,
456251881Speter   apply REPOS_RELPATH, REPOS_ROOT_URL and REPOS_UUID.
457251881Speter   Perform all temporary allocations in SCRATCH_POOL.
458251881Speter   */
459251881Spetersvn_error_t *
460251881Spetersvn_wc__db_base_add_incomplete_directory(svn_wc__db_t *db,
461251881Speter                                         const char *local_abspath,
462251881Speter                                         const char *repos_relpath,
463251881Speter                                         const char *repos_root_url,
464251881Speter                                         const char *repos_uuid,
465251881Speter                                         svn_revnum_t revision,
466251881Speter                                         svn_depth_t depth,
467251881Speter                                         svn_boolean_t insert_base_deleted,
468251881Speter                                         svn_boolean_t delete_working,
469251881Speter                                         svn_skel_t *conflict,
470251881Speter                                         svn_skel_t *work_items,
471251881Speter                                         apr_pool_t *scratch_pool);
472251881Speter
473251881Speter
474251881Speter/* Add or replace a file in the BASE tree.
475251881Speter
476251881Speter   The file is located at LOCAL_ABSPATH on the local filesystem, and
477251881Speter   corresponds to <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID> in the
478251881Speter   repository, at revision REVISION.
479251881Speter
480251881Speter   The file properties are given by the PROPS hash (which is
481251881Speter   const char *name => const svn_string_t *).
482251881Speter
483251881Speter   The last-change information is given by <CHANGED_REV, CHANGED_DATE,
484251881Speter   CHANGED_AUTHOR>.
485251881Speter
486251881Speter   The checksum of the file contents is given in CHECKSUM. An entry in
487251881Speter   the pristine text base is NOT required when this API is called.
488251881Speter
489251881Speter   If DAV_CACHE is not NULL, sets LOCAL_ABSPATH's dav cache to the specified
490251881Speter   data.
491251881Speter
492251881Speter   If CONFLICT is not NULL, then it describes a conflict for this node. The
493251881Speter   node will be record as conflicted (in ACTUAL).
494251881Speter
495251881Speter   If UPDATE_ACTUAL_PROPS is TRUE, set the properties store NEW_ACTUAL_PROPS
496251881Speter   as the new set of properties in ACTUAL. If NEW_ACTUAL_PROPS is NULL or
497251881Speter   when the value of NEW_ACTUAL_PROPS matches NEW_PROPS, store NULL in
498251881Speter   ACTUAL, to mark the properties unmodified.
499251881Speter
500251881Speter   Any work items that are necessary as part of this node construction may
501251881Speter   be passed in WORK_ITEMS.
502251881Speter
503251881Speter   Unless KEEP_RECORDED_INFO is set to TRUE, recorded size and timestamp values
504251881Speter   will be cleared.
505251881Speter
506251881Speter   All temporary allocations will be made in SCRATCH_POOL.
507251881Speter*/
508251881Spetersvn_error_t *
509251881Spetersvn_wc__db_base_add_file(svn_wc__db_t *db,
510251881Speter                         const char *local_abspath,
511251881Speter                         const char *wri_abspath,
512251881Speter                         const char *repos_relpath,
513251881Speter                         const char *repos_root_url,
514251881Speter                         const char *repos_uuid,
515251881Speter                         svn_revnum_t revision,
516251881Speter                         const apr_hash_t *props,
517251881Speter                         svn_revnum_t changed_rev,
518251881Speter                         apr_time_t changed_date,
519251881Speter                         const char *changed_author,
520251881Speter                         const svn_checksum_t *checksum,
521251881Speter                         apr_hash_t *dav_cache,
522251881Speter                         svn_boolean_t delete_working,
523251881Speter                         svn_boolean_t update_actual_props,
524251881Speter                         apr_hash_t *new_actual_props,
525251881Speter                         apr_array_header_t *new_iprops,
526251881Speter                         svn_boolean_t keep_recorded_info,
527251881Speter                         svn_boolean_t insert_base_deleted,
528251881Speter                         const svn_skel_t *conflict,
529251881Speter                         const svn_skel_t *work_items,
530251881Speter                         apr_pool_t *scratch_pool);
531251881Speter
532251881Speter
533251881Speter/* Add or replace a symlink in the BASE tree.
534251881Speter
535251881Speter   The symlink is located at LOCAL_ABSPATH on the local filesystem, and
536251881Speter   corresponds to <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID> in the
537251881Speter   repository, at revision REVISION.
538251881Speter
539251881Speter   The symlink's properties are given by the PROPS hash (which is
540251881Speter   const char *name => const svn_string_t *).
541251881Speter
542251881Speter   The last-change information is given by <CHANGED_REV, CHANGED_DATE,
543251881Speter   CHANGED_AUTHOR>.
544251881Speter
545251881Speter   The target of the symlink is specified by TARGET.
546251881Speter
547251881Speter   If DAV_CACHE is not NULL, sets LOCAL_ABSPATH's dav cache to the specified
548251881Speter   data.
549251881Speter
550251881Speter   If CONFLICT is not NULL, then it describes a conflict for this node. The
551251881Speter   node will be record as conflicted (in ACTUAL).
552251881Speter
553251881Speter   If UPDATE_ACTUAL_PROPS is TRUE, set the properties store NEW_ACTUAL_PROPS
554251881Speter   as the new set of properties in ACTUAL. If NEW_ACTUAL_PROPS is NULL or
555251881Speter   when the value of NEW_ACTUAL_PROPS matches NEW_PROPS, store NULL in
556251881Speter   ACTUAL, to mark the properties unmodified.
557251881Speter
558251881Speter   Any work items that are necessary as part of this node construction may
559251881Speter   be passed in WORK_ITEMS.
560251881Speter
561251881Speter   All temporary allocations will be made in SCRATCH_POOL.
562251881Speter*/
563251881Speter/* ### KFF: This is an interesting question, because currently
564251881Speter   ### symlinks are versioned as regular files with the svn:special
565251881Speter   ### property; then the file's text contents indicate that it is a
566251881Speter   ### symlink and where that symlink points.  That's for portability:
567251881Speter   ### you can check 'em out onto a platform that doesn't support
568251881Speter   ### symlinks, and even modify the link and check it back in.  It's
569251881Speter   ### a great solution; but then the question for wc-ng is:
570251881Speter   ###
571251881Speter   ### Suppose you check out a symlink on platform X and platform Y.
572251881Speter   ### X supports symlinks; Y does not.  Should the wc-ng storage for
573251881Speter   ### those two be the same?  I mean, on platform Y, the file is just
574251881Speter   ### going to look and behave like a regular file.  It would be sort
575251881Speter   ### of odd for the wc-ng storage for that file to be of a different
576251881Speter   ### type from all the other files.  (On the other hand, maybe it's
577251881Speter   ### weird today that the wc-1 storage for a working symlink is to
578251881Speter   ### be like a regular file (i.e., regular text-base and whatnot).
579251881Speter   ###
580251881Speter   ### I'm still feeling my way around this problem; just pointing out
581251881Speter   ### the issues.
582251881Speter
583251881Speter   ### gjs: symlinks are stored in the database as first-class objects,
584251881Speter   ###   rather than in the filesystem as "special" regular files. thus,
585251881Speter   ###   all portability concerns are moot. higher-levels can figure out
586251881Speter   ###   how to represent the link in ACTUAL. higher-levels can also
587251881Speter   ###   deal with translating to/from the svn:special property and
588251881Speter   ###   the plain-text file contents.
589251881Speter   ### dlr: What about hard links? At minimum, mention in doc string.
590251881Speter*/
591251881Spetersvn_error_t *
592251881Spetersvn_wc__db_base_add_symlink(svn_wc__db_t *db,
593251881Speter                            const char *local_abspath,
594251881Speter                            const char *wri_abspath,
595251881Speter                            const char *repos_relpath,
596251881Speter                            const char *repos_root_url,
597251881Speter                            const char *repos_uuid,
598251881Speter                            svn_revnum_t revision,
599251881Speter                            const apr_hash_t *props,
600251881Speter                            svn_revnum_t changed_rev,
601251881Speter                            apr_time_t changed_date,
602251881Speter                            const char *changed_author,
603251881Speter                            const char *target,
604251881Speter                            apr_hash_t *dav_cache,
605251881Speter                            svn_boolean_t delete_working,
606251881Speter                            svn_boolean_t update_actual_props,
607251881Speter                            apr_hash_t *new_actual_props,
608251881Speter                            apr_array_header_t *new_iprops,
609251881Speter                            svn_boolean_t keep_recorded_info,
610251881Speter                            svn_boolean_t insert_base_deleted,
611251881Speter                            const svn_skel_t *conflict,
612251881Speter                            const svn_skel_t *work_items,
613251881Speter                            apr_pool_t *scratch_pool);
614251881Speter
615251881Speter
616251881Speter/* Create a node in the BASE tree that is present in name only.
617251881Speter
618251881Speter   The new node will be located at LOCAL_ABSPATH, and correspond to the
619251881Speter   repository node described by <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID>
620251881Speter   at revision REVISION.
621251881Speter
622251881Speter   The node's kind is described by KIND, and the reason for its absence
623251881Speter   is specified by STATUS. Only these values are allowed for STATUS:
624251881Speter
625251881Speter     svn_wc__db_status_server_excluded
626251881Speter     svn_wc__db_status_excluded
627251881Speter
628251881Speter   If CONFLICT is not NULL, then it describes a conflict for this node. The
629251881Speter   node will be record as conflicted (in ACTUAL).
630251881Speter
631251881Speter   Any work items that are necessary as part of this node construction may
632251881Speter   be passed in WORK_ITEMS.
633251881Speter
634251881Speter   All temporary allocations will be made in SCRATCH_POOL.
635251881Speter*/
636251881Spetersvn_error_t *
637251881Spetersvn_wc__db_base_add_excluded_node(svn_wc__db_t *db,
638251881Speter                                  const char *local_abspath,
639251881Speter                                  const char *repos_relpath,
640251881Speter                                  const char *repos_root_url,
641251881Speter                                  const char *repos_uuid,
642251881Speter                                  svn_revnum_t revision,
643251881Speter                                  svn_node_kind_t kind,
644251881Speter                                  svn_wc__db_status_t status,
645251881Speter                                  const svn_skel_t *conflict,
646251881Speter                                  const svn_skel_t *work_items,
647251881Speter                                  apr_pool_t *scratch_pool);
648251881Speter
649251881Speter
650251881Speter/* Create a node in the BASE tree that is present in name only.
651251881Speter
652251881Speter   The new node will be located at LOCAL_ABSPATH, and correspond to the
653251881Speter   repository node described by <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID>
654251881Speter   at revision REVISION.
655251881Speter
656251881Speter   The node's kind is described by KIND, and the reason for its absence
657251881Speter   is 'svn_wc__db_status_not_present'.
658251881Speter
659251881Speter   If CONFLICT is not NULL, then it describes a conflict for this node. The
660251881Speter   node will be record as conflicted (in ACTUAL).
661251881Speter
662251881Speter   Any work items that are necessary as part of this node construction may
663251881Speter   be passed in WORK_ITEMS.
664251881Speter
665251881Speter   All temporary allocations will be made in SCRATCH_POOL.
666251881Speter*/
667251881Spetersvn_error_t *
668251881Spetersvn_wc__db_base_add_not_present_node(svn_wc__db_t *db,
669251881Speter                                     const char *local_abspath,
670251881Speter                                     const char *repos_relpath,
671251881Speter                                     const char *repos_root_url,
672251881Speter                                     const char *repos_uuid,
673251881Speter                                     svn_revnum_t revision,
674251881Speter                                     svn_node_kind_t kind,
675251881Speter                                     const svn_skel_t *conflict,
676251881Speter                                     const svn_skel_t *work_items,
677251881Speter                                     apr_pool_t *scratch_pool);
678251881Speter
679251881Speter
680251881Speter/* Remove a node and all its descendants from the BASE tree. This handles
681251881Speter   the deletion of a tree from the update editor and some file external
682251881Speter   scenarios.
683251881Speter
684251881Speter   The node to remove is indicated by LOCAL_ABSPATH from the local
685251881Speter   filesystem.
686251881Speter
687251881Speter   This operation *installs* workqueue operations to update the local
688251881Speter   filesystem after the database operation.
689251881Speter
690251881Speter   To maintain a consistent database this function will also remove
691251881Speter   any working node that marks LOCAL_ABSPATH as base-deleted.  If this
692251881Speter   results in there being no working node for LOCAL_ABSPATH then any
693251881Speter   actual node will be removed if the actual node does not mark a
694251881Speter   conflict.
695251881Speter
696251881Speter   If KEEP_AS_WORKING is TRUE, then the base tree is copied to higher
697251881Speter   layers as a copy of itself before deleting the BASE nodes.
698251881Speter
699251881Speter   If KEEP_AS_WORKING is FALSE, and QUEUE_DELETES is TRUE, also queue
700251881Speter   workqueue items to delete all in-wc representations that aren't
701251881Speter   shadowed by higher layers.
702251881Speter   (With KEEP_AS_WORKING TRUE, this is a no-op, as everything is
703251881Speter    automatically shadowed by the created copy)
704251881Speter
705253734Speter   If REMOVE_LOCKS is TRUE, all locks of this node and any subnodes
706253734Speter   are also removed. This is to be done during commit of deleted nodes.
707253734Speter
708251881Speter   If NOT_PRESENT_REVISION specifies a valid revision a not-present
709251881Speter   node is installed in BASE node with kind NOT_PRESENT_KIND after
710251881Speter   deleting.
711251881Speter
712251881Speter   If CONFLICT and/or WORK_ITEMS are passed they are installed as part
713251881Speter   of the operation, after the work items inserted by the operation
714251881Speter   itself.
715251881Speter*/
716251881Spetersvn_error_t *
717251881Spetersvn_wc__db_base_remove(svn_wc__db_t *db,
718251881Speter                       const char *local_abspath,
719251881Speter                       svn_boolean_t keep_as_working,
720251881Speter                       svn_boolean_t queue_deletes,
721253734Speter                       svn_boolean_t remove_locks,
722251881Speter                       svn_revnum_t not_present_revision,
723251881Speter                       svn_skel_t *conflict,
724251881Speter                       svn_skel_t *work_items,
725251881Speter                       apr_pool_t *scratch_pool);
726251881Speter
727251881Speter
728251881Speter/* Retrieve information about a node in the BASE tree.
729251881Speter
730251881Speter   For the BASE node implied by LOCAL_ABSPATH from the local filesystem,
731251881Speter   return information in the provided OUT parameters. Each OUT parameter
732251881Speter   may be NULL, indicating that specific item is not requested.
733251881Speter
734251881Speter   If there is no information about this node, then SVN_ERR_WC_PATH_NOT_FOUND
735251881Speter   will be returned.
736251881Speter
737251881Speter   The OUT parameters, and their "not available" values are:
738251881Speter     STATUS             n/a (always available)
739251881Speter     KIND               n/a (always available)
740251881Speter     REVISION           SVN_INVALID_REVNUM
741251881Speter     REPOS_RELPATH      NULL (caller should scan up)
742251881Speter     REPOS_ROOT_URL     NULL (caller should scan up)
743251881Speter     REPOS_UUID         NULL (caller should scan up)
744251881Speter     CHANGED_REV        SVN_INVALID_REVNUM
745251881Speter     CHANGED_DATE       0
746251881Speter     CHANGED_AUTHOR     NULL
747251881Speter     DEPTH              svn_depth_unknown
748251881Speter     CHECKSUM           NULL
749251881Speter     TARGET             NULL
750251881Speter     LOCK               NULL
751251881Speter
752251881Speter     HAD_PROPS          FALSE
753251881Speter     PROPS              NULL
754251881Speter
755251881Speter     UPDATE_ROOT        FALSE
756251881Speter
757251881Speter   If the STATUS is normal, the REPOS_* values will be non-NULL.
758251881Speter
759251881Speter   If DEPTH is requested, and the node is NOT a directory, then the
760251881Speter   value will be set to svn_depth_unknown. If LOCAL_ABSPATH is a link,
761251881Speter   it's up to the caller to resolve depth for the link's target.
762251881Speter
763251881Speter   If CHECKSUM is requested, and the node is NOT a file, then it will
764251881Speter   be set to NULL.
765251881Speter
766251881Speter   If TARGET is requested, and the node is NOT a symlink, then it will
767251881Speter   be set to NULL.
768251881Speter
769251881Speter   *PROPS maps "const char *" names to "const svn_string_t *" values.  If
770251881Speter   the base node is capable of having properties but has none, set
771251881Speter   *PROPS to an empty hash.  If its status is such that it cannot have
772251881Speter   properties, set *PROPS to NULL.
773251881Speter
774251881Speter   If UPDATE_ROOT is requested, set it to TRUE if the node should only
775251881Speter   be updated when it is the root of an update (e.g. file externals).
776251881Speter
777251881Speter   All returned data will be allocated in RESULT_POOL. All temporary
778251881Speter   allocations will be made in SCRATCH_POOL.
779251881Speter*/
780251881Spetersvn_error_t *
781251881Spetersvn_wc__db_base_get_info(svn_wc__db_status_t *status,
782251881Speter                         svn_node_kind_t *kind,
783251881Speter                         svn_revnum_t *revision,
784251881Speter                         const char **repos_relpath,
785251881Speter                         const char **repos_root_url,
786251881Speter                         const char **repos_uuid,
787251881Speter                         svn_revnum_t *changed_rev,
788251881Speter                         apr_time_t *changed_date,
789251881Speter                         const char **changed_author,
790251881Speter                         svn_depth_t *depth,
791251881Speter                         const svn_checksum_t **checksum,
792251881Speter                         const char **target,
793251881Speter                         svn_wc__db_lock_t **lock,
794251881Speter                         svn_boolean_t *had_props,
795251881Speter                         apr_hash_t **props,
796251881Speter                         svn_boolean_t *update_root,
797251881Speter                         svn_wc__db_t *db,
798251881Speter                         const char *local_abspath,
799251881Speter                         apr_pool_t *result_pool,
800251881Speter                         apr_pool_t *scratch_pool);
801251881Speter
802251881Speter/* Structure returned by svn_wc__db_base_get_children_info.  Only has the
803251881Speter   fields needed by the adm crawler. */
804251881Speterstruct svn_wc__db_base_info_t {
805251881Speter  svn_wc__db_status_t status;
806251881Speter  svn_node_kind_t kind;
807251881Speter  svn_revnum_t revnum;
808251881Speter  const char *repos_relpath;
809251881Speter  const char *repos_root_url;
810251881Speter  svn_depth_t depth;
811251881Speter  svn_boolean_t update_root;
812251881Speter  svn_wc__db_lock_t *lock;
813251881Speter};
814251881Speter
815251881Speter/* Return in *NODES a hash mapping name->struct svn_wc__db_base_info_t for
816251881Speter   the children of DIR_ABSPATH at op_depth 0.
817251881Speter */
818251881Spetersvn_error_t *
819251881Spetersvn_wc__db_base_get_children_info(apr_hash_t **nodes,
820251881Speter                                  svn_wc__db_t *db,
821251881Speter                                  const char *dir_abspath,
822251881Speter                                  apr_pool_t *result_pool,
823251881Speter                                  apr_pool_t *scratch_pool);
824251881Speter
825251881Speter
826251881Speter/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the BASE tree.
827251881Speter
828251881Speter   *PROPS maps "const char *" names to "const svn_string_t *" values.
829251881Speter   If the node has no properties, set *PROPS to an empty hash.
830251881Speter   *PROPS will never be set to NULL.
831251881Speter   If the node is not present in the BASE tree (with presence 'normal'
832251881Speter   or 'incomplete'), return an error.
833251881Speter   Allocate *PROPS and its keys and values in RESULT_POOL.
834251881Speter*/
835251881Spetersvn_error_t *
836251881Spetersvn_wc__db_base_get_props(apr_hash_t **props,
837251881Speter                          svn_wc__db_t *db,
838251881Speter                          const char *local_abspath,
839251881Speter                          apr_pool_t *result_pool,
840251881Speter                          apr_pool_t *scratch_pool);
841251881Speter
842251881Speter
843251881Speter/* Return a list of the BASE tree node's children's names.
844251881Speter
845251881Speter   For the node indicated by LOCAL_ABSPATH, this function will return
846251881Speter   the names of all of its children in the array CHILDREN. The array
847251881Speter   elements are const char * values.
848251881Speter
849251881Speter   If the node is not a directory, then SVN_ERR_WC_NOT_WORKING_COPY will
850251881Speter   be returned.
851251881Speter
852251881Speter   All returned data will be allocated in RESULT_POOL. All temporary
853251881Speter   allocations will be made in SCRATCH_POOL.
854251881Speter*/
855251881Spetersvn_error_t *
856251881Spetersvn_wc__db_base_get_children(const apr_array_header_t **children,
857251881Speter                             svn_wc__db_t *db,
858251881Speter                             const char *local_abspath,
859251881Speter                             apr_pool_t *result_pool,
860251881Speter                             apr_pool_t *scratch_pool);
861251881Speter
862251881Speter
863251881Speter/* Set the dav cache for LOCAL_ABSPATH to PROPS.  Use SCRATCH_POOL for
864251881Speter   temporary allocations. */
865251881Spetersvn_error_t *
866251881Spetersvn_wc__db_base_set_dav_cache(svn_wc__db_t *db,
867251881Speter                              const char *local_abspath,
868251881Speter                              const apr_hash_t *props,
869251881Speter                              apr_pool_t *scratch_pool);
870251881Speter
871251881Speter
872251881Speter/* Retrieve the dav cache for LOCAL_ABSPATH into *PROPS, allocated in
873251881Speter   RESULT_POOL.  Use SCRATCH_POOL for temporary allocations.  Return
874251881Speter   SVN_ERR_WC_PATH_NOT_FOUND if no dav cache can be located for
875251881Speter   LOCAL_ABSPATH in DB.  */
876251881Spetersvn_error_t *
877251881Spetersvn_wc__db_base_get_dav_cache(apr_hash_t **props,
878251881Speter                              svn_wc__db_t *db,
879251881Speter                              const char *local_abspath,
880251881Speter                              apr_pool_t *result_pool,
881251881Speter                              apr_pool_t *scratch_pool);
882251881Speter
883251881Speter/* Recursively clear the dav cache for LOCAL_ABSPATH.  Use
884251881Speter   SCRATCH_POOL for temporary allocations. */
885251881Spetersvn_error_t *
886251881Spetersvn_wc__db_base_clear_dav_cache_recursive(svn_wc__db_t *db,
887251881Speter                                          const char *local_abspath,
888251881Speter                                          apr_pool_t *scratch_pool);
889251881Speter
890251881Speter/* Set LOCK_TOKENS to a hash mapping const char * full URLs to const char *
891251881Speter * lock tokens for every base node at or under LOCAL_ABSPATH in DB which has
892251881Speter * such a lock token set on it.
893251881Speter * Allocate the hash and all items therein from RESULT_POOL.  */
894251881Spetersvn_error_t *
895251881Spetersvn_wc__db_base_get_lock_tokens_recursive(apr_hash_t **lock_tokens,
896251881Speter                                          svn_wc__db_t *db,
897251881Speter                                          const char *local_abspath,
898251881Speter                                          apr_pool_t *result_pool,
899251881Speter                                          apr_pool_t *scratch_pool);
900251881Speter
901251881Speter/* ### anything else needed for maintaining the BASE tree? */
902251881Speter
903251881Speter
904251881Speter/* @} */
905251881Speter
906251881Speter/* @defgroup svn_wc__db_pristine  Pristine ("text base") management
907251881Speter   @{
908251881Speter*/
909251881Speter
910251881Speter/* Set *PRISTINE_ABSPATH to the path to the pristine text file
911251881Speter   identified by SHA1_CHECKSUM.  Error if it does not exist.
912251881Speter
913251881Speter   ### This is temporary - callers should not be looking at the file
914251881Speter   directly.
915251881Speter
916251881Speter   Allocate the path in RESULT_POOL. */
917251881Spetersvn_error_t *
918251881Spetersvn_wc__db_pristine_get_path(const char **pristine_abspath,
919251881Speter                             svn_wc__db_t *db,
920251881Speter                             const char *wri_abspath,
921251881Speter                             const svn_checksum_t *checksum,
922251881Speter                             apr_pool_t *result_pool,
923251881Speter                             apr_pool_t *scratch_pool);
924251881Speter
925251881Speter/* Set *PRISTINE_ABSPATH to the path under WCROOT_ABSPATH that will be
926251881Speter   used by the pristine text identified by SHA1_CHECKSUM.  The file
927251881Speter   need not exist.
928251881Speter */
929251881Spetersvn_error_t *
930251881Spetersvn_wc__db_pristine_get_future_path(const char **pristine_abspath,
931251881Speter                                    const char *wcroot_abspath,
932251881Speter                                    const svn_checksum_t *sha1_checksum,
933251881Speter                                    apr_pool_t *result_pool,
934251881Speter                                    apr_pool_t *scratch_pool);
935251881Speter
936251881Speter
937251881Speter/* If requested set *CONTENTS to a readable stream that will yield the pristine
938251881Speter   text identified by SHA1_CHECKSUM (must be a SHA-1 checksum) within the WC
939251881Speter   identified by WRI_ABSPATH in DB.
940251881Speter
941251881Speter   If requested set *SIZE to the size of the pristine stream in bytes,
942251881Speter
943251881Speter   Even if the pristine text is removed from the store while it is being
944251881Speter   read, the stream will remain valid and readable until it is closed.
945251881Speter
946251881Speter   Allocate the stream in RESULT_POOL. */
947251881Spetersvn_error_t *
948251881Spetersvn_wc__db_pristine_read(svn_stream_t **contents,
949251881Speter                         svn_filesize_t *size,
950251881Speter                         svn_wc__db_t *db,
951251881Speter                         const char *wri_abspath,
952251881Speter                         const svn_checksum_t *sha1_checksum,
953251881Speter                         apr_pool_t *result_pool,
954251881Speter                         apr_pool_t *scratch_pool);
955251881Speter
956251881Speter
957251881Speter/* Set *TEMP_DIR_ABSPATH to a directory in which the caller should create
958251881Speter   a uniquely named file for later installation as a pristine text file.
959251881Speter
960251881Speter   The directory is guaranteed to be one that svn_wc__db_pristine_install()
961251881Speter   can use: specifically, one from which it can atomically move the file.
962251881Speter
963251881Speter   Allocate *TEMP_DIR_ABSPATH in RESULT_POOL. */
964251881Spetersvn_error_t *
965251881Spetersvn_wc__db_pristine_get_tempdir(const char **temp_dir_abspath,
966251881Speter                                svn_wc__db_t *db,
967251881Speter                                const char *wri_abspath,
968251881Speter                                apr_pool_t *result_pool,
969251881Speter                                apr_pool_t *scratch_pool);
970251881Speter
971251881Speter
972251881Speter/* Install the file TEMPFILE_ABSPATH (which is sitting in a directory given by
973251881Speter   svn_wc__db_pristine_get_tempdir()) into the pristine data store, to be
974251881Speter   identified by the SHA-1 checksum of its contents, SHA1_CHECKSUM, and whose
975251881Speter   MD-5 checksum is MD5_CHECKSUM. */
976251881Spetersvn_error_t *
977251881Spetersvn_wc__db_pristine_install(svn_wc__db_t *db,
978251881Speter                            const char *tempfile_abspath,
979251881Speter                            const svn_checksum_t *sha1_checksum,
980251881Speter                            const svn_checksum_t *md5_checksum,
981251881Speter                            apr_pool_t *scratch_pool);
982251881Speter
983251881Speter
984251881Speter/* Set *MD5_CHECKSUM to the MD-5 checksum of a pristine text
985251881Speter   identified by its SHA-1 checksum SHA1_CHECKSUM. Return an error
986251881Speter   if the pristine text does not exist or its MD5 checksum is not found.
987251881Speter
988251881Speter   Allocate *MD5_CHECKSUM in RESULT_POOL. */
989251881Spetersvn_error_t *
990251881Spetersvn_wc__db_pristine_get_md5(const svn_checksum_t **md5_checksum,
991251881Speter                            svn_wc__db_t *db,
992251881Speter                            const char *wri_abspath,
993251881Speter                            const svn_checksum_t *sha1_checksum,
994251881Speter                            apr_pool_t *result_pool,
995251881Speter                            apr_pool_t *scratch_pool);
996251881Speter
997251881Speter
998251881Speter/* Set *SHA1_CHECKSUM to the SHA-1 checksum of a pristine text
999251881Speter   identified by its MD-5 checksum MD5_CHECKSUM. Return an error
1000251881Speter   if the pristine text does not exist or its SHA-1 checksum is not found.
1001251881Speter
1002251881Speter   Note: The MD-5 checksum is not strictly guaranteed to be unique in the
1003251881Speter   database table, although duplicates are expected to be extremely rare.
1004251881Speter   ### TODO: The behaviour is currently unspecified if the MD-5 checksum is
1005251881Speter   not unique. Need to see whether this function is going to stay in use,
1006251881Speter   and, if so, address this somehow.
1007251881Speter
1008251881Speter   Allocate *SHA1_CHECKSUM in RESULT_POOL. */
1009251881Spetersvn_error_t *
1010251881Spetersvn_wc__db_pristine_get_sha1(const svn_checksum_t **sha1_checksum,
1011251881Speter                             svn_wc__db_t *db,
1012251881Speter                             const char *wri_abspath,
1013251881Speter                             const svn_checksum_t *md5_checksum,
1014251881Speter                             apr_pool_t *result_pool,
1015251881Speter                             apr_pool_t *scratch_pool);
1016251881Speter
1017251881Speter
1018251881Speter/* If necessary transfers the PRISTINE files of the tree rooted at
1019251881Speter   SRC_LOCAL_ABSPATH to the working copy identified by DST_WRI_ABSPATH. */
1020251881Spetersvn_error_t *
1021251881Spetersvn_wc__db_pristine_transfer(svn_wc__db_t *db,
1022251881Speter                             const char *src_local_abspath,
1023251881Speter                             const char *dst_wri_abspath,
1024251881Speter                             svn_cancel_func_t cancel_func,
1025251881Speter                             void *cancel_baton,
1026251881Speter                             apr_pool_t *scratch_pool);
1027251881Speter
1028251881Speter/* Remove the pristine text with SHA-1 checksum SHA1_CHECKSUM from the
1029251881Speter * pristine store, iff it is not referenced by any of the (other) WC DB
1030251881Speter * tables. */
1031251881Spetersvn_error_t *
1032251881Spetersvn_wc__db_pristine_remove(svn_wc__db_t *db,
1033251881Speter                           const char *wri_abspath,
1034251881Speter                           const svn_checksum_t *sha1_checksum,
1035251881Speter                           apr_pool_t *scratch_pool);
1036251881Speter
1037251881Speter
1038251881Speter/* Remove all unreferenced pristines in the WC of WRI_ABSPATH in DB. */
1039251881Spetersvn_error_t *
1040251881Spetersvn_wc__db_pristine_cleanup(svn_wc__db_t *db,
1041251881Speter                            const char *wri_abspath,
1042251881Speter                            apr_pool_t *scratch_pool);
1043251881Speter
1044251881Speter
1045251881Speter/* Set *PRESENT to true if the pristine store for WRI_ABSPATH in DB contains
1046251881Speter   a pristine text with SHA-1 checksum SHA1_CHECKSUM, and to false otherwise.
1047251881Speter*/
1048251881Spetersvn_error_t *
1049251881Spetersvn_wc__db_pristine_check(svn_boolean_t *present,
1050251881Speter                          svn_wc__db_t *db,
1051251881Speter                          const char *wri_abspath,
1052251881Speter                          const svn_checksum_t *sha1_checksum,
1053251881Speter                          apr_pool_t *scratch_pool);
1054251881Speter
1055251881Speter/* @defgroup svn_wc__db_external  External management
1056251881Speter   @{ */
1057251881Speter
1058251881Speter/* Adds (or overwrites) a file external LOCAL_ABSPATH to the working copy
1059251881Speter   identified by WRI_ABSPATH.
1060251881Speter
1061251881Speter   It updates both EXTERNALS and NODES in one atomic step.
1062251881Speter */
1063251881Spetersvn_error_t *
1064251881Spetersvn_wc__db_external_add_file(svn_wc__db_t *db,
1065251881Speter                             const char *local_abspath,
1066251881Speter                             const char *wri_abspath,
1067251881Speter
1068251881Speter                             const char *repos_relpath,
1069251881Speter                             const char *repos_root_url,
1070251881Speter                             const char *repos_uuid,
1071251881Speter                             svn_revnum_t revision,
1072251881Speter
1073251881Speter                             const apr_hash_t *props,
1074251881Speter                             apr_array_header_t *iprops,
1075251881Speter
1076251881Speter                             svn_revnum_t changed_rev,
1077251881Speter                             apr_time_t changed_date,
1078251881Speter                             const char *changed_author,
1079251881Speter
1080251881Speter                             const svn_checksum_t *checksum,
1081251881Speter
1082251881Speter                             const apr_hash_t *dav_cache,
1083251881Speter
1084251881Speter                             const char *record_ancestor_abspath,
1085251881Speter                             const char *recorded_repos_relpath,
1086251881Speter                             svn_revnum_t recorded_peg_revision,
1087251881Speter                             svn_revnum_t recorded_revision,
1088251881Speter
1089251881Speter                             svn_boolean_t update_actual_props,
1090251881Speter                             apr_hash_t *new_actual_props,
1091251881Speter
1092251881Speter                             svn_boolean_t keep_recorded_info,
1093251881Speter                             const svn_skel_t *conflict,
1094251881Speter                             const svn_skel_t *work_items,
1095251881Speter                             apr_pool_t *scratch_pool);
1096251881Speter
1097251881Speter/* Adds (or overwrites) a symlink external LOCAL_ABSPATH to the working copy
1098251881Speter   identified by WRI_ABSPATH.
1099251881Speter */
1100251881Spetersvn_error_t *
1101251881Spetersvn_wc__db_external_add_symlink(svn_wc__db_t *db,
1102251881Speter                                const char *local_abspath,
1103251881Speter                                const char *wri_abspath,
1104251881Speter
1105251881Speter                                const char *repos_relpath,
1106251881Speter                                const char *repos_root_url,
1107251881Speter                                const char *repos_uuid,
1108251881Speter                                svn_revnum_t revision,
1109251881Speter
1110251881Speter                                const apr_hash_t *props,
1111251881Speter
1112251881Speter                                svn_revnum_t changed_rev,
1113251881Speter                                apr_time_t changed_date,
1114251881Speter                                const char *changed_author,
1115251881Speter
1116251881Speter                                const char *target,
1117251881Speter
1118251881Speter                                const apr_hash_t *dav_cache,
1119251881Speter
1120251881Speter                                const char *record_ancestor_abspath,
1121251881Speter                                const char *recorded_repos_relpath,
1122251881Speter                                svn_revnum_t recorded_peg_revision,
1123251881Speter                                svn_revnum_t recorded_revision,
1124251881Speter
1125251881Speter                                svn_boolean_t update_actual_props,
1126251881Speter                                apr_hash_t *new_actual_props,
1127251881Speter
1128251881Speter                                svn_boolean_t keep_recorded_info,
1129251881Speter                                const svn_skel_t *work_items,
1130251881Speter                                apr_pool_t *scratch_pool);
1131251881Speter
1132251881Speter/* Adds (or overwrites) a directory external LOCAL_ABSPATH to the working copy
1133251881Speter   identified by WRI_ABSPATH.
1134251881Speter
1135251881Speter  Directory externals are stored in their own working copy, so one should use
1136251881Speter  the normal svn_wc__db functions to access the normal working copy
1137251881Speter  information.
1138251881Speter */
1139251881Spetersvn_error_t *
1140251881Spetersvn_wc__db_external_add_dir(svn_wc__db_t *db,
1141251881Speter                            const char *local_abspath,
1142251881Speter                            const char *wri_abspath,
1143251881Speter
1144251881Speter                            const char *repos_root_url,
1145251881Speter                            const char *repos_uuid,
1146251881Speter
1147251881Speter                            const char *record_ancestor_abspath,
1148251881Speter                            const char *recorded_repos_relpath,
1149251881Speter                            svn_revnum_t recorded_peg_revision,
1150251881Speter                            svn_revnum_t recorded_revision,
1151251881Speter
1152251881Speter                            const svn_skel_t *work_items,
1153251881Speter                            apr_pool_t *scratch_pool);
1154251881Speter
1155251881Speter/* Remove a registered external LOCAL_ABSPATH from the working copy identified
1156251881Speter   by WRI_ABSPATH.
1157251881Speter */
1158251881Spetersvn_error_t *
1159251881Spetersvn_wc__db_external_remove(svn_wc__db_t *db,
1160251881Speter                           const char *local_abspath,
1161251881Speter                           const char *wri_abspath,
1162251881Speter
1163251881Speter                           const svn_skel_t *work_items,
1164251881Speter                           apr_pool_t *scratch_pool);
1165251881Speter
1166251881Speter
1167251881Speter/* Reads information on the external LOCAL_ABSPATH as stored in the working
1168251881Speter   copy identified with WRI_ABSPATH (If NULL the parent directory of
1169251881Speter   LOCAL_ABSPATH is taken as WRI_ABSPATH).
1170251881Speter
1171251881Speter   Return SVN_ERR_WC_PATH_NOT_FOUND if LOCAL_ABSPATH is not an external in
1172251881Speter   this working copy.
1173251881Speter
1174251881Speter   When STATUS is requested it has one of these values
1175251881Speter      svn_wc__db_status_normal           The external is available
1176251881Speter      svn_wc__db_status_excluded         The external is user excluded
1177251881Speter
1178251881Speter   When KIND is requested then the value will be set to the kind of external.
1179251881Speter
1180251881Speter   If DEFINING_ABSPATH is requested, then the value will be set to the
1181251881Speter   absolute path of the directory which originally defined the external.
1182251881Speter   (The path with the svn:externals property)
1183251881Speter
1184251881Speter   If REPOS_ROOT_URL is requested, then the value will be set to the
1185251881Speter   repository root of the external.
1186251881Speter
1187251881Speter   If REPOS_UUID is requested, then the value will be set to the
1188251881Speter   repository uuid of the external.
1189251881Speter
1190251881Speter   If RECORDED_REPOS_RELPATH is requested, then the value will be set to the
1191251881Speter   original repository relative path inside REPOS_ROOT_URL of the external.
1192251881Speter
1193251881Speter   If RECORDED_PEG_REVISION is requested, then the value will be set to the
1194251881Speter   original recorded operational (peg) revision of the external.
1195251881Speter
1196251881Speter   If RECORDED_REVISION is requested, then the value will be set to the
1197251881Speter   original recorded revision of the external.
1198251881Speter
1199251881Speter   Allocate the result in RESULT_POOL and perform temporary allocations in
1200251881Speter   SCRATCH_POOL.
1201251881Speter */
1202251881Spetersvn_error_t *
1203251881Spetersvn_wc__db_external_read(svn_wc__db_status_t *status,
1204251881Speter                         svn_node_kind_t *kind,
1205251881Speter                         const char **defining_abspath,
1206251881Speter
1207251881Speter                         const char **repos_root_url,
1208251881Speter                         const char **repos_uuid,
1209251881Speter
1210251881Speter                         const char **recorded_repos_relpath,
1211251881Speter                         svn_revnum_t *recorded_peg_revision,
1212251881Speter                         svn_revnum_t *recorded_revision,
1213251881Speter
1214251881Speter                         svn_wc__db_t *db,
1215251881Speter                         const char *local_abspath,
1216251881Speter                         const char *wri_abspath,
1217251881Speter                         apr_pool_t *result_pool,
1218251881Speter                         apr_pool_t *scratch_pool);
1219251881Speter
1220251881Speter/* Return in *EXTERNALS a list of svn_wc__committable_external_info_t *
1221251881Speter * containing info on externals defined to be checked out below LOCAL_ABSPATH,
1222251881Speter * returning only those externals that are not fixed to a specific revision.
1223251881Speter *
1224251881Speter * If IMMEDIATES_ONLY is TRUE, only those externals defined to be checked out
1225251881Speter * as immediate children of LOCAL_ABSPATH are returned (this is useful for
1226251881Speter * treating user requested depth < infinity).
1227251881Speter *
1228251881Speter * If there are no externals to be returned, set *EXTERNALS to NULL. Otherwise
1229251881Speter * set *EXTERNALS to an APR array newly cleated in RESULT_POOL.
1230251881Speter *
1231251881Speter * NOTE: This only returns the externals known by the immediate WC root for
1232251881Speter * LOCAL_ABSPATH; i.e.:
1233251881Speter * - If there is a further parent WC "above" the immediate WC root, and if
1234251881Speter *   that parent WC defines externals to live somewhere within this WC, these
1235251881Speter *   externals will appear to be foreign/unversioned and won't be picked up.
1236251881Speter * - Likewise, only the topmost level of externals nestings (externals
1237251881Speter *   defined within a checked out external dir) is picked up by this function.
1238251881Speter *   (For recursion, see svn_wc__committable_externals_below().)
1239251881Speter *
1240251881Speter * ###TODO: Add a WRI_ABSPATH (wc root indicator) separate from LOCAL_ABSPATH,
1241251881Speter * to allow searching any wc-root for externals under LOCAL_ABSPATH, not only
1242251881Speter * LOCAL_ABSPATH's most immediate wc-root. */
1243251881Spetersvn_error_t *
1244251881Spetersvn_wc__db_committable_externals_below(apr_array_header_t **externals,
1245251881Speter                                       svn_wc__db_t *db,
1246251881Speter                                       const char *local_abspath,
1247251881Speter                                       svn_boolean_t immediates_only,
1248251881Speter                                       apr_pool_t *result_pool,
1249251881Speter                                       apr_pool_t *scratch_pool);
1250251881Speter
1251251881Speter/* Gets a mapping from const char * local abspaths of externals to the const
1252251881Speter   char * local abspath of where they are defined for all externals defined
1253251881Speter   at or below LOCAL_ABSPATH.
1254251881Speter
1255251881Speter   ### Returns NULL in *EXTERNALS until we bumped to format 29.
1256251881Speter
1257251881Speter   Allocate the result in RESULT_POOL and perform temporary allocations in
1258251881Speter   SCRATCH_POOL. */
1259251881Spetersvn_error_t *
1260251881Spetersvn_wc__db_externals_defined_below(apr_hash_t **externals,
1261251881Speter                                   svn_wc__db_t *db,
1262251881Speter                                   const char *local_abspath,
1263251881Speter                                   apr_pool_t *result_pool,
1264251881Speter                                   apr_pool_t *scratch_pool);
1265251881Speter
1266251881Speter/* Gather all svn:externals property values from the actual properties on
1267251881Speter   directories below LOCAL_ABSPATH as a mapping of const char *local_abspath
1268251881Speter   to const char * property values.
1269251881Speter
1270251881Speter   If DEPTHS is not NULL, set *depths to an apr_hash_t* mapping the same
1271251881Speter   local_abspaths to the const char * ambient depth of the node.
1272251881Speter
1273251881Speter   Allocate the result in RESULT_POOL and perform temporary allocations in
1274251881Speter   SCRATCH_POOL. */
1275251881Spetersvn_error_t *
1276251881Spetersvn_wc__db_externals_gather_definitions(apr_hash_t **externals,
1277251881Speter                                        apr_hash_t **depths,
1278251881Speter                                        svn_wc__db_t *db,
1279251881Speter                                        const char *local_abspath,
1280251881Speter                                        apr_pool_t *result_pool,
1281251881Speter                                        apr_pool_t *scratch_pool);
1282251881Speter
1283251881Speter/* @} */
1284251881Speter
1285251881Speter/* @defgroup svn_wc__db_op  Operations on WORKING tree
1286251881Speter   @{
1287251881Speter*/
1288251881Speter
1289251881Speter/* Copy the node at SRC_ABSPATH (in NODES and ACTUAL_NODE tables) to
1290251881Speter * DST_ABSPATH, both in DB but not necessarily in the same WC.  The parent
1291251881Speter * of DST_ABSPATH must be a versioned directory.
1292251881Speter *
1293251881Speter * This copy is NOT recursive. It simply establishes this one node, plus
1294251881Speter * incomplete nodes for the children.
1295251881Speter *
1296251881Speter * If IS_MOVE is TRUE, mark this copy operation as the copy-half of
1297251881Speter * a move. The delete-half of the move needs to be created separately
1298251881Speter * with svn_wc__db_op_delete().
1299251881Speter *
1300251881Speter * Add WORK_ITEMS to the work queue. */
1301251881Spetersvn_error_t *
1302251881Spetersvn_wc__db_op_copy(svn_wc__db_t *db,
1303251881Speter                   const char *src_abspath,
1304251881Speter                   const char *dst_abspath,
1305251881Speter                   const char *dst_op_root_abspath,
1306251881Speter                   svn_boolean_t is_move,
1307251881Speter                   const svn_skel_t *work_items,
1308251881Speter                   apr_pool_t *scratch_pool);
1309251881Speter
1310251881Speter/* Checks if LOCAL_ABSPATH represents a move back to its original location,
1311251881Speter * and if it is reverts the move while keeping local changes after it has been
1312251881Speter * moved from MOVED_FROM_ABSPATH.
1313251881Speter *
1314251881Speter * If MOVED_BACK is not NULL, set *MOVED_BACK to TRUE when a move was reverted,
1315251881Speter * otherwise to FALSE.
1316251881Speter */
1317251881Spetersvn_error_t *
1318251881Spetersvn_wc__db_op_handle_move_back(svn_boolean_t *moved_back,
1319251881Speter                               svn_wc__db_t *db,
1320251881Speter                               const char *local_abspath,
1321251881Speter                               const char *moved_from_abspath,
1322251881Speter                               const svn_skel_t *work_items,
1323251881Speter                               apr_pool_t *scratch_pool);
1324251881Speter
1325251881Speter
1326251881Speter/* Copy the leaves of the op_depth layer directly shadowed by the operation
1327251881Speter * of SRC_ABSPATH (so SRC_ABSPATH must be an op_root) to dst_abspaths
1328251881Speter * parents layer.
1329251881Speter *
1330251881Speter * This operation is recursive. It copies all the descendants at the lower
1331251881Speter * layer and adds base-deleted nodes on dst_abspath layer to mark these nodes
1332251881Speter * properly deleted.
1333251881Speter *
1334251881Speter * Usually this operation is directly followed by a call to svn_wc__db_op_copy
1335251881Speter * which performs the real copy from src_abspath to dst_abspath.
1336251881Speter */
1337251881Spetersvn_error_t *
1338251881Spetersvn_wc__db_op_copy_shadowed_layer(svn_wc__db_t *db,
1339251881Speter                                  const char *src_abspath,
1340251881Speter                                  const char *dst_abspath,
1341251881Speter                                  svn_boolean_t is_move,
1342251881Speter                                  apr_pool_t *scratch_pool);
1343251881Speter
1344251881Speter
1345251881Speter/* Record a copy at LOCAL_ABSPATH from a repository directory.
1346251881Speter
1347251881Speter   This copy is NOT recursive. It simply establishes this one node.
1348251881Speter   CHILDREN must be provided, and incomplete nodes will be constructed
1349251881Speter   for them.
1350251881Speter
1351251881Speter   ### arguments docco.  */
1352251881Spetersvn_error_t *
1353251881Spetersvn_wc__db_op_copy_dir(svn_wc__db_t *db,
1354251881Speter                       const char *local_abspath,
1355251881Speter                       const apr_hash_t *props,
1356251881Speter                       svn_revnum_t changed_rev,
1357251881Speter                       apr_time_t changed_date,
1358251881Speter                       const char *changed_author,
1359251881Speter                       const char *original_repos_relpath,
1360251881Speter                       const char *original_root_url,
1361251881Speter                       const char *original_uuid,
1362251881Speter                       svn_revnum_t original_revision,
1363251881Speter                       const apr_array_header_t *children,
1364251881Speter                       svn_boolean_t is_move,
1365251881Speter                       svn_depth_t depth,
1366251881Speter                       const svn_skel_t *conflict,
1367251881Speter                       const svn_skel_t *work_items,
1368251881Speter                       apr_pool_t *scratch_pool);
1369251881Speter
1370251881Speter
1371251881Speter/* Record a copy at LOCAL_ABSPATH from a repository file.
1372251881Speter
1373251881Speter   ### arguments docco.  */
1374251881Spetersvn_error_t *
1375251881Spetersvn_wc__db_op_copy_file(svn_wc__db_t *db,
1376251881Speter                        const char *local_abspath,
1377251881Speter                        const apr_hash_t *props,
1378251881Speter                        svn_revnum_t changed_rev,
1379251881Speter                        apr_time_t changed_date,
1380251881Speter                        const char *changed_author,
1381251881Speter                        const char *original_repos_relpath,
1382251881Speter                        const char *original_root_url,
1383251881Speter                        const char *original_uuid,
1384251881Speter                        svn_revnum_t original_revision,
1385251881Speter                        const svn_checksum_t *checksum,
1386251881Speter                        svn_boolean_t update_actual_props,
1387251881Speter                        const apr_hash_t *new_actual_props,
1388251881Speter                        svn_boolean_t is_move,
1389251881Speter                        const svn_skel_t *conflict,
1390251881Speter                        const svn_skel_t *work_items,
1391251881Speter                        apr_pool_t *scratch_pool);
1392251881Speter
1393251881Speter
1394251881Spetersvn_error_t *
1395251881Spetersvn_wc__db_op_copy_symlink(svn_wc__db_t *db,
1396251881Speter                           const char *local_abspath,
1397251881Speter                           const apr_hash_t *props,
1398251881Speter                           svn_revnum_t changed_rev,
1399251881Speter                           apr_time_t changed_date,
1400251881Speter                           const char *changed_author,
1401251881Speter                           const char *original_repos_relpath,
1402251881Speter                           const char *original_root_url,
1403251881Speter                           const char *original_uuid,
1404251881Speter                           svn_revnum_t original_revision,
1405251881Speter                           const char *target,
1406251881Speter                           const svn_skel_t *conflict,
1407251881Speter                           const svn_skel_t *work_items,
1408251881Speter                           apr_pool_t *scratch_pool);
1409251881Speter
1410251881Speter
1411251881Speter/* ### do we need svn_wc__db_op_copy_server_excluded() ??  */
1412251881Speter
1413251881Speter
1414251881Speter/* ### add a new versioned directory. a list of children is NOT passed
1415251881Speter   ### since they are added in future, distinct calls to db_op_add_*.
1416251881Speter   PROPS gives the properties; empty or NULL means none. */
1417251881Speter/* ### do we need a CONFLICTS param?  */
1418251881Spetersvn_error_t *
1419251881Spetersvn_wc__db_op_add_directory(svn_wc__db_t *db,
1420251881Speter                            const char *local_abspath,
1421251881Speter                            const apr_hash_t *props,
1422251881Speter                            const svn_skel_t *work_items,
1423251881Speter                            apr_pool_t *scratch_pool);
1424251881Speter
1425251881Speter
1426251881Speter/* Add a file.
1427251881Speter   PROPS gives the properties; empty or NULL means none.
1428251881Speter   ### this file has no "pristine"
1429251881Speter   ### contents, so a checksum [reference] is not required.  */
1430251881Speter/* ### do we need a CONFLICTS param?  */
1431251881Spetersvn_error_t *
1432251881Spetersvn_wc__db_op_add_file(svn_wc__db_t *db,
1433251881Speter                       const char *local_abspath,
1434251881Speter                       const apr_hash_t *props,
1435251881Speter                       const svn_skel_t *work_items,
1436251881Speter                       apr_pool_t *scratch_pool);
1437251881Speter
1438251881Speter
1439251881Speter/* Add a symlink.
1440251881Speter   PROPS gives the properties; empty or NULL means none. */
1441251881Speter/* ### do we need a CONFLICTS param?  */
1442251881Spetersvn_error_t *
1443251881Spetersvn_wc__db_op_add_symlink(svn_wc__db_t *db,
1444251881Speter                          const char *local_abspath,
1445251881Speter                          const char *target,
1446251881Speter                          const apr_hash_t *props,
1447251881Speter                          const svn_skel_t *work_items,
1448251881Speter                          apr_pool_t *scratch_pool);
1449251881Speter
1450251881Speter
1451251881Speter/* Set the properties of the node LOCAL_ABSPATH in the ACTUAL tree to
1452251881Speter   PROPS.
1453251881Speter
1454251881Speter   PROPS maps "const char *" names to "const svn_string_t *" values.
1455251881Speter   To specify no properties, PROPS must be an empty hash, not NULL.
1456251881Speter   If the node is not present, return an error.
1457251881Speter
1458251881Speter   If PROPS is NULL, set the properties to be the same as the pristine
1459251881Speter   properties.
1460251881Speter
1461251881Speter   If CONFLICT is not NULL, it is used to register a conflict on this
1462251881Speter   node at the same time the properties are changed.
1463251881Speter
1464251881Speter   WORK_ITEMS are inserted into the work queue, as additional things that
1465251881Speter   need to be completed before the working copy is stable.
1466251881Speter
1467251881Speter
1468251881Speter   If CLEAR_RECORDED_INFO is true, the recorded information for the node
1469251881Speter   is cleared. (commonly used when updating svn:* magic properties).
1470251881Speter
1471251881Speter   NOTE: This will overwrite ALL working properties the node currently
1472251881Speter   has. There is no db_op_set_prop() function. Callers must read all the
1473251881Speter   properties, change one, and write all the properties.
1474251881Speter   ### ugh. this has poor transaction semantics...
1475251881Speter
1476251881Speter
1477251881Speter   NOTE: This will create an entry in the ACTUAL table for the node if it
1478251881Speter   does not yet have one.
1479251881Speter*/
1480251881Spetersvn_error_t *
1481251881Spetersvn_wc__db_op_set_props(svn_wc__db_t *db,
1482251881Speter                        const char *local_abspath,
1483251881Speter                        apr_hash_t *props,
1484251881Speter                        svn_boolean_t clear_recorded_info,
1485251881Speter                        const svn_skel_t *conflict,
1486251881Speter                        const svn_skel_t *work_items,
1487251881Speter                        apr_pool_t *scratch_pool);
1488251881Speter
1489251881Speter/* Mark LOCAL_ABSPATH, and all children, for deletion.
1490251881Speter *
1491251881Speter * This function removes the file externals (and if DELETE_DIR_EXTERNALS is
1492251881Speter * TRUE also the directory externals) registered below LOCAL_ABSPATH.
1493251881Speter * (DELETE_DIR_EXTERNALS should be true if also removing unversioned nodes)
1494251881Speter *
1495251881Speter * If MOVED_TO_ABSPATH is not NULL, mark the deletion of LOCAL_ABSPATH
1496251881Speter * as the delete-half of a move from LOCAL_ABSPATH to MOVED_TO_ABSPATH.
1497251881Speter *
1498251881Speter * If NOTIFY_FUNC is not NULL, then it will be called (with NOTIFY_BATON)
1499251881Speter * for each node deleted. While this processing occurs, if CANCEL_FUNC is
1500251881Speter * not NULL, then it will be called (with CANCEL_BATON) to detect cancellation
1501251881Speter * during the processing.
1502251881Speter *
1503251881Speter * Note: the notification (and cancellation) occur outside of a SQLite
1504251881Speter * transaction.
1505251881Speter */
1506251881Spetersvn_error_t *
1507251881Spetersvn_wc__db_op_delete(svn_wc__db_t *db,
1508251881Speter                     const char *local_abspath,
1509251881Speter                     const char *moved_to_abspath,
1510251881Speter                     svn_boolean_t delete_dir_externals,
1511251881Speter                     svn_skel_t *conflict,
1512251881Speter                     svn_skel_t *work_items,
1513251881Speter                     svn_cancel_func_t cancel_func,
1514251881Speter                     void *cancel_baton,
1515251881Speter                     svn_wc_notify_func2_t notify_func,
1516251881Speter                     void *notify_baton,
1517251881Speter                     apr_pool_t *scratch_pool);
1518251881Speter
1519251881Speter
1520251881Speter/* Mark all LOCAL_ABSPATH in the TARGETS array, and all of their children,
1521251881Speter * for deletion.
1522251881Speter *
1523251881Speter * This function is more efficient than svn_wc__db_op_delete() because
1524251881Speter * only one sqlite transaction is used for all targets.
1525251881Speter * It currently lacks support for moves (though this could be changed,
1526251881Speter * at which point svn_wc__db_op_delete() becomes redundant).
1527251881Speter *
1528251881Speter * This function removes the file externals (and if DELETE_DIR_EXTERNALS is
1529251881Speter * TRUE also the directory externals) registered below the targets.
1530251881Speter * (DELETE_DIR_EXTERNALS should be true if also removing unversioned nodes)
1531251881Speter *
1532251881Speter * If NOTIFY_FUNC is not NULL, then it will be called (with NOTIFY_BATON)
1533251881Speter * for each node deleted. While this processing occurs, if CANCEL_FUNC is
1534251881Speter * not NULL, then it will be called (with CANCEL_BATON) to detect cancellation
1535251881Speter * during the processing.
1536251881Speter *
1537251881Speter * Note: the notification (and cancellation) occur outside of a SQLite
1538251881Speter * transaction.
1539251881Speter */
1540251881Spetersvn_error_t *
1541251881Spetersvn_wc__db_op_delete_many(svn_wc__db_t *db,
1542251881Speter                          apr_array_header_t *targets,
1543251881Speter                          svn_boolean_t delete_dir_externals,
1544251881Speter                          const svn_skel_t *conflict,
1545251881Speter                          svn_cancel_func_t cancel_func,
1546251881Speter                          void *cancel_baton,
1547251881Speter                          svn_wc_notify_func2_t notify_func,
1548251881Speter                          void *notify_baton,
1549251881Speter                          apr_pool_t *scratch_pool);
1550251881Speter
1551251881Speter
1552251881Speter/* ### mark PATH as (possibly) modified. "svn edit" ... right API here? */
1553251881Spetersvn_error_t *
1554251881Spetersvn_wc__db_op_modified(svn_wc__db_t *db,
1555251881Speter                       const char *local_abspath,
1556251881Speter                       apr_pool_t *scratch_pool);
1557251881Speter
1558251881Speter
1559251881Speter/* ### use NULL to remove from a changelist.
1560251881Speter
1561251881Speter   ### NOTE: only depth=svn_depth_empty is supported right now.
1562251881Speter */
1563251881Spetersvn_error_t *
1564251881Spetersvn_wc__db_op_set_changelist(svn_wc__db_t *db,
1565251881Speter                             const char *local_abspath,
1566251881Speter                             const char *new_changelist,
1567251881Speter                             const apr_array_header_t *changelist_filter,
1568251881Speter                             svn_depth_t depth,
1569251881Speter                             /* ### flip to CANCEL, then NOTIFY. precedent.  */
1570251881Speter                             svn_wc_notify_func2_t notify_func,
1571251881Speter                             void *notify_baton,
1572251881Speter                             svn_cancel_func_t cancel_func,
1573251881Speter                             void *cancel_baton,
1574251881Speter                             apr_pool_t *scratch_pool);
1575251881Speter
1576251881Speter/* Record CONFLICT on LOCAL_ABSPATH, potentially replacing other conflicts
1577251881Speter   recorded on LOCAL_ABSPATH.
1578251881Speter
1579251881Speter   Users should in most cases pass CONFLICT to another WC_DB call instead of
1580251881Speter   calling svn_wc__db_op_mark_conflict() directly outside a transaction, to
1581251881Speter   allow recording atomically with the operation involved.
1582251881Speter
1583251881Speter   Any work items that are necessary as part of marking this node conflicted
1584251881Speter   can be passed in WORK_ITEMS.
1585251881Speter */
1586251881Spetersvn_error_t *
1587251881Spetersvn_wc__db_op_mark_conflict(svn_wc__db_t *db,
1588251881Speter                            const char *local_abspath,
1589251881Speter                            const svn_skel_t *conflict,
1590251881Speter                            const svn_skel_t *work_items,
1591251881Speter                            apr_pool_t *scratch_pool);
1592251881Speter
1593251881Speter
1594251881Speter/* ### caller maintains ACTUAL, and how the resolution occurred. we're just
1595251881Speter   ### recording state.
1596251881Speter   ###
1597251881Speter   ### I'm not sure that these three values are the best way to do this,
1598251881Speter   ### but they're handy for now.  */
1599251881Spetersvn_error_t *
1600251881Spetersvn_wc__db_op_mark_resolved(svn_wc__db_t *db,
1601251881Speter                            const char *local_abspath,
1602251881Speter                            svn_boolean_t resolved_text,
1603251881Speter                            svn_boolean_t resolved_props,
1604251881Speter                            svn_boolean_t resolved_tree,
1605251881Speter                            const svn_skel_t *work_items,
1606251881Speter                            apr_pool_t *scratch_pool);
1607251881Speter
1608251881Speter
1609251881Speter/* Revert all local changes which are being maintained in the database,
1610251881Speter * including conflict storage, properties and text modification status.
1611251881Speter *
1612251881Speter * Returns SVN_ERR_WC_INVALID_OPERATION_DEPTH if the revert is not
1613251881Speter * possible, e.g. copy/delete but not a root, or a copy root with
1614251881Speter * children.
1615251881Speter *
1616251881Speter * At present only depth=empty and depth=infinity are supported.
1617251881Speter *
1618251881Speter * This function populates the revert list that can be queried to
1619251881Speter * determine what was reverted.
1620251881Speter */
1621251881Spetersvn_error_t *
1622251881Spetersvn_wc__db_op_revert(svn_wc__db_t *db,
1623251881Speter                     const char *local_abspath,
1624251881Speter                     svn_depth_t depth,
1625251881Speter                     apr_pool_t *result_pool,
1626251881Speter                     apr_pool_t *scratch_pool);
1627251881Speter
1628251881Speter/* Query the revert list for LOCAL_ABSPATH and set *REVERTED if the
1629251881Speter * path was reverted.  Set *MARKER_FILES to a const char *list of
1630251881Speter * marker files if any were recorded on LOCAL_ABSPATH.
1631251881Speter *
1632251881Speter * Set *COPIED_HERE if the reverted node was copied here and is the
1633251881Speter * operation root of the copy.
1634251881Speter * Set *KIND to the node kind of the reverted node.
1635251881Speter *
1636251881Speter * Removes the row for LOCAL_ABSPATH from the revert list.
1637251881Speter */
1638251881Spetersvn_error_t *
1639251881Spetersvn_wc__db_revert_list_read(svn_boolean_t *reverted,
1640251881Speter                            const apr_array_header_t **marker_files,
1641251881Speter                            svn_boolean_t *copied_here,
1642251881Speter                            svn_node_kind_t *kind,
1643251881Speter                            svn_wc__db_t *db,
1644251881Speter                            const char *local_abspath,
1645251881Speter                            apr_pool_t *result_pool,
1646251881Speter                            apr_pool_t *scratch_pool);
1647251881Speter
1648251881Speter/* The type of elements in the array returned by
1649251881Speter * svn_wc__db_revert_list_read_copied_children(). */
1650251881Spetertypedef struct svn_wc__db_revert_list_copied_child_info_t {
1651251881Speter  const char *abspath;
1652251881Speter  svn_node_kind_t kind;
1653251881Speter} svn_wc__db_revert_list_copied_child_info_t ;
1654251881Speter
1655251881Speter/* Return in *CHILDREN a list of reverted copied nodes at or within
1656251881Speter * LOCAL_ABSPATH (which is a reverted file or a reverted directory).
1657251881Speter * Allocate *COPIED_CHILDREN and its elements in RESULT_POOL.
1658251881Speter * The elements are of type svn_wc__db_revert_list_copied_child_info_t. */
1659251881Spetersvn_error_t *
1660251881Spetersvn_wc__db_revert_list_read_copied_children(const apr_array_header_t **children,
1661251881Speter                                            svn_wc__db_t *db,
1662251881Speter                                            const char *local_abspath,
1663251881Speter                                            apr_pool_t *result_pool,
1664251881Speter                                            apr_pool_t *scratch_pool);
1665251881Speter
1666251881Speter
1667251881Speter/* Make revert notifications for all paths in the revert list that are
1668251881Speter * equal to LOCAL_ABSPATH or below LOCAL_ABSPATH.
1669251881Speter *
1670251881Speter * Removes all the corresponding rows from the revert list.
1671251881Speter *
1672251881Speter * ### Pass in cancel_func?
1673251881Speter */
1674251881Spetersvn_error_t *
1675251881Spetersvn_wc__db_revert_list_notify(svn_wc_notify_func2_t notify_func,
1676251881Speter                              void *notify_baton,
1677251881Speter                              svn_wc__db_t *db,
1678251881Speter                              const char *local_abspath,
1679251881Speter                              apr_pool_t *scratch_pool);
1680251881Speter
1681251881Speter/* Clean up after svn_wc__db_op_revert by removing the revert list.
1682251881Speter */
1683251881Spetersvn_error_t *
1684251881Spetersvn_wc__db_revert_list_done(svn_wc__db_t *db,
1685251881Speter                            const char *local_abspath,
1686251881Speter                            apr_pool_t *scratch_pool);
1687251881Speter
1688251881Speter/* ### status */
1689251881Speter
1690251881Speter
1691251881Speter/* @} */
1692251881Speter
1693251881Speter/* @defgroup svn_wc__db_read  Read operations on the BASE/WORKING tree
1694251881Speter   @{
1695251881Speter
1696251881Speter   These functions query information about nodes in ACTUAL, and returns
1697251881Speter   the requested information from the appropriate ACTUAL, WORKING, or
1698251881Speter   BASE tree.
1699251881Speter
1700251881Speter   For example, asking for the checksum of the pristine version will
1701251881Speter   return the one recorded in WORKING, or if no WORKING node exists, then
1702251881Speter   the checksum comes from BASE.
1703251881Speter*/
1704251881Speter
1705251881Speter/* Retrieve information about a node.
1706251881Speter
1707251881Speter   For the node implied by LOCAL_ABSPATH from the local filesystem, return
1708251881Speter   information in the provided OUT parameters. Each OUT parameter may be
1709251881Speter   NULL, indicating that specific item is not requested.
1710251881Speter
1711251881Speter   The information returned comes from the BASE tree, as possibly modified
1712251881Speter   by the WORKING and ACTUAL trees.
1713251881Speter
1714251881Speter   If there is no information about the node, then SVN_ERR_WC_PATH_NOT_FOUND
1715251881Speter   will be returned.
1716251881Speter
1717251881Speter   The OUT parameters, and their "not available" values are:
1718251881Speter     STATUS                  n/a (always available)
1719251881Speter     KIND                    svn_node_unknown   (For ACTUAL only nodes)
1720251881Speter     REVISION                SVN_INVALID_REVNUM
1721251881Speter     REPOS_RELPATH           NULL
1722251881Speter     REPOS_ROOT_URL          NULL
1723251881Speter     REPOS_UUID              NULL
1724251881Speter     CHANGED_REV             SVN_INVALID_REVNUM
1725251881Speter     CHANGED_DATE            0
1726251881Speter     CHANGED_AUTHOR          NULL
1727251881Speter     DEPTH                   svn_depth_unknown
1728251881Speter     CHECKSUM                NULL
1729251881Speter     TARGET                  NULL
1730251881Speter
1731251881Speter     ORIGINAL_REPOS_RELPATH  NULL
1732251881Speter     ORIGINAL_ROOT_URL       NULL
1733251881Speter     ORIGINAL_UUID           NULL
1734251881Speter     ORIGINAL_REVISION       SVN_INVALID_REVNUM
1735251881Speter
1736251881Speter     LOCK                    NULL
1737251881Speter
1738251881Speter     RECORDED_SIZE           SVN_INVALID_FILESIZE
1739251881Speter     RECORDED_TIME       0
1740251881Speter
1741251881Speter     CHANGELIST              NULL
1742251881Speter     CONFLICTED              FALSE
1743251881Speter
1744251881Speter     OP_ROOT                 FALSE
1745251881Speter     HAD_PROPS               FALSE
1746251881Speter     PROPS_MOD               FALSE
1747251881Speter
1748251881Speter     HAVE_BASE               FALSE
1749251881Speter     HAVE_MORE_WORK          FALSE
1750251881Speter     HAVE_WORK               FALSE
1751251881Speter
1752251881Speter   When STATUS is requested, then it will be one of these values:
1753251881Speter
1754251881Speter     svn_wc__db_status_normal
1755251881Speter       A plain BASE node, with no local changes.
1756251881Speter
1757251881Speter     svn_wc__db_status_added
1758251881Speter       A node has been added/copied/moved to here. See HAVE_BASE to see
1759251881Speter       if this change overwrites a BASE node. Use scan_addition() to resolve
1760251881Speter       whether this has been added, copied, or moved, and the details of the
1761251881Speter       operation (this function only looks at LOCAL_ABSPATH, but resolving
1762251881Speter       the details requires scanning one or more ancestor nodes).
1763251881Speter
1764251881Speter     svn_wc__db_status_deleted
1765251881Speter       This node has been deleted or moved away. It may be a delete/move of
1766251881Speter       a BASE node, or a child node of a subtree that was copied/moved to
1767251881Speter       an ancestor location. Call scan_deletion() to determine the full
1768251881Speter       details of the operations upon this node.
1769251881Speter
1770251881Speter     svn_wc__db_status_server_excluded
1771251881Speter       The node is versioned/known by the server, but the server has
1772251881Speter       decided not to provide further information about the node. This
1773251881Speter       is a BASE node (since changes are not allowed to this node).
1774251881Speter
1775251881Speter     svn_wc__db_status_excluded
1776251881Speter       The node has been excluded from the working copy tree. This may
1777251881Speter       be an exclusion from the BASE tree, or an exclusion in the
1778251881Speter       WORKING tree for a child node of a copied/moved parent.
1779251881Speter
1780251881Speter     svn_wc__db_status_not_present
1781251881Speter       This is a node from the BASE tree, has been marked as "not-present"
1782251881Speter       within this mixed-revision working copy. This node is at a revision
1783251881Speter       that is not in the tree, contrary to its inclusion in the parent
1784251881Speter       node's revision.
1785251881Speter
1786251881Speter     svn_wc__db_status_incomplete
1787251881Speter       The BASE is incomplete due to an interrupted operation.  An
1788251881Speter       incomplete WORKING node will be svn_wc__db_status_added.
1789251881Speter
1790251881Speter   If REVISION is requested, it will be set to the revision of the
1791251881Speter   unmodified (BASE) node, or to SVN_INVALID_REVNUM if any structural
1792251881Speter   changes have been made to that node (that is, if the node has a row in
1793251881Speter   the WORKING table).
1794251881Speter
1795251881Speter   If DEPTH is requested, and the node is NOT a directory, then
1796251881Speter   the value will be set to svn_depth_unknown.
1797251881Speter
1798251881Speter   If CHECKSUM is requested, and the node is NOT a file, then it will
1799251881Speter   be set to NULL.
1800251881Speter
1801251881Speter   If TARGET is requested, and the node is NOT a symlink, then it will
1802251881Speter   be set to NULL.
1803251881Speter
1804251881Speter   If TRANSLATED_SIZE is requested, and the node is NOT a file, then
1805251881Speter   it will be set to SVN_INVALID_FILESIZE.
1806251881Speter
1807251881Speter   If HAVE_WORK is TRUE, the returned information is from the highest WORKING
1808251881Speter   layer. In that case HAVE_MORE_WORK and HAVE_BASE provide information about
1809251881Speter   what other layers exist for this node.
1810251881Speter
1811251881Speter   If HAVE_WORK is FALSE and HAVE_BASE is TRUE then the information is from
1812251881Speter   the BASE tree.
1813251881Speter
1814251881Speter   If HAVE_WORK and HAVE_BASE are both FALSE and when retrieving CONFLICTED,
1815251881Speter   then the node doesn't exist at all.
1816251881Speter
1817251881Speter   If OP_ROOT is requested and the node has a WORKING layer, OP_ROOT will be
1818251881Speter   set to true if this node is the op_root for this layer.
1819251881Speter
1820251881Speter   If HAD_PROPS is requested and the node has pristine props, the value will
1821251881Speter   be set to TRUE.
1822251881Speter
1823251881Speter   If PROPS_MOD is requested and the node has property modification the value
1824251881Speter   will be set to TRUE.
1825251881Speter
1826251881Speter   ### add information about the need to scan upwards to get a complete
1827251881Speter   ### picture of the state of this node.
1828251881Speter
1829251881Speter   ### add some documentation about OUT parameter values based on STATUS ??
1830251881Speter
1831251881Speter   ### the TEXT_MOD may become an enumerated value at some point to
1832251881Speter   ### indicate different states of knowledge about text modifications.
1833251881Speter   ### for example, an "svn edit" command in the future might set a
1834251881Speter   ### flag indicating administratively-defined modification. and/or we
1835251881Speter   ### might have a status indicating that we saw it was modified while
1836251881Speter   ### performing a filesystem traversal.
1837251881Speter
1838251881Speter   All returned data will be allocated in RESULT_POOL. All temporary
1839251881Speter   allocations will be made in SCRATCH_POOL.
1840251881Speter*/
1841251881Speter/* ### old docco. needs to be incorporated as appropriate. there is
1842251881Speter   ### some pending, potential changes to the definition of this API,
1843251881Speter   ### so not worrying about it just yet.
1844251881Speter
1845251881Speter   ### if the node has not been committed (after adding):
1846251881Speter   ###   revision will be SVN_INVALID_REVNUM
1847251881Speter   ###   repos_* will be NULL
1848251881Speter   ###   changed_rev will be SVN_INVALID_REVNUM
1849251881Speter   ###   changed_date will be 0
1850251881Speter   ###   changed_author will be NULL
1851251881Speter   ###   status will be svn_wc__db_status_added
1852251881Speter   ###   text_mod will be TRUE
1853251881Speter   ###   prop_mod will be TRUE if any props have been set
1854251881Speter   ###   base_shadowed will be FALSE
1855251881Speter
1856251881Speter   ### if the node is not a copy, or a move destination:
1857251881Speter   ###   original_repos_path will be NULL
1858251881Speter   ###   original_root_url will be NULL
1859251881Speter   ###   original_uuid will be NULL
1860251881Speter   ###   original_revision will be SVN_INVALID_REVNUM
1861251881Speter
1862251881Speter   ### note that @a base_shadowed can be derived. if the status specifies
1863251881Speter   ### an add/copy/move *and* there is a corresponding node in BASE, then
1864251881Speter   ### the BASE has been deleted to open the way for this node.
1865251881Speter*/
1866251881Spetersvn_error_t *
1867251881Spetersvn_wc__db_read_info(svn_wc__db_status_t *status,  /* ### derived */
1868251881Speter                     svn_node_kind_t *kind,
1869251881Speter                     svn_revnum_t *revision,
1870251881Speter                     const char **repos_relpath,
1871251881Speter                     const char **repos_root_url,
1872251881Speter                     const char **repos_uuid,
1873251881Speter                     svn_revnum_t *changed_rev,
1874251881Speter                     apr_time_t *changed_date,
1875251881Speter                     const char **changed_author,
1876251881Speter                     svn_depth_t *depth,  /* dirs only */
1877251881Speter                     const svn_checksum_t **checksum, /* files only */
1878251881Speter                     const char **target, /* symlinks only */
1879251881Speter
1880251881Speter                     /* ### the following fields if copied/moved (history) */
1881251881Speter                     const char **original_repos_relpath,
1882251881Speter                     const char **original_root_url,
1883251881Speter                     const char **original_uuid,
1884251881Speter                     svn_revnum_t *original_revision,
1885251881Speter
1886251881Speter                     /* For BASE nodes */
1887251881Speter                     svn_wc__db_lock_t **lock,
1888251881Speter
1889251881Speter                     /* Recorded for files present in the working copy */
1890251881Speter                     svn_filesize_t *recorded_size,
1891251881Speter                     apr_time_t *recorded_time,
1892251881Speter
1893251881Speter                     /* From ACTUAL */
1894251881Speter                     const char **changelist,
1895251881Speter                     svn_boolean_t *conflicted,
1896251881Speter
1897251881Speter                     /* ### the followed are derived fields */
1898251881Speter                     svn_boolean_t *op_root,
1899251881Speter
1900251881Speter                     svn_boolean_t *had_props,
1901251881Speter                     svn_boolean_t *props_mod,
1902251881Speter
1903251881Speter                     svn_boolean_t *have_base,
1904251881Speter                     svn_boolean_t *have_more_work,
1905251881Speter                     svn_boolean_t *have_work,
1906251881Speter
1907251881Speter                     svn_wc__db_t *db,
1908251881Speter                     const char *local_abspath,
1909251881Speter                     apr_pool_t *result_pool,
1910251881Speter                     apr_pool_t *scratch_pool);
1911251881Speter
1912269847Speter/* Structure used as linked list in svn_wc__db_info_t to describe all nodes
1913269847Speter   in this location that were moved to another location */
1914269847Speterstruct svn_wc__db_moved_to_info_t
1915269847Speter{
1916269847Speter  const char *moved_to_abspath;
1917269847Speter  const char *shadow_op_root_abspath;
1918269847Speter
1919269847Speter  struct svn_wc__db_moved_to_info_t *next;
1920269847Speter};
1921269847Speter
1922251881Speter/* Structure returned by svn_wc__db_read_children_info.  Only has the
1923251881Speter   fields needed by status. */
1924251881Speterstruct svn_wc__db_info_t {
1925251881Speter  svn_wc__db_status_t status;
1926251881Speter  svn_node_kind_t kind;
1927251881Speter  svn_revnum_t revnum;
1928251881Speter  const char *repos_relpath;
1929251881Speter  const char *repos_root_url;
1930251881Speter  const char *repos_uuid;
1931251881Speter  svn_revnum_t changed_rev;
1932251881Speter  const char *changed_author;
1933251881Speter  apr_time_t changed_date;
1934251881Speter  svn_depth_t depth;
1935251881Speter
1936251881Speter  svn_filesize_t recorded_size;
1937251881Speter  apr_time_t recorded_time;
1938251881Speter
1939251881Speter  const char *changelist;
1940251881Speter  svn_boolean_t conflicted;
1941251881Speter#ifdef HAVE_SYMLINK
1942251881Speter  svn_boolean_t special;
1943251881Speter#endif
1944251881Speter  svn_boolean_t op_root;
1945251881Speter
1946251881Speter  svn_boolean_t has_checksum;
1947251881Speter  svn_boolean_t copied;
1948251881Speter  svn_boolean_t had_props;
1949251881Speter  svn_boolean_t props_mod;
1950251881Speter
1951251881Speter  svn_boolean_t have_base;
1952251881Speter  svn_boolean_t have_more_work;
1953251881Speter
1954251881Speter  svn_boolean_t locked;     /* WC directory lock */
1955251881Speter  svn_wc__db_lock_t *lock;  /* Repository file lock */
1956251881Speter  svn_boolean_t incomplete; /* TRUE if a working node is incomplete */
1957251881Speter
1958269847Speter  struct svn_wc__db_moved_to_info_t *moved_to; /* A linked list of locations
1959269847Speter                                                 where nodes at this path
1960269847Speter                                                 are moved to. Highest layers
1961269847Speter                                                 first */
1962251881Speter  svn_boolean_t moved_here;     /* Only on op-roots. */
1963251881Speter
1964251881Speter  svn_boolean_t file_external;
1965251881Speter};
1966251881Speter
1967251881Speter/* Return in *NODES a hash mapping name->struct svn_wc__db_info_t for
1968251881Speter   the children of DIR_ABSPATH, and in *CONFLICTS a hash of names in
1969251881Speter   conflict.
1970251881Speter
1971251881Speter   The results include any path that was a child of a deleted directory that
1972251881Speter   existed at LOCAL_ABSPATH, even if that directory is now scheduled to be
1973251881Speter   replaced by the working node at LOCAL_ABSPATH.
1974251881Speter */
1975251881Spetersvn_error_t *
1976251881Spetersvn_wc__db_read_children_info(apr_hash_t **nodes,
1977251881Speter                              apr_hash_t **conflicts,
1978251881Speter                              svn_wc__db_t *db,
1979251881Speter                              const char *dir_abspath,
1980251881Speter                              apr_pool_t *result_pool,
1981251881Speter                              apr_pool_t *scratch_pool);
1982251881Speter
1983269847Speter/* Like svn_wc__db_read_children_info, but only gets an info node for the root
1984269847Speter   element. */
1985269847Spetersvn_error_t *
1986269847Spetersvn_wc__db_read_single_info(const struct svn_wc__db_info_t **info,
1987269847Speter                            svn_wc__db_t *db,
1988269847Speter                            const char *local_abspath,
1989269847Speter                            apr_pool_t *result_pool,
1990269847Speter                            apr_pool_t *scratch_pool);
1991251881Speter
1992251881Speter/* Structure returned by svn_wc__db_read_walker_info.  Only has the
1993251881Speter   fields needed by svn_wc__internal_walk_children(). */
1994251881Speterstruct svn_wc__db_walker_info_t {
1995251881Speter  svn_wc__db_status_t status;
1996251881Speter  svn_node_kind_t kind;
1997251881Speter};
1998251881Speter
1999251881Speter/* When a node is deleted in WORKING, some of its information is no longer
2000251881Speter   available. But in some cases it might still be relevant to obtain this
2001251881Speter   information even when the information isn't stored in the BASE tree.
2002251881Speter
2003251881Speter   This function allows access to that specific information.
2004251881Speter
2005251881Speter   When a node is not deleted, this node returns the same information
2006251881Speter   as svn_wc__db_read_info().
2007251881Speter
2008251881Speter   All output arguments are optional and behave in the same way as when
2009251881Speter   calling svn_wc__db_read_info().
2010251881Speter
2011251881Speter   (All other information (like original_*) can be obtained via other apis).
2012251881Speter
2013251881Speter   *PROPS maps "const char *" names to "const svn_string_t *" values.  If
2014251881Speter   the pristine node is capable of having properties but has none, set
2015251881Speter   *PROPS to an empty hash.  If its status is such that it cannot have
2016251881Speter   properties, set *PROPS to NULL.
2017251881Speter */
2018251881Spetersvn_error_t *
2019251881Spetersvn_wc__db_read_pristine_info(svn_wc__db_status_t *status,
2020251881Speter                              svn_node_kind_t *kind,
2021251881Speter                              svn_revnum_t *changed_rev,
2022251881Speter                              apr_time_t *changed_date,
2023251881Speter                              const char **changed_author,
2024251881Speter                              svn_depth_t *depth,  /* dirs only */
2025251881Speter                              const svn_checksum_t **checksum, /* files only */
2026251881Speter                              const char **target, /* symlinks only */
2027251881Speter                              svn_boolean_t *had_props,
2028251881Speter                              apr_hash_t **props,
2029251881Speter                              svn_wc__db_t *db,
2030251881Speter                              const char *local_abspath,
2031251881Speter                              apr_pool_t *result_pool,
2032251881Speter                              apr_pool_t *scratch_pool);
2033251881Speter
2034251881Speter/* Gets the information required to install a pristine file to the working copy
2035251881Speter
2036251881Speter   Set WCROOT_ABSPATH to the working copy root, SHA1_CHECKSUM to the
2037251881Speter   checksum of the node (a valid reference into the pristine store)
2038251881Speter   and PRISTINE_PROPS to the node's pristine properties (to use for
2039251881Speter   installing the file).
2040251881Speter
2041251881Speter   If WRI_ABSPATH is not NULL, check for information in the working copy
2042251881Speter   identified by WRI_ABSPATH.
2043251881Speter   */
2044251881Spetersvn_error_t *
2045251881Spetersvn_wc__db_read_node_install_info(const char **wcroot_abspath,
2046251881Speter                                  const svn_checksum_t **sha1_checksum,
2047251881Speter                                  apr_hash_t **pristine_props,
2048251881Speter                                  apr_time_t *changed_date,
2049251881Speter                                  svn_wc__db_t *db,
2050251881Speter                                  const char *local_abspath,
2051251881Speter                                  const char *wri_abspath,
2052251881Speter                                  apr_pool_t *result_pool,
2053251881Speter                                  apr_pool_t *scratch_pool);
2054251881Speter
2055251881Speter/* Return in *NODES a hash mapping name->struct svn_wc__db_walker_info_t for
2056251881Speter   the children of DIR_ABSPATH. "name" is the child's name relative to
2057251881Speter   DIR_ABSPATH, not an absolute path. */
2058251881Spetersvn_error_t *
2059251881Spetersvn_wc__db_read_children_walker_info(apr_hash_t **nodes,
2060251881Speter                                     svn_wc__db_t *db,
2061251881Speter                                     const char *dir_abspath,
2062251881Speter                                     apr_pool_t *result_pool,
2063251881Speter                                     apr_pool_t *scratch_pool);
2064251881Speter
2065251881Speter
2066251881Speter/**
2067251881Speter * Set *URL to the corresponding url for LOCAL_ABSPATH.
2068251881Speter * If the node is added, return the url it will have in the repository.
2069251881Speter */
2070251881Spetersvn_error_t *
2071251881Spetersvn_wc__db_read_url(const char **url,
2072251881Speter                    svn_wc__db_t *db,
2073251881Speter                    const char *local_abspath,
2074251881Speter                    apr_pool_t *result_pool,
2075251881Speter                    apr_pool_t *scratch_pool);
2076251881Speter
2077251881Speter
2078251881Speter/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the ACTUAL
2079251881Speter   tree (looking through to the WORKING or BASE tree as required).
2080251881Speter
2081251881Speter   ### *PROPS will be set to NULL in the following situations:
2082251881Speter   ### ... tbd
2083251881Speter
2084251881Speter   PROPS maps "const char *" names to "const svn_string_t *" values.
2085251881Speter   If the node has no properties, set *PROPS to an empty hash.
2086251881Speter   If the node is not present, return an error.
2087251881Speter   Allocate *PROPS and its keys and values in RESULT_POOL.
2088251881Speter*/
2089251881Spetersvn_error_t *
2090251881Spetersvn_wc__db_read_props(apr_hash_t **props,
2091251881Speter                      svn_wc__db_t *db,
2092251881Speter                      const char *local_abspath,
2093251881Speter                      apr_pool_t *result_pool,
2094251881Speter                      apr_pool_t *scratch_pool);
2095251881Speter
2096251881Speter/* Call RECEIVER_FUNC, passing RECEIVER_BATON, an absolute path, and
2097251881Speter * a hash table mapping <tt>char *</tt> names onto svn_string_t *
2098251881Speter * values for any properties of child nodes of LOCAL_ABSPATH (up to DEPTH).
2099251881Speter *
2100251881Speter * If PRISTINE is FALSE, read the properties from the WORKING layer (highest
2101251881Speter * op_depth); if PRISTINE is FALSE, local modifications will be visible.
2102251881Speter */
2103251881Spetersvn_error_t *
2104251881Spetersvn_wc__db_read_props_streamily(svn_wc__db_t *db,
2105251881Speter                                const char *local_abspath,
2106251881Speter                                svn_depth_t depth,
2107251881Speter                                svn_boolean_t pristine,
2108251881Speter                                const apr_array_header_t *changelists,
2109251881Speter                                svn_wc__proplist_receiver_t receiver_func,
2110251881Speter                                void *receiver_baton,
2111251881Speter                                svn_cancel_func_t cancel_func,
2112251881Speter                                void *cancel_baton,
2113251881Speter                                apr_pool_t *scratch_pool);
2114251881Speter
2115251881Speter
2116251881Speter/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the WORKING
2117251881Speter   tree (looking through to the BASE tree as required).
2118251881Speter
2119251881Speter   ### *PROPS will set set to NULL in the following situations:
2120251881Speter   ### ... tbd.  see props.c:svn_wc__get_pristine_props()
2121251881Speter
2122251881Speter   *PROPS maps "const char *" names to "const svn_string_t *" values.
2123251881Speter   If the node has no properties, set *PROPS to an empty hash.
2124251881Speter   If the node is not present, return an error.
2125251881Speter   Allocate *PROPS and its keys and values in RESULT_POOL.
2126251881Speter*/
2127251881Spetersvn_error_t *
2128251881Spetersvn_wc__db_read_pristine_props(apr_hash_t **props,
2129251881Speter                               svn_wc__db_t *db,
2130251881Speter                               const char *local_abspath,
2131251881Speter                               apr_pool_t *result_pool,
2132251881Speter                               apr_pool_t *scratch_pool);
2133251881Speter
2134251881Speter
2135251881Speter/**
2136251881Speter * Set @a *iprops to a depth-first ordered array of
2137251881Speter * #svn_prop_inherited_item_t * structures representing the properties
2138251881Speter * inherited by @a local_abspath from the ACTUAL tree above
2139251881Speter * @a local_abspath (looking through to the WORKING or BASE tree as
2140251881Speter * required), up to and including the root of the working copy and
2141251881Speter * any cached inherited properties inherited by the root.
2142251881Speter *
2143251881Speter * The #svn_prop_inherited_item_t->path_or_url members of the
2144251881Speter * #svn_prop_inherited_item_t * structures in @a *iprops are
2145251881Speter * paths relative to the repository root URL for cached inherited
2146251881Speter * properties and absolute working copy paths otherwise.
2147251881Speter *
2148251881Speter * If ACTUAL_PROPS is not NULL, then set *ACTUAL_PROPS to the actual
2149251881Speter * properties stored on LOCAL_ABSPATH.
2150251881Speter *
2151251881Speter * Allocate @a *iprops in @a result_pool.  Use @a scratch_pool
2152251881Speter * for temporary allocations.
2153251881Speter */
2154251881Spetersvn_error_t *
2155251881Spetersvn_wc__db_read_inherited_props(apr_array_header_t **iprops,
2156251881Speter                                apr_hash_t **actual_props,
2157251881Speter                                svn_wc__db_t *db,
2158251881Speter                                const char *local_abspath,
2159251881Speter                                const char *propname,
2160251881Speter                                apr_pool_t *result_pool,
2161251881Speter                                apr_pool_t *scratch_pool);
2162251881Speter
2163251881Speter/* Read a BASE node's inherited property information.
2164251881Speter
2165251881Speter   Set *IPROPS to to a depth-first ordered array of
2166251881Speter   svn_prop_inherited_item_t * structures representing the cached
2167251881Speter   inherited properties for the BASE node at LOCAL_ABSPATH.
2168251881Speter
2169251881Speter   If no cached properties are found, then set *IPROPS to NULL.
2170251881Speter   If LOCAL_ABSPATH represents the root of the repository, then set
2171251881Speter   *IPROPS to an empty array.
2172251881Speter
2173251881Speter   Allocate *IPROPS in RESULT_POOL, use SCRATCH_POOL for temporary
2174251881Speter   allocations. */
2175251881Spetersvn_error_t *
2176251881Spetersvn_wc__db_read_cached_iprops(apr_array_header_t **iprops,
2177251881Speter                              svn_wc__db_t *db,
2178251881Speter                              const char *local_abspath,
2179251881Speter                              apr_pool_t *result_pool,
2180251881Speter                              apr_pool_t *scratch_pool);
2181251881Speter
2182251881Speter/* Find BASE nodes with cached inherited properties.
2183251881Speter
2184251881Speter   Set *IPROPS_PATHS to a hash mapping const char * absolute working copy
2185251881Speter   paths to the repos_relpath of the path for each path in the working copy
2186251881Speter   at or below LOCAL_ABSPATH, limited by DEPTH, that has cached inherited
2187251881Speter   properties for the BASE node of the path.
2188251881Speter
2189251881Speter   Allocate *IPROP_PATHS in RESULT_POOL.
2190251881Speter   Use SCRATCH_POOL for temporary allocations. */
2191251881Spetersvn_error_t *
2192251881Spetersvn_wc__db_get_children_with_cached_iprops(apr_hash_t **iprop_paths,
2193251881Speter                                           svn_depth_t depth,
2194251881Speter                                           const char *local_abspath,
2195251881Speter                                           svn_wc__db_t *db,
2196251881Speter                                           apr_pool_t *result_pool,
2197251881Speter                                           apr_pool_t *scratch_pool);
2198251881Speter
2199251881Speter/** Obtain a mapping of const char * local_abspaths to const svn_string_t*
2200251881Speter * property values in *VALUES, of all PROPNAME properties on LOCAL_ABSPATH
2201251881Speter * and its descendants.
2202251881Speter *
2203251881Speter * Allocate the result in RESULT_POOL, and perform temporary allocations in
2204251881Speter * SCRATCH_POOL.
2205251881Speter */
2206251881Spetersvn_error_t *
2207251881Spetersvn_wc__db_prop_retrieve_recursive(apr_hash_t **values,
2208251881Speter                                   svn_wc__db_t *db,
2209251881Speter                                   const char *local_abspath,
2210251881Speter                                   const char *propname,
2211251881Speter                                   apr_pool_t *result_pool,
2212251881Speter                                   apr_pool_t *scratch_pool);
2213251881Speter
2214251881Speter/* Set *CHILDREN to a new array of the (const char *) basenames of the
2215251881Speter   immediate children of the working node at LOCAL_ABSPATH in DB.
2216251881Speter
2217251881Speter   Return every path that refers to a child of the working node at
2218251881Speter   LOCAL_ABSPATH.  Do not include a path just because it was a child of a
2219251881Speter   deleted directory that existed at LOCAL_ABSPATH if that directory is now
2220251881Speter   scheduled to be replaced by the working node at LOCAL_ABSPATH.
2221251881Speter
2222251881Speter   Allocate *CHILDREN in RESULT_POOL and do temporary allocations in
2223251881Speter   SCRATCH_POOL.
2224251881Speter
2225251881Speter   ### return some basic info for each child? e.g. kind.
2226251881Speter   ### maybe the data in _read_get_info should be a structure, and this
2227251881Speter   ### can return a struct for each one.
2228251881Speter   ### however: _read_get_info can say "not interested", which isn't the
2229251881Speter   ###   case with a struct. thus, a struct requires fetching and/or
2230251881Speter   ###   computing all info.
2231251881Speter*/
2232251881Spetersvn_error_t *
2233251881Spetersvn_wc__db_read_children_of_working_node(const apr_array_header_t **children,
2234251881Speter                                         svn_wc__db_t *db,
2235251881Speter                                         const char *local_abspath,
2236251881Speter                                         apr_pool_t *result_pool,
2237251881Speter                                         apr_pool_t *scratch_pool);
2238251881Speter
2239251881Speter/* Like svn_wc__db_read_children_of_working_node(), except also include any
2240251881Speter   path that was a child of a deleted directory that existed at
2241251881Speter   LOCAL_ABSPATH, even if that directory is now scheduled to be replaced by
2242251881Speter   the working node at LOCAL_ABSPATH.
2243251881Speter*/
2244251881Spetersvn_error_t *
2245251881Spetersvn_wc__db_read_children(const apr_array_header_t **children,
2246251881Speter                         svn_wc__db_t *db,
2247251881Speter                         const char *local_abspath,
2248251881Speter                         apr_pool_t *result_pool,
2249251881Speter                         apr_pool_t *scratch_pool);
2250251881Speter
2251251881Speter/* Read into *VICTIMS the basenames of the immediate children of
2252251881Speter   LOCAL_ABSPATH in DB that are conflicted.
2253251881Speter
2254251881Speter   In case of tree conflicts a victim doesn't have to be in the
2255251881Speter   working copy.
2256251881Speter
2257251881Speter   Allocate *VICTIMS in RESULT_POOL and do temporary allocations in
2258251881Speter   SCRATCH_POOL */
2259251881Speter/* ### This function will probably be removed. */
2260251881Spetersvn_error_t *
2261251881Spetersvn_wc__db_read_conflict_victims(const apr_array_header_t **victims,
2262251881Speter                                 svn_wc__db_t *db,
2263251881Speter                                 const char *local_abspath,
2264251881Speter                                 apr_pool_t *result_pool,
2265251881Speter                                 apr_pool_t *scratch_pool);
2266251881Speter
2267251881Speter/* Read into *MARKER_FILES the absolute paths of the marker files
2268251881Speter   of conflicts stored on LOCAL_ABSPATH and its immediate children in DB.
2269251881Speter   The on-disk files may have been deleted by the user.
2270251881Speter
2271251881Speter   Allocate *MARKER_FILES in RESULT_POOL and do temporary allocations
2272251881Speter   in SCRATCH_POOL */
2273251881Spetersvn_error_t *
2274251881Spetersvn_wc__db_get_conflict_marker_files(apr_hash_t **markers,
2275251881Speter                                     svn_wc__db_t *db,
2276251881Speter                                     const char *local_abspath,
2277251881Speter                                     apr_pool_t *result_pool,
2278251881Speter                                     apr_pool_t *scratch_pool);
2279251881Speter
2280251881Speter/* Read the conflict information recorded on LOCAL_ABSPATH in *CONFLICT,
2281251881Speter   an editable conflict skel.
2282251881Speter
2283251881Speter   If the node exists, but does not have a conflict set *CONFLICT to NULL,
2284251881Speter   otherwise return a SVN_ERR_WC_PATH_NOT_FOUND error.
2285251881Speter
2286251881Speter   Allocate *CONFLICTS in RESULT_POOL and do temporary allocations in
2287251881Speter   SCRATCH_POOL */
2288251881Spetersvn_error_t *
2289251881Spetersvn_wc__db_read_conflict(svn_skel_t **conflict,
2290251881Speter                         svn_wc__db_t *db,
2291251881Speter                         const char *local_abspath,
2292251881Speter                         apr_pool_t *result_pool,
2293251881Speter                         apr_pool_t *scratch_pool);
2294251881Speter
2295251881Speter
2296251881Speter/* Return the kind of the node in DB at LOCAL_ABSPATH. The WORKING tree will
2297251881Speter   be examined first, then the BASE tree. If the node is not present in either
2298251881Speter   tree and ALLOW_MISSING is TRUE, then svn_node_unknown is returned.
2299251881Speter   If the node is missing and ALLOW_MISSING is FALSE, then it will return
2300251881Speter   SVN_ERR_WC_PATH_NOT_FOUND.
2301251881Speter
2302251881Speter   The SHOW_HIDDEN and SHOW_DELETED flags report certain states as kind none.
2303251881Speter
2304251881Speter   When nodes have certain statee they are only reported when:
2305251881Speter      svn_wc__db_status_not_present         when show_hidden && show_deleted
2306251881Speter
2307251881Speter      svn_wc__db_status_excluded            when show_hidden
2308251881Speter      svn_wc__db_status_server_excluded     when show_hidden
2309251881Speter
2310251881Speter      svn_wc__db_status_deleted             when show_deleted
2311251881Speter
2312251881Speter   In other cases these nodes are reported with *KIND as svn_node_none.
2313251881Speter   (See also svn_wc_read_kind2()'s documentation)
2314251881Speter
2315251881Speter   Uses SCRATCH_POOL for temporary allocations.  */
2316251881Spetersvn_error_t *
2317251881Spetersvn_wc__db_read_kind(svn_node_kind_t *kind,
2318251881Speter                     svn_wc__db_t *db,
2319251881Speter                     const char *local_abspath,
2320251881Speter                     svn_boolean_t allow_missing,
2321251881Speter                     svn_boolean_t show_deleted,
2322251881Speter                     svn_boolean_t show_hidden,
2323251881Speter                     apr_pool_t *scratch_pool);
2324251881Speter
2325251881Speter
2326251881Speter/* An analog to svn_wc__entry_is_hidden().  Set *HIDDEN to TRUE if
2327251881Speter   LOCAL_ABSPATH in DB "is not present, and I haven't scheduled something
2328251881Speter   over the top of it." */
2329251881Spetersvn_error_t *
2330251881Spetersvn_wc__db_node_hidden(svn_boolean_t *hidden,
2331251881Speter                       svn_wc__db_t *db,
2332251881Speter                       const char *local_abspath,
2333251881Speter                       apr_pool_t *scratch_pool);
2334251881Speter
2335251881Speter/* Checks if a node replaces a node in a different layer. Also check if it
2336251881Speter   replaces a BASE (op_depth 0) node or just a node in a higher layer (a copy).
2337251881Speter   Finally check if this is the root of the replacement, or if the replacement
2338251881Speter   is initiated by the parent node.
2339251881Speter
2340251881Speter   IS_REPLACE_ROOT (if not NULL) is set to TRUE if the node is the root of a
2341251881Speter   replacement; otherwise to FALSE.
2342251881Speter
2343251881Speter   BASE_REPLACE (if not NULL) is set to TRUE if the node directly or indirectly
2344251881Speter   replaces a node in the BASE tree; otherwise to FALSE.
2345251881Speter
2346251881Speter   IS_REPLACE (if not NULL) is set to TRUE if the node directly replaces a node
2347251881Speter   in a lower layer; otherwise to FALSE.
2348251881Speter */
2349251881Spetersvn_error_t *
2350251881Spetersvn_wc__db_node_check_replace(svn_boolean_t *is_replace_root,
2351251881Speter                              svn_boolean_t *base_replace,
2352251881Speter                              svn_boolean_t *is_replace,
2353251881Speter                              svn_wc__db_t *db,
2354251881Speter                              const char *local_abspath,
2355251881Speter                              apr_pool_t *scratch_pool);
2356251881Speter
2357251881Speter/* ### changelists. return an array, or an iterator interface? how big
2358251881Speter   ### are these things? are we okay with an in-memory array? examine other
2359251881Speter   ### changelist usage -- we may already assume the list fits in memory.
2360251881Speter*/
2361251881Speter
2362251881Speter/* The DB-private version of svn_wc__is_wcroot(), which see.
2363251881Speter */
2364251881Spetersvn_error_t *
2365251881Spetersvn_wc__db_is_wcroot(svn_boolean_t *is_wcroot,
2366251881Speter                     svn_wc__db_t *db,
2367251881Speter                     const char *local_abspath,
2368251881Speter                     apr_pool_t *scratch_pool);
2369251881Speter
2370251881Speter/* Check whether a node is a working copy root and/or switched.
2371251881Speter
2372251881Speter   If LOCAL_ABSPATH is the root of a working copy, set *IS_WC_ROOT to TRUE,
2373251881Speter   otherwise to FALSE.
2374251881Speter
2375251881Speter   If LOCAL_ABSPATH is switched against its parent in the same working copy
2376251881Speter   set *IS_SWITCHED to TRUE, otherwise to FALSE.
2377251881Speter
2378251881Speter   If KIND is not null, set *KIND to the node type of LOCAL_ABSPATH.
2379251881Speter
2380251881Speter   Any of the output arguments can be null to specify that the result is not
2381251881Speter   interesting to the caller.
2382251881Speter
2383251881Speter   Use SCRATCH_POOL for temporary allocations.
2384251881Speter */
2385251881Spetersvn_error_t *
2386251881Spetersvn_wc__db_is_switched(svn_boolean_t *is_wcroot,
2387251881Speter                       svn_boolean_t *is_switched,
2388251881Speter                       svn_node_kind_t *kind,
2389251881Speter                       svn_wc__db_t *db,
2390251881Speter                       const char *local_abspath,
2391251881Speter                       apr_pool_t *scratch_pool);
2392251881Speter
2393251881Speter
2394251881Speter/* @} */
2395251881Speter
2396251881Speter
2397251881Speter/* @defgroup svn_wc__db_global  Operations that alter multiple trees
2398251881Speter   @{
2399251881Speter*/
2400251881Speter
2401251881Speter/* Associate LOCAL_DIR_ABSPATH, and all its children with the repository at
2402251881Speter   at REPOS_ROOT_URL.  The relative path to the repos root will not change,
2403251881Speter   just the repository root.  The repos uuid will also remain the same.
2404251881Speter   This also updates any locks which may exist for the node, as well as any
2405251881Speter   copyfrom repository information.  Finally, the DAV cache (aka
2406251881Speter   "wcprops") will be reset for affected entries.
2407251881Speter
2408251881Speter   Use SCRATCH_POOL for any temporary allocations.
2409251881Speter
2410251881Speter   ### local_dir_abspath "should be" the wcroot or a switch root. all URLs
2411251881Speter   ### under this directory (depth=infinity) will be rewritten.
2412251881Speter
2413251881Speter   ### This API had a depth parameter, which was removed, should it be
2414251881Speter   ### resurrected?  What's the purpose if we claim relocate is infinitely
2415251881Speter   ### recursive?
2416251881Speter
2417251881Speter   ### Assuming the future ability to copy across repositories, should we
2418251881Speter   ### refrain from resetting the copyfrom information in this operation?
2419251881Speter*/
2420251881Spetersvn_error_t *
2421251881Spetersvn_wc__db_global_relocate(svn_wc__db_t *db,
2422251881Speter                           const char *local_dir_abspath,
2423251881Speter                           const char *repos_root_url,
2424251881Speter                           apr_pool_t *scratch_pool);
2425251881Speter
2426251881Speter
2427251881Speter/* ### docco
2428251881Speter
2429251881Speter   ### collapse the WORKING and ACTUAL tree changes down into BASE, called
2430251881Speter       for each committed node.
2431251881Speter
2432251881Speter   NEW_REVISION must be the revision number of the revision created by
2433251881Speter   the commit. It will become the BASE node's 'revnum' and 'changed_rev'
2434251881Speter   values in the BASE_NODE table.
2435251881Speter
2436251881Speter   CHANGED_REVISION is the new 'last changed' revision. If the node is
2437251881Speter   modified its value is equivalent to NEW_REVISION, but in case of a
2438251881Speter   descendant of a copy/move it can be an older revision.
2439251881Speter
2440251881Speter   CHANGED_DATE is the (server-side) date of CHANGED_REVISION. It may be 0 if
2441251881Speter   the revprop is missing on the revision.
2442251881Speter
2443251881Speter   CHANGED_AUTHOR is the (server-side) author of CHANGED_REVISION. It may be
2444251881Speter   NULL if the revprop is missing on the revision.
2445251881Speter
2446251881Speter   One or both of NEW_CHECKSUM and NEW_CHILDREN should be NULL. For new:
2447251881Speter     files: NEW_CHILDREN should be NULL
2448251881Speter     dirs: NEW_CHECKSUM should be NULL
2449251881Speter     symlinks: both should be NULL
2450251881Speter
2451251881Speter   WORK_ITEMS will be place into the work queue.
2452251881Speter*/
2453251881Spetersvn_error_t *
2454251881Spetersvn_wc__db_global_commit(svn_wc__db_t *db,
2455251881Speter                         const char *local_abspath,
2456251881Speter                         svn_revnum_t new_revision,
2457251881Speter                         svn_revnum_t changed_revision,
2458251881Speter                         apr_time_t changed_date,
2459251881Speter                         const char *changed_author,
2460251881Speter                         const svn_checksum_t *new_checksum,
2461251881Speter                         const apr_array_header_t *new_children,
2462251881Speter                         apr_hash_t *new_dav_cache,
2463251881Speter                         svn_boolean_t keep_changelist,
2464251881Speter                         svn_boolean_t no_unlock,
2465251881Speter                         const svn_skel_t *work_items,
2466251881Speter                         apr_pool_t *scratch_pool);
2467251881Speter
2468251881Speter
2469251881Speter/* ### docco
2470251881Speter
2471251881Speter   Perform an "update" operation at this node. It will create/modify a BASE
2472251881Speter   node, and possibly update the ACTUAL tree's node (e.g put the node into
2473251881Speter   a conflicted state).
2474251881Speter
2475251881Speter   ### there may be cases where we need to tweak an existing WORKING node
2476251881Speter
2477251881Speter   ### this operations on a single node, but may affect children
2478251881Speter
2479251881Speter   ### the repository cannot be changed with this function, but a "switch"
2480251881Speter   ### (aka changing repos_relpath) is possible
2481251881Speter
2482251881Speter   ### one of NEW_CHILDREN, NEW_CHECKSUM, or NEW_TARGET must be provided.
2483251881Speter   ### the other two values must be NULL.
2484251881Speter   ### should this be broken out into an update_(directory|file|symlink) ?
2485251881Speter
2486251881Speter   ### how does this differ from base_add_*? just the CONFLICT param.
2487251881Speter   ### the WORK_ITEMS param is new here, but the base_add_* functions
2488251881Speter   ### should probably grow that. should we instead just (re)use base_add
2489251881Speter   ### rather than grow a new function?
2490251881Speter
2491251881Speter   ### this does not allow a change of depth
2492251881Speter
2493251881Speter   ### we do not update a file's TRANSLATED_SIZE here. at some future point,
2494251881Speter   ### when the file is installed, then a TRANSLATED_SIZE will be set.
2495251881Speter*/
2496251881Spetersvn_error_t *
2497251881Spetersvn_wc__db_global_update(svn_wc__db_t *db,
2498251881Speter                         const char *local_abspath,
2499251881Speter                         svn_node_kind_t new_kind,
2500251881Speter                         const char *new_repos_relpath,
2501251881Speter                         svn_revnum_t new_revision,
2502251881Speter                         const apr_hash_t *new_props,
2503251881Speter                         svn_revnum_t new_changed_rev,
2504251881Speter                         apr_time_t new_changed_date,
2505251881Speter                         const char *new_changed_author,
2506251881Speter                         const apr_array_header_t *new_children,
2507251881Speter                         const svn_checksum_t *new_checksum,
2508251881Speter                         const char *new_target,
2509251881Speter                         const apr_hash_t *new_dav_cache,
2510251881Speter                         const svn_skel_t *conflict,
2511251881Speter                         const svn_skel_t *work_items,
2512251881Speter                         apr_pool_t *scratch_pool);
2513251881Speter
2514251881Speter
2515251881Speter/* Modify the entry of working copy LOCAL_ABSPATH, presumably after an update
2516251881Speter   of depth DEPTH completes.  If LOCAL_ABSPATH doesn't exist, this routine
2517251881Speter   does nothing.
2518251881Speter
2519251881Speter   Set the node's repository relpath, repository root, repository uuid and
2520251881Speter   revision to NEW_REPOS_RELPATH, NEW_REPOS_ROOT and NEW_REPOS_UUID.  If
2521251881Speter   NEW_REPOS_RELPATH is null, the repository location is untouched; if
2522251881Speter   NEW_REVISION in invalid, the working revision field is untouched.
2523251881Speter   The modifications are mutually exclusive.  If NEW_REPOS_ROOT is non-NULL,
2524251881Speter   set the repository root of the entry to NEW_REPOS_ROOT.
2525251881Speter
2526251881Speter   If LOCAL_ABSPATH is a directory, then, walk entries below LOCAL_ABSPATH
2527251881Speter   according to DEPTH thusly:
2528251881Speter
2529251881Speter   If DEPTH is svn_depth_infinity, perform the following actions on
2530251881Speter   every entry below PATH; if svn_depth_immediates, svn_depth_files,
2531251881Speter   or svn_depth_empty, perform them only on LOCAL_ABSPATH.
2532251881Speter
2533251881Speter   If NEW_REVISION is valid, then tweak every entry to have this new
2534251881Speter   working revision (excluding files that are scheduled for addition
2535251881Speter   or replacement).  Likewise, if BASE_URL is non-null, then rewrite
2536251881Speter   all urls to be "telescoping" children of the base_url.
2537251881Speter
2538251881Speter   EXCLUDE_RELPATHS is a hash containing const char *local_relpath.  Nodes
2539251881Speter   for pathnames contained in EXCLUDE_RELPATHS are not touched by this
2540251881Speter   function.  These pathnames should be paths relative to the wcroot.
2541251881Speter
2542251881Speter   If WCROOT_IPROPS is not NULL it is a hash mapping const char * absolute
2543251881Speter   working copy paths to depth-first ordered arrays of
2544251881Speter   svn_prop_inherited_item_t * structures.  If LOCAL_ABSPATH exists in
2545251881Speter   WCROOT_IPROPS, then set the hashed value as the node's inherited
2546251881Speter   properties.
2547251881Speter*/
2548251881Spetersvn_error_t *
2549251881Spetersvn_wc__db_op_bump_revisions_post_update(svn_wc__db_t *db,
2550251881Speter                                         const char *local_abspath,
2551251881Speter                                         svn_depth_t depth,
2552251881Speter                                         const char *new_repos_relpath,
2553251881Speter                                         const char *new_repos_root_url,
2554251881Speter                                         const char *new_repos_uuid,
2555251881Speter                                         svn_revnum_t new_revision,
2556251881Speter                                         apr_hash_t *exclude_relpaths,
2557251881Speter                                         apr_hash_t *wcroot_iprops,
2558251881Speter                                         svn_wc_notify_func2_t notify_func,
2559251881Speter                                         void *notify_baton,
2560251881Speter                                         apr_pool_t *scratch_pool);
2561251881Speter
2562251881Speter
2563251881Speter/* Record the RECORDED_SIZE and RECORDED_TIME for a versioned node.
2564251881Speter
2565251881Speter   This function will record the information within the WORKING node,
2566251881Speter   if present, or within the BASE tree. If neither node is present, then
2567251881Speter   SVN_ERR_WC_PATH_NOT_FOUND will be returned.
2568251881Speter
2569251881Speter   RECORDED_SIZE may be SVN_INVALID_FILESIZE, which will be recorded
2570251881Speter   as such, implying "unknown size".
2571251881Speter
2572251881Speter   RECORDED_TIME may be 0, which will be recorded as such, implying
2573251881Speter   "unknown last mod time".
2574251881Speter*/
2575251881Spetersvn_error_t *
2576251881Spetersvn_wc__db_global_record_fileinfo(svn_wc__db_t *db,
2577251881Speter                                  const char *local_abspath,
2578251881Speter                                  svn_filesize_t recorded_size,
2579251881Speter                                  apr_time_t recorded_time,
2580251881Speter                                  apr_pool_t *scratch_pool);
2581251881Speter
2582251881Speter
2583251881Speter/* ### post-commit handling.
2584251881Speter   ### maybe multiple phases?
2585251881Speter   ### 1) mark a changelist as being-committed
2586251881Speter   ### 2) collect ACTUAL content, store for future use as TEXTBASE
2587251881Speter   ### 3) caller performs commit
2588251881Speter   ### 4) post-commit, integrate changelist into BASE
2589251881Speter*/
2590251881Speter
2591251881Speter
2592251881Speter/* @} */
2593251881Speter
2594251881Speter
2595251881Speter/* @defgroup svn_wc__db_lock  Function to manage the LOCKS table.
2596251881Speter   @{
2597251881Speter*/
2598251881Speter
2599251881Speter/* Add or replace LOCK for LOCAL_ABSPATH to DB.  */
2600251881Spetersvn_error_t *
2601251881Spetersvn_wc__db_lock_add(svn_wc__db_t *db,
2602251881Speter                    const char *local_abspath,
2603251881Speter                    const svn_wc__db_lock_t *lock,
2604251881Speter                    apr_pool_t *scratch_pool);
2605251881Speter
2606251881Speter
2607251881Speter/* Remove any lock for LOCAL_ABSPATH in DB.  */
2608251881Spetersvn_error_t *
2609251881Spetersvn_wc__db_lock_remove(svn_wc__db_t *db,
2610251881Speter                       const char *local_abspath,
2611251881Speter                       apr_pool_t *scratch_pool);
2612251881Speter
2613251881Speter
2614251881Speter/* @} */
2615251881Speter
2616251881Speter
2617251881Speter/* @defgroup svn_wc__db_scan  Functions to scan up a tree for further data.
2618251881Speter   @{
2619251881Speter*/
2620251881Speter
2621251881Speter/* Read a BASE node's repository information.
2622251881Speter
2623251881Speter   For the BASE node implied by LOCAL_ABSPATH, its location in the repository
2624251881Speter   returned in *REPOS_ROOT_URL and *REPOS_UUID will be returned in
2625251881Speter   *REPOS_RELPATH. Any of the OUT parameters may be NULL, indicating no
2626251881Speter   interest in that piece of information.
2627251881Speter
2628251881Speter   All returned data will be allocated in RESULT_POOL. All temporary
2629251881Speter   allocations will be made in SCRATCH_POOL.
2630251881Speter
2631251881Speter   ### Either delete this function and use _base_get_info instead, or
2632251881Speter   ### add a 'revision' output to make a complete repository node location
2633251881Speter   ### and rename to not say 'scan', because it doesn't.
2634251881Speter*/
2635251881Spetersvn_error_t *
2636251881Spetersvn_wc__db_scan_base_repos(const char **repos_relpath,
2637251881Speter                           const char **repos_root_url,
2638251881Speter                           const char **repos_uuid,
2639251881Speter                           svn_wc__db_t *db,
2640251881Speter                           const char *local_abspath,
2641251881Speter                           apr_pool_t *result_pool,
2642251881Speter                           apr_pool_t *scratch_pool);
2643251881Speter
2644251881Speter
2645251881Speter/* Scan upwards for information about a known addition to the WORKING tree.
2646251881Speter
2647251881Speter   IFF a node's status as returned by svn_wc__db_read_info() is
2648251881Speter   svn_wc__db_status_added (NOT obstructed_add!), then this function
2649251881Speter   returns a refined status in *STATUS, which is one of:
2650251881Speter
2651251881Speter     svn_wc__db_status_added -- this NODE is a simple add without history.
2652251881Speter       OP_ROOT_ABSPATH will be set to the topmost node in the added subtree
2653251881Speter       (implying its parent will be an unshadowed BASE node). The REPOS_*
2654251881Speter       values will be implied by that ancestor BASE node and this node's
2655251881Speter       position in the added subtree. ORIGINAL_* will be set to their
2656251881Speter       NULL values (and SVN_INVALID_REVNUM for ORIGINAL_REVISION).
2657251881Speter
2658251881Speter     svn_wc__db_status_copied -- this NODE is the root or child of a copy.
2659251881Speter       The root of the copy will be stored in OP_ROOT_ABSPATH. Note that
2660251881Speter       the parent of the operation root could be another WORKING node (from
2661251881Speter       an add, copy, or move). The REPOS_* values will be implied by the
2662251881Speter       ancestor unshadowed BASE node. ORIGINAL_* will indicate the source
2663251881Speter       of the copy.
2664251881Speter
2665251881Speter     svn_wc__db_status_incomplete -- this NODE is copied but incomplete.
2666251881Speter
2667251881Speter     svn_wc__db_status_moved_here -- this NODE arrived as a result of a move.
2668251881Speter       The root of the moved nodes will be stored in OP_ROOT_ABSPATH.
2669251881Speter       Similar to the copied state, its parent may be a WORKING node or a
2670251881Speter       BASE node. And again, the REPOS_* values are implied by this node's
2671251881Speter       position in the subtree under the ancestor unshadowed BASE node.
2672251881Speter       ORIGINAL_* will indicate the source of the move.
2673251881Speter
2674251881Speter   All OUT parameters may be NULL to indicate a lack of interest in
2675251881Speter   that piece of information.
2676251881Speter
2677251881Speter   STATUS, OP_ROOT_ABSPATH, and REPOS_* will always be assigned a value
2678251881Speter   if that information is requested (and assuming a successful return).
2679251881Speter
2680251881Speter   ORIGINAL_REPOS_RELPATH will refer to the *root* of the operation. It
2681251881Speter   does *not* correspond to the node given by LOCAL_ABSPATH. The caller
2682251881Speter   can use the suffix on LOCAL_ABSPATH (relative to OP_ROOT_ABSPATH) in
2683251881Speter   order to compute the source node which corresponds to LOCAL_ABSPATH.
2684251881Speter
2685251881Speter   If the node given by LOCAL_ABSPATH does not have changes recorded in
2686251881Speter   the WORKING tree, then SVN_ERR_WC_PATH_NOT_FOUND is returned. If it
2687251881Speter   doesn't have an "added" status, then SVN_ERR_WC_PATH_UNEXPECTED_STATUS
2688251881Speter   will be returned.
2689251881Speter
2690251881Speter   All returned data will be allocated in RESULT_POOL. All temporary
2691251881Speter   allocations will be made in SCRATCH_POOL.
2692251881Speter*/
2693251881Spetersvn_error_t *
2694251881Spetersvn_wc__db_scan_addition(svn_wc__db_status_t *status,
2695251881Speter                         const char **op_root_abspath,
2696251881Speter                         const char **repos_relpath,
2697251881Speter                         const char **repos_root_url,
2698251881Speter                         const char **repos_uuid,
2699251881Speter                         const char **original_repos_relpath,
2700251881Speter                         const char **original_root_url,
2701251881Speter                         const char **original_uuid,
2702251881Speter                         svn_revnum_t *original_revision,
2703251881Speter                         svn_wc__db_t *db,
2704251881Speter                         const char *local_abspath,
2705251881Speter                         apr_pool_t *result_pool,
2706251881Speter                         apr_pool_t *scratch_pool);
2707251881Speter
2708251881Speter/* Scan the working copy for move information of the node LOCAL_ABSPATH.
2709251881Speter * If LOCAL_ABSPATH return a SVN_ERR_WC_PATH_UNEXPECTED_STATUS error.
2710251881Speter *
2711251881Speter * If not NULL *MOVED_FROM_ABSPATH will be set to the previous location
2712251881Speter * of LOCAL_ABSPATH, before it or an ancestror was moved.
2713251881Speter *
2714251881Speter * If not NULL *OP_ROOT_ABSPATH will be set to the new location of the
2715251881Speter * path that was actually moved
2716251881Speter *
2717251881Speter * If not NULL *OP_ROOT_MOVED_FROM_ABSPATH will be set to the old location
2718251881Speter * of the path that was actually moved.
2719251881Speter *
2720251881Speter * If not NULL *MOVED_FROM_DELETE_ABSPATH will be set to the ancestor of the
2721251881Speter * moved from location that deletes the original location
2722251881Speter *
2723251881Speter * Given a working copy
2724251881Speter * A/B/C
2725251881Speter * svn mv A/B D
2726251881Speter * svn rm A
2727251881Speter *
2728251881Speter * You can call this function on D and D/C. When called on D/C all output
2729251881Speter *              MOVED_FROM_ABSPATH will be A/B/C
2730251881Speter *              OP_ROOT_ABSPATH will be D
2731251881Speter *              OP_ROOT_MOVED_FROM_ABSPATH will be A/B
2732251881Speter *              MOVED_FROM_DELETE_ABSPATH will be A
2733251881Speter */
2734251881Spetersvn_error_t *
2735251881Spetersvn_wc__db_scan_moved(const char **moved_from_abspath,
2736251881Speter                      const char **op_root_abspath,
2737251881Speter                      const char **op_root_moved_from_abspath,
2738251881Speter                      const char **moved_from_delete_abspath,
2739251881Speter                      svn_wc__db_t *db,
2740251881Speter                      const char *local_abspath,
2741251881Speter                      apr_pool_t *result_pool,
2742251881Speter                      apr_pool_t *scratch_pool);
2743251881Speter
2744251881Speter/* Scan upwards for additional information about a deleted node.
2745251881Speter
2746251881Speter   When a deleted node is discovered in the WORKING tree, the situation
2747251881Speter   may be quite complex. This function will provide the information to
2748251881Speter   resolve the circumstances of the deletion.
2749251881Speter
2750251881Speter   For discussion purposes, we will start with the most complex example
2751251881Speter   and then demonstrate simplified examples. Consider node B/W/D/N has been
2752251881Speter   found as deleted. B is an unmodified directory (thus, only in BASE). W is
2753251881Speter   "replacement" content that exists in WORKING, shadowing a similar B/W
2754251881Speter   directory in BASE. D is a deleted subtree in the WORKING tree, and N is
2755251881Speter   the deleted node.
2756251881Speter
2757251881Speter   In this example, BASE_DEL_ABSPATH will bet set to B/W. That is the root of
2758251881Speter   the BASE tree (implicitly) deleted by the replacement. WORK_DEL_ABSPATH
2759251881Speter   will be set to the subtree deleted within the replacement; in this case,
2760251881Speter   B/W/D. No move-away took place, so MOVED_TO_ABSPATH is set to NULL.
2761251881Speter
2762251881Speter   In another scenario, B/W was moved-away before W was put into the WORKING
2763251881Speter   tree through an add/copy/move-here. MOVED_TO_ABSPATH will indicate where
2764251881Speter   B/W was moved to. Note that further operations may have been performed
2765251881Speter   post-move, but that is not known or reported by this function.
2766251881Speter
2767251881Speter   If BASE does not have a B/W, then the WORKING B/W is not a replacement,
2768251881Speter   but a simple add/copy/move-here. BASE_DEL_ABSPATH will be set to NULL.
2769251881Speter
2770251881Speter   If B/W/D does not exist in the WORKING tree (we're only talking about a
2771251881Speter   deletion of nodes of the BASE tree), then deleting B/W/D would have marked
2772251881Speter   the subtree for deletion. BASE_DEL_ABSPATH will refer to B/W/D,
2773251881Speter   MOVED_TO_ABSPATH will be NULL, and WORK_DEL_ABSPATH will be NULL.
2774251881Speter
2775251881Speter   If the BASE node B/W/D was moved instead of deleted, then MOVED_TO_ABSPATH
2776251881Speter   would indicate the target location (and other OUT values as above).
2777251881Speter
2778251881Speter   When the user deletes B/W/D from the WORKING tree, there are a few
2779251881Speter   additional considerations. If B/W is a simple addition (not a copy or
2780251881Speter   a move-here), then the deletion will simply remove the nodes from WORKING
2781251881Speter   and possibly leave behind "base-delete" markers in the WORKING tree.
2782251881Speter   If the source is a copy/moved-here, then the nodes are replaced with
2783251881Speter   deletion markers.
2784251881Speter
2785251881Speter   If the user moves-away B/W/D from the WORKING tree, then behavior is
2786251881Speter   again dependent upon the origination of B/W. For a plain add, the nodes
2787251881Speter   simply move to the destination; this means that B/W/D ceases to be a
2788251881Speter   node and so cannot be scanned. For a copy, a deletion is made at B/W/D,
2789251881Speter   and a new copy (of a subtree of the original source) is made at the
2790251881Speter   destination. For a move-here, a deletion is made, and a copy is made at
2791251881Speter   the destination (we do not track multiple moves; the source is moved to
2792251881Speter   B/W, then B/W/D is deleted; then a copy is made at the destination;
2793251881Speter   however, note the double-move could have been performed by moving the
2794251881Speter   subtree first, then moving the source to B/W).
2795251881Speter
2796251881Speter   There are three further considerations when resolving a deleted node:
2797251881Speter
2798251881Speter     If the BASE B/W/D was deleted explicitly *and* B/W is a replacement,
2799251881Speter     then the explicit deletion is subsumed by the implicit deletion that
2800251881Speter     occurred with the B/W replacement. Thus, BASE_DEL_ABSPATH will point
2801251881Speter     to B/W as the root of the BASE deletion. IOW, we can detect the
2802251881Speter     explicit move-away, but not an explicit deletion.
2803251881Speter
2804251881Speter     If B/W/D/N refers to a node present in the BASE tree, and B/W was
2805251881Speter     replaced by a shallow subtree, then it is possible for N to be
2806251881Speter     reported as deleted (from BASE) yet no deletions occurred in the
2807251881Speter     WORKING tree above N. Thus, WORK_DEL_ABSPATH will be set to NULL.
2808251881Speter
2809251881Speter
2810251881Speter   Summary of OUT parameters:
2811251881Speter
2812251881Speter   BASE_DEL_ABSPATH will specify the nearest ancestor of the explicit or
2813251881Speter   implicit deletion (if any) that applies to the BASE tree.
2814251881Speter
2815251881Speter   WORK_DEL_ABSPATH will specify the root of a deleted subtree within
2816251881Speter   the WORKING tree (note there is no concept of layered delete operations
2817251881Speter   in WORKING, so there is only one deletion root in the ancestry).
2818251881Speter
2819251881Speter   MOVED_TO_ABSPATH will specify the path where this node was moved to
2820251881Speter   if the node has moved-away.
2821251881Speter
2822251881Speter   If the node was moved-away, MOVED_TO_OP_ROOT_ABSPATH will specify the
2823251881Speter   target path of the root of the move operation.  If LOCAL_ABSPATH itself
2824251881Speter   is the source path of the root of the move operation, then
2825251881Speter   MOVED_TO_OP_ROOT_ABSPATH equals MOVED_TO_ABSPATH.
2826251881Speter
2827251881Speter   All OUT parameters may be set to NULL to indicate a lack of interest in
2828251881Speter   that piece of information.
2829251881Speter
2830251881Speter   If the node given by LOCAL_ABSPATH does not exist, then
2831251881Speter   SVN_ERR_WC_PATH_NOT_FOUND is returned. If it doesn't have a "deleted"
2832251881Speter   status, then SVN_ERR_WC_PATH_UNEXPECTED_STATUS will be returned.
2833251881Speter
2834251881Speter   All returned data will be allocated in RESULT_POOL. All temporary
2835251881Speter   allocations will be made in SCRATCH_POOL.
2836251881Speter*/
2837251881Spetersvn_error_t *
2838251881Spetersvn_wc__db_scan_deletion(const char **base_del_abspath,
2839251881Speter                         const char **moved_to_abspath,
2840251881Speter                         const char **work_del_abspath,
2841251881Speter                         const char **moved_to_op_root_abspath,
2842251881Speter                         svn_wc__db_t *db,
2843251881Speter                         const char *local_abspath,
2844251881Speter                         apr_pool_t *result_pool,
2845251881Speter                         apr_pool_t *scratch_pool);
2846251881Speter
2847251881Speter
2848251881Speter/* @} */
2849251881Speter
2850251881Speter
2851251881Speter/* @defgroup svn_wc__db_upgrade  Functions for upgrading a working copy.
2852251881Speter   @{
2853251881Speter*/
2854251881Speter
2855262253Speter/* Installs or updates Sqlite schema statistics for the current (aka latest)
2856262253Speter   working copy schema.
2857262253Speter
2858262253Speter   This function should be called once on initializing the database and after
2859262253Speter   an schema update completes */
2860262253Spetersvn_error_t *
2861262253Spetersvn_wc__db_install_schema_statistics(svn_sqlite__db_t *sdb,
2862262253Speter                                     apr_pool_t *scratch_pool);
2863262253Speter
2864262253Speter
2865251881Speter/* Create a new wc.db file for LOCAL_DIR_ABSPATH, which is going to be a
2866251881Speter   working copy for the repository REPOS_ROOT_URL with uuid REPOS_UUID.
2867251881Speter   Return the raw sqlite handle, repository id and working copy id
2868251881Speter   and store the database in WC_DB.
2869251881Speter
2870251881Speter   Perform temporary allocations in SCRATCH_POOL. */
2871251881Spetersvn_error_t *
2872251881Spetersvn_wc__db_upgrade_begin(svn_sqlite__db_t **sdb,
2873251881Speter                         apr_int64_t *repos_id,
2874251881Speter                         apr_int64_t *wc_id,
2875251881Speter                         svn_wc__db_t *wc_db,
2876251881Speter                         const char *local_dir_abspath,
2877251881Speter                         const char *repos_root_url,
2878251881Speter                         const char *repos_uuid,
2879251881Speter                         apr_pool_t *scratch_pool);
2880251881Speter
2881251881Speter
2882251881Spetersvn_error_t *
2883251881Spetersvn_wc__db_upgrade_apply_dav_cache(svn_sqlite__db_t *sdb,
2884251881Speter                                   const char *dir_relpath,
2885251881Speter                                   apr_hash_t *cache_values,
2886251881Speter                                   apr_pool_t *scratch_pool);
2887251881Speter
2888251881Speter
2889251881Speter/* ### need much more docco
2890251881Speter
2891251881Speter   ### this function should be called within a sqlite transaction. it makes
2892251881Speter   ### assumptions around this fact.
2893251881Speter
2894251881Speter   Apply the various sets of properties to the database nodes based on
2895251881Speter   their existence/presence, the current state of the node, and the original
2896251881Speter   format of the working copy which provided these property sets.
2897251881Speter*/
2898251881Spetersvn_error_t *
2899251881Spetersvn_wc__db_upgrade_apply_props(svn_sqlite__db_t *sdb,
2900251881Speter                               const char *dir_abspath,
2901251881Speter                               const char *local_relpath,
2902251881Speter                               apr_hash_t *base_props,
2903251881Speter                               apr_hash_t *revert_props,
2904251881Speter                               apr_hash_t *working_props,
2905251881Speter                               int original_format,
2906251881Speter                               apr_int64_t wc_id,
2907251881Speter                               apr_pool_t *scratch_pool);
2908251881Speter
2909251881Speter/* Simply insert (or replace) one row in the EXTERNALS table. */
2910251881Spetersvn_error_t *
2911251881Spetersvn_wc__db_upgrade_insert_external(svn_wc__db_t *db,
2912251881Speter                                   const char *local_abspath,
2913251881Speter                                   svn_node_kind_t kind,
2914251881Speter                                   const char *parent_abspath,
2915251881Speter                                   const char *def_local_abspath,
2916251881Speter                                   const char *repos_relpath,
2917251881Speter                                   const char *repos_root_url,
2918251881Speter                                   const char *repos_uuid,
2919251881Speter                                   svn_revnum_t def_peg_revision,
2920251881Speter                                   svn_revnum_t def_revision,
2921251881Speter                                   apr_pool_t *scratch_pool);
2922251881Speter
2923251881Speter/* Get the repository identifier corresponding to REPOS_ROOT_URL from the
2924251881Speter   database in SDB. The value is returned in *REPOS_ID. All allocations
2925251881Speter   are allocated in SCRATCH_POOL.
2926251881Speter
2927251881Speter   NOTE: the row in REPOSITORY must exist. If not, then SVN_ERR_WC_DB_ERROR
2928251881Speter   is returned.
2929251881Speter
2930251881Speter   ### unclear on whether/how this interface will stay/evolve.  */
2931251881Spetersvn_error_t *
2932251881Spetersvn_wc__db_upgrade_get_repos_id(apr_int64_t *repos_id,
2933251881Speter                                svn_sqlite__db_t *sdb,
2934251881Speter                                const char *repos_root_url,
2935251881Speter                                apr_pool_t *scratch_pool);
2936251881Speter
2937251881Speter/* Upgrade the metadata concerning the WC at WCROOT_ABSPATH, in DB,
2938251881Speter * to the SVN_WC__VERSION format.
2939251881Speter *
2940251881Speter * This function is used for upgrading wc-ng working copies to a newer
2941251881Speter * wc-ng format. If a pre-1.7 working copy is found, this function
2942251881Speter * returns SVN_ERR_WC_UPGRADE_REQUIRED.
2943251881Speter *
2944251881Speter * Upgrading subdirectories of a working copy is not supported.
2945251881Speter * If WCROOT_ABSPATH is not a working copy root SVN_ERR_WC_INVALID_OP_ON_CWD
2946251881Speter * is returned.
2947253734Speter *
2948253734Speter * If BUMPED_FORMAT is not NULL, set *BUMPED_FORMAT to TRUE if the format
2949253734Speter * was bumped or to FALSE if the wc was already at the resulting format.
2950251881Speter */
2951251881Spetersvn_error_t *
2952251881Spetersvn_wc__db_bump_format(int *result_format,
2953253734Speter                       svn_boolean_t *bumped_format,
2954253734Speter                       svn_wc__db_t *db,
2955251881Speter                       const char *wcroot_abspath,
2956251881Speter                       apr_pool_t *scratch_pool);
2957251881Speter
2958251881Speter/* @} */
2959251881Speter
2960251881Speter
2961251881Speter/* @defgroup svn_wc__db_wq  Work queue manipulation. see workqueue.h
2962251881Speter   @{
2963251881Speter*/
2964251881Speter
2965251881Speter/* In the WCROOT associated with DB and WRI_ABSPATH, add WORK_ITEM to the
2966251881Speter   wcroot's work queue. Use SCRATCH_POOL for all temporary allocations.  */
2967251881Spetersvn_error_t *
2968251881Spetersvn_wc__db_wq_add(svn_wc__db_t *db,
2969251881Speter                  const char *wri_abspath,
2970251881Speter                  const svn_skel_t *work_item,
2971251881Speter                  apr_pool_t *scratch_pool);
2972251881Speter
2973251881Speter
2974251881Speter/* In the WCROOT associated with DB and WRI_ABSPATH, fetch a work item that
2975251881Speter   needs to be completed. Its identifier is returned in ID, and the data in
2976251881Speter   WORK_ITEM.
2977251881Speter
2978251881Speter   Items are returned in the same order they were queued. This allows for
2979251881Speter   (say) queueing work on a parent node to be handled before that of its
2980251881Speter   children.
2981251881Speter
2982251881Speter   If there are no work items to be completed, then ID will be set to zero,
2983251881Speter   and WORK_ITEM to NULL.
2984251881Speter
2985251881Speter   If COMPLETED_ID is not 0, the wq item COMPLETED_ID will be marked as
2986251881Speter   completed before returning the next item.
2987251881Speter
2988251881Speter   RESULT_POOL will be used to allocate WORK_ITEM, and SCRATCH_POOL
2989251881Speter   will be used for all temporary allocations.  */
2990251881Spetersvn_error_t *
2991251881Spetersvn_wc__db_wq_fetch_next(apr_uint64_t *id,
2992251881Speter                         svn_skel_t **work_item,
2993251881Speter                         svn_wc__db_t *db,
2994251881Speter                         const char *wri_abspath,
2995251881Speter                         apr_uint64_t completed_id,
2996251881Speter                         apr_pool_t *result_pool,
2997251881Speter                         apr_pool_t *scratch_pool);
2998251881Speter
2999251881Speter/* Special variant of svn_wc__db_wq_fetch_next(), which in the same transaction
3000251881Speter   also records timestamps and sizes for one or more nodes */
3001251881Spetersvn_error_t *
3002251881Spetersvn_wc__db_wq_record_and_fetch_next(apr_uint64_t *id,
3003251881Speter                                    svn_skel_t **work_item,
3004251881Speter                                    svn_wc__db_t *db,
3005251881Speter                                    const char *wri_abspath,
3006251881Speter                                    apr_uint64_t completed_id,
3007251881Speter                                    apr_hash_t *record_map,
3008251881Speter                                    apr_pool_t *result_pool,
3009251881Speter                                    apr_pool_t *scratch_pool);
3010251881Speter
3011251881Speter
3012251881Speter/* @} */
3013251881Speter
3014251881Speter
3015251881Speter/* Note: LEVELS_TO_LOCK is here strictly for backward compat.  The access
3016251881Speter   batons still have the notion of 'levels to lock' and we need to ensure
3017251881Speter   that they still function correctly, even in the new world.  'levels to
3018251881Speter   lock' should not be exposed through the wc-ng APIs at all: users either
3019251881Speter   get to lock the entire tree (rooted at some subdir, of course), or none.
3020251881Speter
3021251881Speter   An infinite depth lock is obtained with LEVELS_TO_LOCK set to -1, but until
3022251881Speter   we move to a single DB only depth 0 is supported.
3023251881Speter*/
3024251881Spetersvn_error_t *
3025251881Spetersvn_wc__db_wclock_obtain(svn_wc__db_t *db,
3026251881Speter                         const char *local_abspath,
3027251881Speter                         int levels_to_lock,
3028251881Speter                         svn_boolean_t steal_lock,
3029251881Speter                         apr_pool_t *scratch_pool);
3030251881Speter
3031251881Speter/* Set LOCK_ABSPATH to the path of the the directory that owns the
3032251881Speter   lock on LOCAL_ABSPATH, or NULL, if LOCAL_ABSPATH is not locked. */
3033251881Spetersvn_error_t*
3034251881Spetersvn_wc__db_wclock_find_root(const char **lock_abspath,
3035251881Speter                            svn_wc__db_t *db,
3036251881Speter                            const char *local_abspath,
3037251881Speter                            apr_pool_t *result_pool,
3038251881Speter                            apr_pool_t *scratch_pool);
3039251881Speter
3040251881Speter/* Check if somebody has a wclock on LOCAL_ABSPATH */
3041251881Spetersvn_error_t *
3042251881Spetersvn_wc__db_wclocked(svn_boolean_t *locked,
3043251881Speter                    svn_wc__db_t *db,
3044251881Speter                    const char *local_abspath,
3045251881Speter                    apr_pool_t *scratch_pool);
3046251881Speter
3047251881Speter/* Release the previously obtained lock on LOCAL_ABSPATH */
3048251881Spetersvn_error_t *
3049251881Spetersvn_wc__db_wclock_release(svn_wc__db_t *db,
3050251881Speter                          const char *local_abspath,
3051251881Speter                          apr_pool_t *scratch_pool);
3052251881Speter
3053251881Speter/* Checks whether DB currently owns a lock to operate on LOCAL_ABSPATH.
3054251881Speter   If EXACT is TRUE only lock roots are checked. */
3055251881Spetersvn_error_t *
3056251881Spetersvn_wc__db_wclock_owns_lock(svn_boolean_t *own_lock,
3057251881Speter                            svn_wc__db_t *db,
3058251881Speter                            const char *local_abspath,
3059251881Speter                            svn_boolean_t exact,
3060251881Speter                            apr_pool_t *scratch_pool);
3061251881Speter
3062251881Speter
3063251881Speter
3064251881Speter/* @defgroup svn_wc__db_temp Various temporary functions during transition
3065251881Speter
3066251881Speter  ### These functions SHOULD be completely removed before 1.7
3067251881Speter
3068251881Speter  @{
3069251881Speter*/
3070251881Speter
3071251881Speter/* Removes all references to LOCAL_ABSPATH from DB, while optionally leaving
3072251881Speter   a not present node.
3073251881Speter
3074251881Speter   This operation always recursively removes all nodes at and below
3075251881Speter   LOCAL_ABSPATH from NODES and ACTUAL.
3076251881Speter
3077251881Speter   If NOT_PRESENT_REVISION specifies a valid revision, leave a not_present
3078251881Speter   BASE node at local_abspath of the specified status and kind.
3079251881Speter   (Requires an existing BASE node before removing)
3080251881Speter
3081251881Speter   If DESTROY_WC is TRUE, this operation *installs* workqueue operations to
3082251881Speter   update the local filesystem after the database operation. If DESTROY_CHANGES
3083251881Speter   is FALSE, modified and unversioned files are left after running this
3084251881Speter   operation (and the WQ). If DESTROY_CHANGES and DESTROY_WC are TRUE,
3085251881Speter   LOCAL_ABSPATH and everything below it will be removed by the WQ.
3086251881Speter
3087251881Speter
3088251881Speter   Note: Unlike many similar functions it is a valid scenario for this
3089251881Speter   function to be called on a wcroot! In this case it will just leave the root
3090251881Speter   record in BASE
3091251881Speter */
3092251881Spetersvn_error_t *
3093251881Spetersvn_wc__db_op_remove_node(svn_boolean_t *left_changes,
3094251881Speter                          svn_wc__db_t *db,
3095251881Speter                          const char *local_abspath,
3096251881Speter                          svn_boolean_t destroy_wc,
3097251881Speter                          svn_boolean_t destroy_changes,
3098251881Speter                          svn_revnum_t not_present_revision,
3099251881Speter                          svn_wc__db_status_t not_present_status,
3100251881Speter                          svn_node_kind_t not_present_kind,
3101251881Speter                          const svn_skel_t *conflict,
3102251881Speter                          const svn_skel_t *work_items,
3103251881Speter                          svn_cancel_func_t cancel_func,
3104251881Speter                          void *cancel_baton,
3105251881Speter                          apr_pool_t *scratch_pool);
3106251881Speter
3107251881Speter/* Sets the depth of LOCAL_ABSPATH in its working copy to DEPTH using DB.
3108251881Speter
3109251881Speter   Returns SVN_ERR_WC_PATH_NOT_FOUND if LOCAL_ABSPATH is not a BASE directory
3110251881Speter */
3111251881Spetersvn_error_t *
3112251881Spetersvn_wc__db_op_set_base_depth(svn_wc__db_t *db,
3113251881Speter                             const char *local_abspath,
3114251881Speter                             svn_depth_t depth,
3115251881Speter                             apr_pool_t *scratch_pool);
3116251881Speter
3117251881Speter/* ### temp function. return the FORMAT for the directory LOCAL_ABSPATH.  */
3118251881Spetersvn_error_t *
3119251881Spetersvn_wc__db_temp_get_format(int *format,
3120251881Speter                           svn_wc__db_t *db,
3121251881Speter                           const char *local_dir_abspath,
3122251881Speter                           apr_pool_t *scratch_pool);
3123251881Speter
3124251881Speter/* ### temp functions to manage/store access batons within the DB.  */
3125251881Spetersvn_wc_adm_access_t *
3126251881Spetersvn_wc__db_temp_get_access(svn_wc__db_t *db,
3127251881Speter                           const char *local_dir_abspath,
3128251881Speter                           apr_pool_t *scratch_pool);
3129251881Spetervoid
3130251881Spetersvn_wc__db_temp_set_access(svn_wc__db_t *db,
3131251881Speter                           const char *local_dir_abspath,
3132251881Speter                           svn_wc_adm_access_t *adm_access,
3133251881Speter                           apr_pool_t *scratch_pool);
3134251881Spetersvn_error_t *
3135251881Spetersvn_wc__db_temp_close_access(svn_wc__db_t *db,
3136251881Speter                             const char *local_dir_abspath,
3137251881Speter                             svn_wc_adm_access_t *adm_access,
3138251881Speter                             apr_pool_t *scratch_pool);
3139251881Spetervoid
3140251881Spetersvn_wc__db_temp_clear_access(svn_wc__db_t *db,
3141251881Speter                             const char *local_dir_abspath,
3142251881Speter                             apr_pool_t *scratch_pool);
3143251881Speter
3144251881Speter/* ### shallow hash: abspath -> svn_wc_adm_access_t *  */
3145251881Speterapr_hash_t *
3146251881Spetersvn_wc__db_temp_get_all_access(svn_wc__db_t *db,
3147251881Speter                               apr_pool_t *result_pool);
3148251881Speter
3149251881Speter/* ### temp function to open the sqlite database to the appropriate location,
3150251881Speter   ### then borrow it for a bit.
3151251881Speter   ### The *only* reason for this function is because entries.c still
3152251881Speter   ### manually hacks the sqlite database.
3153251881Speter
3154251881Speter   ### No matter how tempted you may be DO NOT USE THIS FUNCTION!
3155251881Speter   ### (if you do, gstein will hunt you down and burn your knee caps off
3156251881Speter   ### in the middle of the night)
3157251881Speter   ### "Bet on it." --gstein
3158251881Speter*/
3159251881Spetersvn_error_t *
3160251881Spetersvn_wc__db_temp_borrow_sdb(svn_sqlite__db_t **sdb,
3161251881Speter                           svn_wc__db_t *db,
3162251881Speter                           const char *local_dir_abspath,
3163251881Speter                           apr_pool_t *scratch_pool);
3164251881Speter
3165251881Speter
3166251881Speter/* Return a directory in *TEMP_DIR_ABSPATH that is suitable for temporary
3167251881Speter   files which may need to be moved (atomically and same-device) into the
3168251881Speter   working copy indicated by WRI_ABSPATH.  */
3169251881Spetersvn_error_t *
3170251881Spetersvn_wc__db_temp_wcroot_tempdir(const char **temp_dir_abspath,
3171251881Speter                               svn_wc__db_t *db,
3172251881Speter                               const char *wri_abspath,
3173251881Speter                               apr_pool_t *result_pool,
3174251881Speter                               apr_pool_t *scratch_pool);
3175251881Speter
3176251881Speter/* Update the BASE_NODE of directory LOCAL_ABSPATH to be NEW_REPOS_RELPATH
3177251881Speter   at revision NEW_REV with status incomplete. */
3178251881Spetersvn_error_t *
3179251881Spetersvn_wc__db_temp_op_start_directory_update(svn_wc__db_t *db,
3180251881Speter                                          const char *local_abspath,
3181251881Speter                                          const char *new_repos_relpath,
3182251881Speter                                          svn_revnum_t new_rev,
3183251881Speter                                          apr_pool_t *scratch_pool);
3184251881Speter
3185251881Speter/* Marks a directory update started with
3186251881Speter   svn_wc__db_temp_op_start_directory_update as completed, by removing
3187251881Speter   the incomplete status */
3188251881Spetersvn_error_t *
3189251881Spetersvn_wc__db_temp_op_end_directory_update(svn_wc__db_t *db,
3190251881Speter                                        const char *local_dir_abspath,
3191251881Speter                                        apr_pool_t *scratch_pool);
3192251881Speter
3193251881Speter
3194251881Speter/* Copy the base tree at LOCAL_ABSPATH into the working tree as copy,
3195251881Speter   leaving any subtree additions and copies as-is.  This allows the
3196251881Speter   base node tree to be removed. */
3197251881Spetersvn_error_t *
3198251881Spetersvn_wc__db_op_make_copy(svn_wc__db_t *db,
3199251881Speter                        const char *local_abspath,
3200251881Speter                        const svn_skel_t *conflicts,
3201251881Speter                        const svn_skel_t *work_items,
3202251881Speter                        apr_pool_t *scratch_pool);
3203251881Speter
3204251881Speter/* Close the wc root LOCAL_ABSPATH and remove any per-directory
3205251881Speter   handles associated with it. */
3206251881Spetersvn_error_t *
3207251881Spetersvn_wc__db_drop_root(svn_wc__db_t *db,
3208251881Speter                     const char *local_abspath,
3209251881Speter                     apr_pool_t *scratch_pool);
3210251881Speter
3211251881Speter/* Return the OP_DEPTH for LOCAL_RELPATH. */
3212251881Speterint
3213251881Spetersvn_wc__db_op_depth_for_upgrade(const char *local_relpath);
3214251881Speter
3215251881Speter/* Set *HAVE_WORK TRUE if there is a working layer below the top layer and
3216251881Speter   *HAVE_BASE if there is a base layer. Set *STATUS to the status of the
3217251881Speter   highest layer below WORKING */
3218251881Spetersvn_error_t *
3219251881Spetersvn_wc__db_info_below_working(svn_boolean_t *have_base,
3220251881Speter                              svn_boolean_t *have_work,
3221251881Speter                              svn_wc__db_status_t *status,
3222251881Speter                              svn_wc__db_t *db,
3223251881Speter                              const char *local_abspath,
3224251881Speter                              apr_pool_t *scratch_pool);
3225251881Speter
3226251881Speter
3227251881Speter/* Gets an array of const char *local_relpaths of descendants of LOCAL_ABSPATH,
3228251881Speter * which itself must be the op root of an addition, copy or move.
3229251881Speter * The descendants returned are at the same op_depth, but are to be deleted
3230251881Speter * by the commit processing because they are not present in the local copy.
3231251881Speter */
3232251881Spetersvn_error_t *
3233251881Spetersvn_wc__db_get_not_present_descendants(const apr_array_header_t **descendants,
3234251881Speter                                       svn_wc__db_t *db,
3235251881Speter                                       const char *local_abspath,
3236251881Speter                                       apr_pool_t *result_pool,
3237251881Speter                                       apr_pool_t *scratch_pool);
3238251881Speter
3239251881Speter/* Gather revision status information about a working copy using DB.
3240251881Speter *
3241251881Speter * Set *MIN_REVISION and *MAX_REVISION to the lowest and highest revision
3242251881Speter * numbers found within LOCAL_ABSPATH.
3243251881Speter * Only nodes with op_depth zero and presence 'normal' or 'incomplete'
3244251881Speter * are considered, so that added, deleted or excluded nodes do not affect
3245251881Speter * the result.  If COMMITTED is TRUE, set *MIN_REVISION and *MAX_REVISION
3246251881Speter * to the lowest and highest committed (i.e. "last changed") revision numbers,
3247251881Speter * respectively.
3248251881Speter *
3249251881Speter * Indicate in *IS_SPARSE_CHECKOUT whether any of the nodes within
3250251881Speter * LOCAL_ABSPATH is sparse.
3251251881Speter * Indicate in *IS_MODIFIED whether the working copy has local modifications.
3252251881Speter *
3253251881Speter * Indicate in *IS_SWITCHED whether any node beneath LOCAL_ABSPATH
3254251881Speter * is switched. If TRAIL_URL is non-NULL, use it to determine if LOCAL_ABSPATH
3255251881Speter * itself is switched.  It should be any trailing portion of LOCAL_ABSPATH's
3256251881Speter * expected URL, long enough to include any parts that the caller considers
3257251881Speter * might be changed by a switch.  If it does not match the end of WC_PATH's
3258251881Speter * actual URL, then report a "switched" status.
3259251881Speter *
3260251881Speter * See also the functions below which provide a subset of this functionality.
3261251881Speter */
3262251881Spetersvn_error_t *
3263251881Spetersvn_wc__db_revision_status(svn_revnum_t *min_revision,
3264251881Speter                           svn_revnum_t *max_revision,
3265251881Speter                           svn_boolean_t *is_sparse_checkout,
3266251881Speter                           svn_boolean_t *is_modified,
3267251881Speter                           svn_boolean_t *is_switched,
3268251881Speter                           svn_wc__db_t *db,
3269251881Speter                           const char *local_abspath,
3270251881Speter                           const char *trail_url,
3271251881Speter                           svn_boolean_t committed,
3272251881Speter                           svn_cancel_func_t cancel_func,
3273251881Speter                           void *cancel_baton,
3274251881Speter                           apr_pool_t *scratch_pool);
3275251881Speter
3276251881Speter/* Set *MIN_REVISION and *MAX_REVISION to the lowest and highest revision
3277251881Speter * numbers found within LOCAL_ABSPATH in the working copy using DB.
3278251881Speter * Only nodes with op_depth zero and presence 'normal' or 'incomplete'
3279251881Speter * are considered, so that added, deleted or excluded nodes do not affect
3280251881Speter * the result.  If COMMITTED is TRUE, set *MIN_REVISION and *MAX_REVISION
3281251881Speter * to the lowest and highest committed (i.e. "last changed") revision numbers,
3282251881Speter * respectively. Use SCRATCH_POOL for temporary allocations.
3283251881Speter *
3284251881Speter * Either of MIN_REVISION and MAX_REVISION may be passed as NULL if
3285251881Speter * the caller doesn't care about that return value.
3286251881Speter *
3287251881Speter * This function provides a subset of the functionality of
3288251881Speter * svn_wc__db_revision_status() and is more efficient if the caller
3289251881Speter * doesn't need all information returned by svn_wc__db_revision_status(). */
3290251881Spetersvn_error_t *
3291251881Spetersvn_wc__db_min_max_revisions(svn_revnum_t *min_revision,
3292251881Speter                             svn_revnum_t *max_revision,
3293251881Speter                             svn_wc__db_t *db,
3294251881Speter                             const char *local_abspath,
3295251881Speter                             svn_boolean_t committed,
3296251881Speter                             apr_pool_t *scratch_pool);
3297251881Speter
3298251881Speter/* Indicate in *IS_SWITCHED whether any node beneath LOCAL_ABSPATH
3299251881Speter * is switched, using DB. Use SCRATCH_POOL for temporary allocations.
3300251881Speter *
3301251881Speter * If TRAIL_URL is non-NULL, use it to determine if LOCAL_ABSPATH itself
3302251881Speter * is switched.  It should be any trailing portion of LOCAL_ABSPATH's
3303251881Speter * expected URL, long enough to include any parts that the caller considers
3304251881Speter * might be changed by a switch.  If it does not match the end of WC_PATH's
3305251881Speter * actual URL, then report a "switched" status.
3306251881Speter *
3307251881Speter * This function provides a subset of the functionality of
3308251881Speter * svn_wc__db_revision_status() and is more efficient if the caller
3309251881Speter * doesn't need all information returned by svn_wc__db_revision_status(). */
3310251881Spetersvn_error_t *
3311251881Spetersvn_wc__db_has_switched_subtrees(svn_boolean_t *is_switched,
3312251881Speter                                 svn_wc__db_t *db,
3313251881Speter                                 const char *local_abspath,
3314251881Speter                                 const char *trail_url,
3315251881Speter                                 apr_pool_t *scratch_pool);
3316251881Speter
3317251881Speter/* Set @a *excluded_subtrees to a hash mapping <tt>const char *</tt>
3318251881Speter * local absolute paths to <tt>const char *</tt> local absolute paths for
3319251881Speter * every path under @a local_abspath in @a db which are excluded by
3320251881Speter * the server (e.g. due to authz), or user.  If no such paths are found then
3321251881Speter * @a *server_excluded_subtrees is set to @c NULL.
3322251881Speter * Allocate the hash and all items therein from @a result_pool.
3323251881Speter */
3324251881Spetersvn_error_t *
3325251881Spetersvn_wc__db_get_excluded_subtrees(apr_hash_t **server_excluded_subtrees,
3326251881Speter                                 svn_wc__db_t *db,
3327251881Speter                                 const char *local_abspath,
3328251881Speter                                 apr_pool_t *result_pool,
3329251881Speter                                 apr_pool_t *scratch_pool);
3330251881Speter
3331251881Speter/* Indicate in *IS_MODIFIED whether the working copy has local modifications,
3332251881Speter * using DB. Use SCRATCH_POOL for temporary allocations.
3333251881Speter *
3334251881Speter * This function provides a subset of the functionality of
3335251881Speter * svn_wc__db_revision_status() and is more efficient if the caller
3336251881Speter * doesn't need all information returned by svn_wc__db_revision_status(). */
3337251881Spetersvn_error_t *
3338251881Spetersvn_wc__db_has_local_mods(svn_boolean_t *is_modified,
3339251881Speter                          svn_wc__db_t *db,
3340251881Speter                          const char *local_abspath,
3341251881Speter                          svn_cancel_func_t cancel_func,
3342251881Speter                          void *cancel_baton,
3343251881Speter                          apr_pool_t *scratch_pool);
3344251881Speter
3345251881Speter
3346251881Speter/* Verify the consistency of metadata concerning the WC that contains
3347251881Speter * WRI_ABSPATH, in DB.  Return an error if any problem is found. */
3348251881Spetersvn_error_t *
3349251881Spetersvn_wc__db_verify(svn_wc__db_t *db,
3350251881Speter                  const char *wri_abspath,
3351251881Speter                  apr_pool_t *scratch_pool);
3352251881Speter
3353251881Speter
3354251881Speter/* Possibly need two structures, one with relpaths and with abspaths?
3355251881Speter * Only exposed for testing at present. */
3356251881Speterstruct svn_wc__db_moved_to_t {
3357251881Speter  const char *local_relpath;  /* moved-to destination */
3358251881Speter  int op_depth;       /* op-root of source */
3359251881Speter};
3360251881Speter
3361251881Speter/* Set *FINAL_ABSPATH to an array of svn_wc__db_moved_to_t for
3362251881Speter * LOCAL_ABSPATH after following any and all nested moves.
3363251881Speter * Only exposed for testing at present. */
3364251881Spetersvn_error_t *
3365251881Spetersvn_wc__db_follow_moved_to(apr_array_header_t **moved_tos,
3366251881Speter                           svn_wc__db_t *db,
3367251881Speter                           const char *local_abspath,
3368251881Speter                           apr_pool_t *result_pool,
3369251881Speter                           apr_pool_t *scratch_pool);
3370251881Speter
3371251881Speter/* Update a moved-away tree conflict victim at VICTIM_ABSPATH with changes
3372251881Speter * brought in by the update operation which flagged the tree conflict. */
3373251881Spetersvn_error_t *
3374251881Spetersvn_wc__db_update_moved_away_conflict_victim(svn_wc__db_t *db,
3375251881Speter                                             const char *victim_abspath,
3376251881Speter                                             svn_wc_notify_func2_t notify_func,
3377251881Speter                                             void *notify_baton,
3378251881Speter                                             svn_cancel_func_t cancel_func,
3379251881Speter                                             void *cancel_baton,
3380251881Speter                                             apr_pool_t *scratch_pool);
3381251881Speter
3382251881Speter/* LOCAL_ABSPATH is moved to MOVE_DST_ABSPATH.  MOVE_SRC_ROOT_ABSPATH
3383251881Speter * is the root of the move to MOVE_DST_OP_ROOT_ABSPATH.
3384251881Speter * MOVE_SRC_OP_ROOT_ABSPATH is the op-root of the move; it's the same
3385251881Speter * as MOVE_SRC_ROOT_ABSPATH except for moves inside deletes when it is
3386251881Speter * the op-root of the delete. */
3387251881Spetersvn_error_t *
3388251881Spetersvn_wc__db_base_moved_to(const char **move_dst_abspath,
3389251881Speter                         const char **move_dst_op_root_abspath,
3390251881Speter                         const char **move_src_root_abspath,
3391251881Speter                         const char **move_src_op_root_abspath,
3392251881Speter                         svn_wc__db_t *db,
3393251881Speter                         const char *local_abspath,
3394251881Speter                         apr_pool_t *result_pool,
3395251881Speter                         apr_pool_t *scratch_pool);
3396251881Speter
3397251881Speter/* Recover space from the database file for LOCAL_ABSPATH by running
3398251881Speter * the "vacuum" command. */
3399251881Spetersvn_error_t *
3400251881Spetersvn_wc__db_vacuum(svn_wc__db_t *db,
3401251881Speter                  const char *local_abspath,
3402251881Speter                  apr_pool_t *scratch_pool);
3403251881Speter
3404251881Speter/* This raises move-edit tree-conflicts on any moves inside the
3405251881Speter   delete-edit conflict on LOCAL_ABSPATH. This is experimental: see
3406251881Speter   comment in resolve_conflict_on_node about combining with another
3407251881Speter   function. */
3408251881Spetersvn_error_t *
3409251881Spetersvn_wc__db_resolve_delete_raise_moved_away(svn_wc__db_t *db,
3410251881Speter                                           const char *local_abspath,
3411251881Speter                                           svn_wc_notify_func2_t notify_func,
3412251881Speter                                           void *notify_baton,
3413251881Speter                                           apr_pool_t *scratch_pool);
3414251881Speter
3415251881Speter/* Like svn_wc__db_resolve_delete_raise_moved_away this should be
3416262253Speter   combined.
3417262253Speter
3418262253Speter   ### LOCAL_ABSPATH specifies the move origin, but the move origin
3419262253Speter   ### is not necessary unique enough. This function needs an op_root_abspath
3420262253Speter   ### argument to differentiate between different origins.
3421262253Speter
3422262253Speter   ### See move_tests.py: move_many_update_delete for an example case.
3423262253Speter   */
3424251881Spetersvn_error_t *
3425251881Spetersvn_wc__db_resolve_break_moved_away(svn_wc__db_t *db,
3426251881Speter                                    const char *local_abspath,
3427251881Speter                                    svn_wc_notify_func2_t notify_func,
3428251881Speter                                    void *notify_baton,
3429251881Speter                                    apr_pool_t *scratch_pool);
3430251881Speter
3431251881Speter/* Break moves for all moved-away children of LOCAL_ABSPATH, within
3432251881Speter * a single transaction.
3433251881Speter *
3434251881Speter * ### Like svn_wc__db_resolve_delete_raise_moved_away this should be
3435251881Speter * combined. */
3436251881Spetersvn_error_t *
3437251881Spetersvn_wc__db_resolve_break_moved_away_children(svn_wc__db_t *db,
3438251881Speter                                             const char *local_abspath,
3439251881Speter                                             svn_wc_notify_func2_t notify_func,
3440251881Speter                                             void *notify_baton,
3441251881Speter                                             apr_pool_t *scratch_pool);
3442251881Speter
3443251881Speter/* Set *REQUIRED_ABSPATH to the path that should be locked to ensure
3444251881Speter * that the lock covers all paths affected by resolving the conflicts
3445251881Speter * in the tree LOCAL_ABSPATH. */
3446251881Spetersvn_error_t *
3447251881Spetersvn_wc__required_lock_for_resolve(const char **required_abspath,
3448251881Speter                                  svn_wc__db_t *db,
3449251881Speter                                  const char *local_abspath,
3450251881Speter                                  apr_pool_t *result_pool,
3451251881Speter                                  apr_pool_t *scratch_pool);
3452251881Speter/* @} */
3453251881Speter
3454251881Speter
3455251881Speter#ifdef __cplusplus
3456251881Speter}
3457251881Speter#endif /* __cplusplus */
3458251881Speter
3459251881Speter#endif /* SVN_WC_DB_H */
3460