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,
1364289166Speter                       svn_depth_t depth,
1365251881Speter                       svn_boolean_t is_move,
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,
1406289166Speter                           svn_boolean_t is_move,
1407251881Speter                           const svn_skel_t *conflict,
1408251881Speter                           const svn_skel_t *work_items,
1409251881Speter                           apr_pool_t *scratch_pool);
1410251881Speter
1411251881Speter
1412251881Speter/* ### do we need svn_wc__db_op_copy_server_excluded() ??  */
1413251881Speter
1414251881Speter
1415251881Speter/* ### add a new versioned directory. a list of children is NOT passed
1416251881Speter   ### since they are added in future, distinct calls to db_op_add_*.
1417251881Speter   PROPS gives the properties; empty or NULL means none. */
1418251881Speter/* ### do we need a CONFLICTS param?  */
1419251881Spetersvn_error_t *
1420251881Spetersvn_wc__db_op_add_directory(svn_wc__db_t *db,
1421251881Speter                            const char *local_abspath,
1422251881Speter                            const apr_hash_t *props,
1423251881Speter                            const svn_skel_t *work_items,
1424251881Speter                            apr_pool_t *scratch_pool);
1425251881Speter
1426251881Speter
1427251881Speter/* Add a file.
1428251881Speter   PROPS gives the properties; empty or NULL means none.
1429251881Speter   ### this file has no "pristine"
1430251881Speter   ### contents, so a checksum [reference] is not required.  */
1431251881Speter/* ### do we need a CONFLICTS param?  */
1432251881Spetersvn_error_t *
1433251881Spetersvn_wc__db_op_add_file(svn_wc__db_t *db,
1434251881Speter                       const char *local_abspath,
1435251881Speter                       const apr_hash_t *props,
1436251881Speter                       const svn_skel_t *work_items,
1437251881Speter                       apr_pool_t *scratch_pool);
1438251881Speter
1439251881Speter
1440251881Speter/* Add a symlink.
1441251881Speter   PROPS gives the properties; empty or NULL means none. */
1442251881Speter/* ### do we need a CONFLICTS param?  */
1443251881Spetersvn_error_t *
1444251881Spetersvn_wc__db_op_add_symlink(svn_wc__db_t *db,
1445251881Speter                          const char *local_abspath,
1446251881Speter                          const char *target,
1447251881Speter                          const apr_hash_t *props,
1448251881Speter                          const svn_skel_t *work_items,
1449251881Speter                          apr_pool_t *scratch_pool);
1450251881Speter
1451251881Speter
1452251881Speter/* Set the properties of the node LOCAL_ABSPATH in the ACTUAL tree to
1453251881Speter   PROPS.
1454251881Speter
1455251881Speter   PROPS maps "const char *" names to "const svn_string_t *" values.
1456251881Speter   To specify no properties, PROPS must be an empty hash, not NULL.
1457251881Speter   If the node is not present, return an error.
1458251881Speter
1459251881Speter   If PROPS is NULL, set the properties to be the same as the pristine
1460251881Speter   properties.
1461251881Speter
1462251881Speter   If CONFLICT is not NULL, it is used to register a conflict on this
1463251881Speter   node at the same time the properties are changed.
1464251881Speter
1465251881Speter   WORK_ITEMS are inserted into the work queue, as additional things that
1466251881Speter   need to be completed before the working copy is stable.
1467251881Speter
1468251881Speter
1469251881Speter   If CLEAR_RECORDED_INFO is true, the recorded information for the node
1470251881Speter   is cleared. (commonly used when updating svn:* magic properties).
1471251881Speter
1472251881Speter   NOTE: This will overwrite ALL working properties the node currently
1473251881Speter   has. There is no db_op_set_prop() function. Callers must read all the
1474251881Speter   properties, change one, and write all the properties.
1475251881Speter   ### ugh. this has poor transaction semantics...
1476251881Speter
1477251881Speter
1478251881Speter   NOTE: This will create an entry in the ACTUAL table for the node if it
1479251881Speter   does not yet have one.
1480251881Speter*/
1481251881Spetersvn_error_t *
1482251881Spetersvn_wc__db_op_set_props(svn_wc__db_t *db,
1483251881Speter                        const char *local_abspath,
1484251881Speter                        apr_hash_t *props,
1485251881Speter                        svn_boolean_t clear_recorded_info,
1486251881Speter                        const svn_skel_t *conflict,
1487251881Speter                        const svn_skel_t *work_items,
1488251881Speter                        apr_pool_t *scratch_pool);
1489251881Speter
1490251881Speter/* Mark LOCAL_ABSPATH, and all children, for deletion.
1491251881Speter *
1492251881Speter * This function removes the file externals (and if DELETE_DIR_EXTERNALS is
1493251881Speter * TRUE also the directory externals) registered below LOCAL_ABSPATH.
1494251881Speter * (DELETE_DIR_EXTERNALS should be true if also removing unversioned nodes)
1495251881Speter *
1496251881Speter * If MOVED_TO_ABSPATH is not NULL, mark the deletion of LOCAL_ABSPATH
1497251881Speter * as the delete-half of a move from LOCAL_ABSPATH to MOVED_TO_ABSPATH.
1498251881Speter *
1499251881Speter * If NOTIFY_FUNC is not NULL, then it will be called (with NOTIFY_BATON)
1500251881Speter * for each node deleted. While this processing occurs, if CANCEL_FUNC is
1501251881Speter * not NULL, then it will be called (with CANCEL_BATON) to detect cancellation
1502251881Speter * during the processing.
1503251881Speter *
1504251881Speter * Note: the notification (and cancellation) occur outside of a SQLite
1505251881Speter * transaction.
1506251881Speter */
1507251881Spetersvn_error_t *
1508251881Spetersvn_wc__db_op_delete(svn_wc__db_t *db,
1509251881Speter                     const char *local_abspath,
1510251881Speter                     const char *moved_to_abspath,
1511251881Speter                     svn_boolean_t delete_dir_externals,
1512251881Speter                     svn_skel_t *conflict,
1513251881Speter                     svn_skel_t *work_items,
1514251881Speter                     svn_cancel_func_t cancel_func,
1515251881Speter                     void *cancel_baton,
1516251881Speter                     svn_wc_notify_func2_t notify_func,
1517251881Speter                     void *notify_baton,
1518251881Speter                     apr_pool_t *scratch_pool);
1519251881Speter
1520251881Speter
1521251881Speter/* Mark all LOCAL_ABSPATH in the TARGETS array, and all of their children,
1522251881Speter * for deletion.
1523251881Speter *
1524251881Speter * This function is more efficient than svn_wc__db_op_delete() because
1525251881Speter * only one sqlite transaction is used for all targets.
1526251881Speter * It currently lacks support for moves (though this could be changed,
1527251881Speter * at which point svn_wc__db_op_delete() becomes redundant).
1528251881Speter *
1529251881Speter * This function removes the file externals (and if DELETE_DIR_EXTERNALS is
1530251881Speter * TRUE also the directory externals) registered below the targets.
1531251881Speter * (DELETE_DIR_EXTERNALS should be true if also removing unversioned nodes)
1532251881Speter *
1533251881Speter * If NOTIFY_FUNC is not NULL, then it will be called (with NOTIFY_BATON)
1534251881Speter * for each node deleted. While this processing occurs, if CANCEL_FUNC is
1535251881Speter * not NULL, then it will be called (with CANCEL_BATON) to detect cancellation
1536251881Speter * during the processing.
1537251881Speter *
1538251881Speter * Note: the notification (and cancellation) occur outside of a SQLite
1539251881Speter * transaction.
1540251881Speter */
1541251881Spetersvn_error_t *
1542251881Spetersvn_wc__db_op_delete_many(svn_wc__db_t *db,
1543251881Speter                          apr_array_header_t *targets,
1544251881Speter                          svn_boolean_t delete_dir_externals,
1545251881Speter                          const svn_skel_t *conflict,
1546251881Speter                          svn_cancel_func_t cancel_func,
1547251881Speter                          void *cancel_baton,
1548251881Speter                          svn_wc_notify_func2_t notify_func,
1549251881Speter                          void *notify_baton,
1550251881Speter                          apr_pool_t *scratch_pool);
1551251881Speter
1552251881Speter
1553251881Speter/* ### mark PATH as (possibly) modified. "svn edit" ... right API here? */
1554251881Spetersvn_error_t *
1555251881Spetersvn_wc__db_op_modified(svn_wc__db_t *db,
1556251881Speter                       const char *local_abspath,
1557251881Speter                       apr_pool_t *scratch_pool);
1558251881Speter
1559251881Speter
1560251881Speter/* ### use NULL to remove from a changelist.
1561251881Speter
1562251881Speter   ### NOTE: only depth=svn_depth_empty is supported right now.
1563251881Speter */
1564251881Spetersvn_error_t *
1565251881Spetersvn_wc__db_op_set_changelist(svn_wc__db_t *db,
1566251881Speter                             const char *local_abspath,
1567251881Speter                             const char *new_changelist,
1568251881Speter                             const apr_array_header_t *changelist_filter,
1569251881Speter                             svn_depth_t depth,
1570251881Speter                             /* ### flip to CANCEL, then NOTIFY. precedent.  */
1571251881Speter                             svn_wc_notify_func2_t notify_func,
1572251881Speter                             void *notify_baton,
1573251881Speter                             svn_cancel_func_t cancel_func,
1574251881Speter                             void *cancel_baton,
1575251881Speter                             apr_pool_t *scratch_pool);
1576251881Speter
1577251881Speter/* Record CONFLICT on LOCAL_ABSPATH, potentially replacing other conflicts
1578251881Speter   recorded on LOCAL_ABSPATH.
1579251881Speter
1580251881Speter   Users should in most cases pass CONFLICT to another WC_DB call instead of
1581251881Speter   calling svn_wc__db_op_mark_conflict() directly outside a transaction, to
1582251881Speter   allow recording atomically with the operation involved.
1583251881Speter
1584251881Speter   Any work items that are necessary as part of marking this node conflicted
1585251881Speter   can be passed in WORK_ITEMS.
1586251881Speter */
1587251881Spetersvn_error_t *
1588251881Spetersvn_wc__db_op_mark_conflict(svn_wc__db_t *db,
1589251881Speter                            const char *local_abspath,
1590251881Speter                            const svn_skel_t *conflict,
1591251881Speter                            const svn_skel_t *work_items,
1592251881Speter                            apr_pool_t *scratch_pool);
1593251881Speter
1594251881Speter
1595251881Speter/* ### caller maintains ACTUAL, and how the resolution occurred. we're just
1596251881Speter   ### recording state.
1597251881Speter   ###
1598251881Speter   ### I'm not sure that these three values are the best way to do this,
1599251881Speter   ### but they're handy for now.  */
1600251881Spetersvn_error_t *
1601251881Spetersvn_wc__db_op_mark_resolved(svn_wc__db_t *db,
1602251881Speter                            const char *local_abspath,
1603251881Speter                            svn_boolean_t resolved_text,
1604251881Speter                            svn_boolean_t resolved_props,
1605251881Speter                            svn_boolean_t resolved_tree,
1606251881Speter                            const svn_skel_t *work_items,
1607251881Speter                            apr_pool_t *scratch_pool);
1608251881Speter
1609251881Speter
1610251881Speter/* Revert all local changes which are being maintained in the database,
1611251881Speter * including conflict storage, properties and text modification status.
1612251881Speter *
1613251881Speter * Returns SVN_ERR_WC_INVALID_OPERATION_DEPTH if the revert is not
1614251881Speter * possible, e.g. copy/delete but not a root, or a copy root with
1615251881Speter * children.
1616251881Speter *
1617251881Speter * At present only depth=empty and depth=infinity are supported.
1618251881Speter *
1619251881Speter * This function populates the revert list that can be queried to
1620251881Speter * determine what was reverted.
1621251881Speter */
1622251881Spetersvn_error_t *
1623251881Spetersvn_wc__db_op_revert(svn_wc__db_t *db,
1624251881Speter                     const char *local_abspath,
1625251881Speter                     svn_depth_t depth,
1626251881Speter                     apr_pool_t *result_pool,
1627251881Speter                     apr_pool_t *scratch_pool);
1628251881Speter
1629251881Speter/* Query the revert list for LOCAL_ABSPATH and set *REVERTED if the
1630251881Speter * path was reverted.  Set *MARKER_FILES to a const char *list of
1631251881Speter * marker files if any were recorded on LOCAL_ABSPATH.
1632251881Speter *
1633251881Speter * Set *COPIED_HERE if the reverted node was copied here and is the
1634251881Speter * operation root of the copy.
1635251881Speter * Set *KIND to the node kind of the reverted node.
1636251881Speter *
1637251881Speter * Removes the row for LOCAL_ABSPATH from the revert list.
1638251881Speter */
1639251881Spetersvn_error_t *
1640251881Spetersvn_wc__db_revert_list_read(svn_boolean_t *reverted,
1641251881Speter                            const apr_array_header_t **marker_files,
1642251881Speter                            svn_boolean_t *copied_here,
1643251881Speter                            svn_node_kind_t *kind,
1644251881Speter                            svn_wc__db_t *db,
1645251881Speter                            const char *local_abspath,
1646251881Speter                            apr_pool_t *result_pool,
1647251881Speter                            apr_pool_t *scratch_pool);
1648251881Speter
1649251881Speter/* The type of elements in the array returned by
1650251881Speter * svn_wc__db_revert_list_read_copied_children(). */
1651251881Spetertypedef struct svn_wc__db_revert_list_copied_child_info_t {
1652251881Speter  const char *abspath;
1653251881Speter  svn_node_kind_t kind;
1654251881Speter} svn_wc__db_revert_list_copied_child_info_t ;
1655251881Speter
1656251881Speter/* Return in *CHILDREN a list of reverted copied nodes at or within
1657251881Speter * LOCAL_ABSPATH (which is a reverted file or a reverted directory).
1658251881Speter * Allocate *COPIED_CHILDREN and its elements in RESULT_POOL.
1659251881Speter * The elements are of type svn_wc__db_revert_list_copied_child_info_t. */
1660251881Spetersvn_error_t *
1661251881Spetersvn_wc__db_revert_list_read_copied_children(const apr_array_header_t **children,
1662251881Speter                                            svn_wc__db_t *db,
1663251881Speter                                            const char *local_abspath,
1664251881Speter                                            apr_pool_t *result_pool,
1665251881Speter                                            apr_pool_t *scratch_pool);
1666251881Speter
1667251881Speter
1668251881Speter/* Make revert notifications for all paths in the revert list that are
1669251881Speter * equal to LOCAL_ABSPATH or below LOCAL_ABSPATH.
1670251881Speter *
1671251881Speter * Removes all the corresponding rows from the revert list.
1672251881Speter *
1673251881Speter * ### Pass in cancel_func?
1674251881Speter */
1675251881Spetersvn_error_t *
1676251881Spetersvn_wc__db_revert_list_notify(svn_wc_notify_func2_t notify_func,
1677251881Speter                              void *notify_baton,
1678251881Speter                              svn_wc__db_t *db,
1679251881Speter                              const char *local_abspath,
1680251881Speter                              apr_pool_t *scratch_pool);
1681251881Speter
1682251881Speter/* Clean up after svn_wc__db_op_revert by removing the revert list.
1683251881Speter */
1684251881Spetersvn_error_t *
1685251881Spetersvn_wc__db_revert_list_done(svn_wc__db_t *db,
1686251881Speter                            const char *local_abspath,
1687251881Speter                            apr_pool_t *scratch_pool);
1688251881Speter
1689251881Speter/* ### status */
1690251881Speter
1691251881Speter
1692251881Speter/* @} */
1693251881Speter
1694251881Speter/* @defgroup svn_wc__db_read  Read operations on the BASE/WORKING tree
1695251881Speter   @{
1696251881Speter
1697251881Speter   These functions query information about nodes in ACTUAL, and returns
1698251881Speter   the requested information from the appropriate ACTUAL, WORKING, or
1699251881Speter   BASE tree.
1700251881Speter
1701251881Speter   For example, asking for the checksum of the pristine version will
1702251881Speter   return the one recorded in WORKING, or if no WORKING node exists, then
1703251881Speter   the checksum comes from BASE.
1704251881Speter*/
1705251881Speter
1706251881Speter/* Retrieve information about a node.
1707251881Speter
1708251881Speter   For the node implied by LOCAL_ABSPATH from the local filesystem, return
1709251881Speter   information in the provided OUT parameters. Each OUT parameter may be
1710251881Speter   NULL, indicating that specific item is not requested.
1711251881Speter
1712251881Speter   The information returned comes from the BASE tree, as possibly modified
1713251881Speter   by the WORKING and ACTUAL trees.
1714251881Speter
1715251881Speter   If there is no information about the node, then SVN_ERR_WC_PATH_NOT_FOUND
1716251881Speter   will be returned.
1717251881Speter
1718251881Speter   The OUT parameters, and their "not available" values are:
1719251881Speter     STATUS                  n/a (always available)
1720251881Speter     KIND                    svn_node_unknown   (For ACTUAL only nodes)
1721251881Speter     REVISION                SVN_INVALID_REVNUM
1722251881Speter     REPOS_RELPATH           NULL
1723251881Speter     REPOS_ROOT_URL          NULL
1724251881Speter     REPOS_UUID              NULL
1725251881Speter     CHANGED_REV             SVN_INVALID_REVNUM
1726251881Speter     CHANGED_DATE            0
1727251881Speter     CHANGED_AUTHOR          NULL
1728251881Speter     DEPTH                   svn_depth_unknown
1729251881Speter     CHECKSUM                NULL
1730251881Speter     TARGET                  NULL
1731251881Speter
1732251881Speter     ORIGINAL_REPOS_RELPATH  NULL
1733251881Speter     ORIGINAL_ROOT_URL       NULL
1734251881Speter     ORIGINAL_UUID           NULL
1735251881Speter     ORIGINAL_REVISION       SVN_INVALID_REVNUM
1736251881Speter
1737251881Speter     LOCK                    NULL
1738251881Speter
1739251881Speter     RECORDED_SIZE           SVN_INVALID_FILESIZE
1740251881Speter     RECORDED_TIME       0
1741251881Speter
1742251881Speter     CHANGELIST              NULL
1743251881Speter     CONFLICTED              FALSE
1744251881Speter
1745251881Speter     OP_ROOT                 FALSE
1746251881Speter     HAD_PROPS               FALSE
1747251881Speter     PROPS_MOD               FALSE
1748251881Speter
1749251881Speter     HAVE_BASE               FALSE
1750251881Speter     HAVE_MORE_WORK          FALSE
1751251881Speter     HAVE_WORK               FALSE
1752251881Speter
1753251881Speter   When STATUS is requested, then it will be one of these values:
1754251881Speter
1755251881Speter     svn_wc__db_status_normal
1756251881Speter       A plain BASE node, with no local changes.
1757251881Speter
1758251881Speter     svn_wc__db_status_added
1759251881Speter       A node has been added/copied/moved to here. See HAVE_BASE to see
1760251881Speter       if this change overwrites a BASE node. Use scan_addition() to resolve
1761251881Speter       whether this has been added, copied, or moved, and the details of the
1762251881Speter       operation (this function only looks at LOCAL_ABSPATH, but resolving
1763251881Speter       the details requires scanning one or more ancestor nodes).
1764251881Speter
1765251881Speter     svn_wc__db_status_deleted
1766251881Speter       This node has been deleted or moved away. It may be a delete/move of
1767251881Speter       a BASE node, or a child node of a subtree that was copied/moved to
1768251881Speter       an ancestor location. Call scan_deletion() to determine the full
1769251881Speter       details of the operations upon this node.
1770251881Speter
1771251881Speter     svn_wc__db_status_server_excluded
1772251881Speter       The node is versioned/known by the server, but the server has
1773251881Speter       decided not to provide further information about the node. This
1774251881Speter       is a BASE node (since changes are not allowed to this node).
1775251881Speter
1776251881Speter     svn_wc__db_status_excluded
1777251881Speter       The node has been excluded from the working copy tree. This may
1778251881Speter       be an exclusion from the BASE tree, or an exclusion in the
1779251881Speter       WORKING tree for a child node of a copied/moved parent.
1780251881Speter
1781251881Speter     svn_wc__db_status_not_present
1782251881Speter       This is a node from the BASE tree, has been marked as "not-present"
1783251881Speter       within this mixed-revision working copy. This node is at a revision
1784251881Speter       that is not in the tree, contrary to its inclusion in the parent
1785251881Speter       node's revision.
1786251881Speter
1787251881Speter     svn_wc__db_status_incomplete
1788251881Speter       The BASE is incomplete due to an interrupted operation.  An
1789251881Speter       incomplete WORKING node will be svn_wc__db_status_added.
1790251881Speter
1791251881Speter   If REVISION is requested, it will be set to the revision of the
1792251881Speter   unmodified (BASE) node, or to SVN_INVALID_REVNUM if any structural
1793251881Speter   changes have been made to that node (that is, if the node has a row in
1794251881Speter   the WORKING table).
1795251881Speter
1796251881Speter   If DEPTH is requested, and the node is NOT a directory, then
1797251881Speter   the value will be set to svn_depth_unknown.
1798251881Speter
1799251881Speter   If CHECKSUM is requested, and the node is NOT a file, then it will
1800251881Speter   be set to NULL.
1801251881Speter
1802251881Speter   If TARGET is requested, and the node is NOT a symlink, then it will
1803251881Speter   be set to NULL.
1804251881Speter
1805251881Speter   If TRANSLATED_SIZE is requested, and the node is NOT a file, then
1806251881Speter   it will be set to SVN_INVALID_FILESIZE.
1807251881Speter
1808251881Speter   If HAVE_WORK is TRUE, the returned information is from the highest WORKING
1809251881Speter   layer. In that case HAVE_MORE_WORK and HAVE_BASE provide information about
1810251881Speter   what other layers exist for this node.
1811251881Speter
1812251881Speter   If HAVE_WORK is FALSE and HAVE_BASE is TRUE then the information is from
1813251881Speter   the BASE tree.
1814251881Speter
1815251881Speter   If HAVE_WORK and HAVE_BASE are both FALSE and when retrieving CONFLICTED,
1816251881Speter   then the node doesn't exist at all.
1817251881Speter
1818251881Speter   If OP_ROOT is requested and the node has a WORKING layer, OP_ROOT will be
1819251881Speter   set to true if this node is the op_root for this layer.
1820251881Speter
1821251881Speter   If HAD_PROPS is requested and the node has pristine props, the value will
1822251881Speter   be set to TRUE.
1823251881Speter
1824251881Speter   If PROPS_MOD is requested and the node has property modification the value
1825251881Speter   will be set to TRUE.
1826251881Speter
1827251881Speter   ### add information about the need to scan upwards to get a complete
1828251881Speter   ### picture of the state of this node.
1829251881Speter
1830251881Speter   ### add some documentation about OUT parameter values based on STATUS ??
1831251881Speter
1832251881Speter   ### the TEXT_MOD may become an enumerated value at some point to
1833251881Speter   ### indicate different states of knowledge about text modifications.
1834251881Speter   ### for example, an "svn edit" command in the future might set a
1835251881Speter   ### flag indicating administratively-defined modification. and/or we
1836251881Speter   ### might have a status indicating that we saw it was modified while
1837251881Speter   ### performing a filesystem traversal.
1838251881Speter
1839251881Speter   All returned data will be allocated in RESULT_POOL. All temporary
1840251881Speter   allocations will be made in SCRATCH_POOL.
1841251881Speter*/
1842251881Speter/* ### old docco. needs to be incorporated as appropriate. there is
1843251881Speter   ### some pending, potential changes to the definition of this API,
1844251881Speter   ### so not worrying about it just yet.
1845251881Speter
1846251881Speter   ### if the node has not been committed (after adding):
1847251881Speter   ###   revision will be SVN_INVALID_REVNUM
1848251881Speter   ###   repos_* will be NULL
1849251881Speter   ###   changed_rev will be SVN_INVALID_REVNUM
1850251881Speter   ###   changed_date will be 0
1851251881Speter   ###   changed_author will be NULL
1852251881Speter   ###   status will be svn_wc__db_status_added
1853251881Speter   ###   text_mod will be TRUE
1854251881Speter   ###   prop_mod will be TRUE if any props have been set
1855251881Speter   ###   base_shadowed will be FALSE
1856251881Speter
1857251881Speter   ### if the node is not a copy, or a move destination:
1858251881Speter   ###   original_repos_path will be NULL
1859251881Speter   ###   original_root_url will be NULL
1860251881Speter   ###   original_uuid will be NULL
1861251881Speter   ###   original_revision will be SVN_INVALID_REVNUM
1862251881Speter
1863251881Speter   ### note that @a base_shadowed can be derived. if the status specifies
1864251881Speter   ### an add/copy/move *and* there is a corresponding node in BASE, then
1865251881Speter   ### the BASE has been deleted to open the way for this node.
1866251881Speter*/
1867251881Spetersvn_error_t *
1868251881Spetersvn_wc__db_read_info(svn_wc__db_status_t *status,  /* ### derived */
1869251881Speter                     svn_node_kind_t *kind,
1870251881Speter                     svn_revnum_t *revision,
1871251881Speter                     const char **repos_relpath,
1872251881Speter                     const char **repos_root_url,
1873251881Speter                     const char **repos_uuid,
1874251881Speter                     svn_revnum_t *changed_rev,
1875251881Speter                     apr_time_t *changed_date,
1876251881Speter                     const char **changed_author,
1877251881Speter                     svn_depth_t *depth,  /* dirs only */
1878251881Speter                     const svn_checksum_t **checksum, /* files only */
1879251881Speter                     const char **target, /* symlinks only */
1880251881Speter
1881251881Speter                     /* ### the following fields if copied/moved (history) */
1882251881Speter                     const char **original_repos_relpath,
1883251881Speter                     const char **original_root_url,
1884251881Speter                     const char **original_uuid,
1885251881Speter                     svn_revnum_t *original_revision,
1886251881Speter
1887251881Speter                     /* For BASE nodes */
1888251881Speter                     svn_wc__db_lock_t **lock,
1889251881Speter
1890251881Speter                     /* Recorded for files present in the working copy */
1891251881Speter                     svn_filesize_t *recorded_size,
1892251881Speter                     apr_time_t *recorded_time,
1893251881Speter
1894251881Speter                     /* From ACTUAL */
1895251881Speter                     const char **changelist,
1896251881Speter                     svn_boolean_t *conflicted,
1897251881Speter
1898251881Speter                     /* ### the followed are derived fields */
1899251881Speter                     svn_boolean_t *op_root,
1900251881Speter
1901251881Speter                     svn_boolean_t *had_props,
1902251881Speter                     svn_boolean_t *props_mod,
1903251881Speter
1904251881Speter                     svn_boolean_t *have_base,
1905251881Speter                     svn_boolean_t *have_more_work,
1906251881Speter                     svn_boolean_t *have_work,
1907251881Speter
1908251881Speter                     svn_wc__db_t *db,
1909251881Speter                     const char *local_abspath,
1910251881Speter                     apr_pool_t *result_pool,
1911251881Speter                     apr_pool_t *scratch_pool);
1912251881Speter
1913269847Speter/* Structure used as linked list in svn_wc__db_info_t to describe all nodes
1914269847Speter   in this location that were moved to another location */
1915269847Speterstruct svn_wc__db_moved_to_info_t
1916269847Speter{
1917269847Speter  const char *moved_to_abspath;
1918269847Speter  const char *shadow_op_root_abspath;
1919269847Speter
1920269847Speter  struct svn_wc__db_moved_to_info_t *next;
1921269847Speter};
1922269847Speter
1923251881Speter/* Structure returned by svn_wc__db_read_children_info.  Only has the
1924251881Speter   fields needed by status. */
1925251881Speterstruct svn_wc__db_info_t {
1926251881Speter  svn_wc__db_status_t status;
1927251881Speter  svn_node_kind_t kind;
1928251881Speter  svn_revnum_t revnum;
1929251881Speter  const char *repos_relpath;
1930251881Speter  const char *repos_root_url;
1931251881Speter  const char *repos_uuid;
1932251881Speter  svn_revnum_t changed_rev;
1933251881Speter  const char *changed_author;
1934251881Speter  apr_time_t changed_date;
1935251881Speter  svn_depth_t depth;
1936251881Speter
1937251881Speter  svn_filesize_t recorded_size;
1938251881Speter  apr_time_t recorded_time;
1939251881Speter
1940251881Speter  const char *changelist;
1941251881Speter  svn_boolean_t conflicted;
1942251881Speter#ifdef HAVE_SYMLINK
1943251881Speter  svn_boolean_t special;
1944251881Speter#endif
1945251881Speter  svn_boolean_t op_root;
1946251881Speter
1947251881Speter  svn_boolean_t has_checksum;
1948251881Speter  svn_boolean_t copied;
1949251881Speter  svn_boolean_t had_props;
1950251881Speter  svn_boolean_t props_mod;
1951251881Speter
1952251881Speter  svn_boolean_t have_base;
1953251881Speter  svn_boolean_t have_more_work;
1954251881Speter
1955251881Speter  svn_boolean_t locked;     /* WC directory lock */
1956251881Speter  svn_wc__db_lock_t *lock;  /* Repository file lock */
1957251881Speter  svn_boolean_t incomplete; /* TRUE if a working node is incomplete */
1958251881Speter
1959269847Speter  struct svn_wc__db_moved_to_info_t *moved_to; /* A linked list of locations
1960269847Speter                                                 where nodes at this path
1961269847Speter                                                 are moved to. Highest layers
1962269847Speter                                                 first */
1963251881Speter  svn_boolean_t moved_here;     /* Only on op-roots. */
1964251881Speter
1965251881Speter  svn_boolean_t file_external;
1966251881Speter};
1967251881Speter
1968251881Speter/* Return in *NODES a hash mapping name->struct svn_wc__db_info_t for
1969251881Speter   the children of DIR_ABSPATH, and in *CONFLICTS a hash of names in
1970251881Speter   conflict.
1971251881Speter
1972251881Speter   The results include any path that was a child of a deleted directory that
1973251881Speter   existed at LOCAL_ABSPATH, even if that directory is now scheduled to be
1974251881Speter   replaced by the working node at LOCAL_ABSPATH.
1975251881Speter */
1976251881Spetersvn_error_t *
1977251881Spetersvn_wc__db_read_children_info(apr_hash_t **nodes,
1978251881Speter                              apr_hash_t **conflicts,
1979251881Speter                              svn_wc__db_t *db,
1980251881Speter                              const char *dir_abspath,
1981251881Speter                              apr_pool_t *result_pool,
1982251881Speter                              apr_pool_t *scratch_pool);
1983251881Speter
1984269847Speter/* Like svn_wc__db_read_children_info, but only gets an info node for the root
1985269847Speter   element. */
1986269847Spetersvn_error_t *
1987269847Spetersvn_wc__db_read_single_info(const struct svn_wc__db_info_t **info,
1988269847Speter                            svn_wc__db_t *db,
1989269847Speter                            const char *local_abspath,
1990269847Speter                            apr_pool_t *result_pool,
1991269847Speter                            apr_pool_t *scratch_pool);
1992251881Speter
1993251881Speter/* Structure returned by svn_wc__db_read_walker_info.  Only has the
1994251881Speter   fields needed by svn_wc__internal_walk_children(). */
1995251881Speterstruct svn_wc__db_walker_info_t {
1996251881Speter  svn_wc__db_status_t status;
1997251881Speter  svn_node_kind_t kind;
1998251881Speter};
1999251881Speter
2000251881Speter/* When a node is deleted in WORKING, some of its information is no longer
2001251881Speter   available. But in some cases it might still be relevant to obtain this
2002251881Speter   information even when the information isn't stored in the BASE tree.
2003251881Speter
2004251881Speter   This function allows access to that specific information.
2005251881Speter
2006251881Speter   When a node is not deleted, this node returns the same information
2007251881Speter   as svn_wc__db_read_info().
2008251881Speter
2009251881Speter   All output arguments are optional and behave in the same way as when
2010251881Speter   calling svn_wc__db_read_info().
2011251881Speter
2012251881Speter   (All other information (like original_*) can be obtained via other apis).
2013251881Speter
2014251881Speter   *PROPS maps "const char *" names to "const svn_string_t *" values.  If
2015251881Speter   the pristine node is capable of having properties but has none, set
2016251881Speter   *PROPS to an empty hash.  If its status is such that it cannot have
2017251881Speter   properties, set *PROPS to NULL.
2018251881Speter */
2019251881Spetersvn_error_t *
2020251881Spetersvn_wc__db_read_pristine_info(svn_wc__db_status_t *status,
2021251881Speter                              svn_node_kind_t *kind,
2022251881Speter                              svn_revnum_t *changed_rev,
2023251881Speter                              apr_time_t *changed_date,
2024251881Speter                              const char **changed_author,
2025251881Speter                              svn_depth_t *depth,  /* dirs only */
2026251881Speter                              const svn_checksum_t **checksum, /* files only */
2027251881Speter                              const char **target, /* symlinks only */
2028251881Speter                              svn_boolean_t *had_props,
2029251881Speter                              apr_hash_t **props,
2030251881Speter                              svn_wc__db_t *db,
2031251881Speter                              const char *local_abspath,
2032251881Speter                              apr_pool_t *result_pool,
2033251881Speter                              apr_pool_t *scratch_pool);
2034251881Speter
2035251881Speter/* Gets the information required to install a pristine file to the working copy
2036251881Speter
2037251881Speter   Set WCROOT_ABSPATH to the working copy root, SHA1_CHECKSUM to the
2038251881Speter   checksum of the node (a valid reference into the pristine store)
2039251881Speter   and PRISTINE_PROPS to the node's pristine properties (to use for
2040251881Speter   installing the file).
2041251881Speter
2042251881Speter   If WRI_ABSPATH is not NULL, check for information in the working copy
2043251881Speter   identified by WRI_ABSPATH.
2044251881Speter   */
2045251881Spetersvn_error_t *
2046251881Spetersvn_wc__db_read_node_install_info(const char **wcroot_abspath,
2047251881Speter                                  const svn_checksum_t **sha1_checksum,
2048251881Speter                                  apr_hash_t **pristine_props,
2049251881Speter                                  apr_time_t *changed_date,
2050251881Speter                                  svn_wc__db_t *db,
2051251881Speter                                  const char *local_abspath,
2052251881Speter                                  const char *wri_abspath,
2053251881Speter                                  apr_pool_t *result_pool,
2054251881Speter                                  apr_pool_t *scratch_pool);
2055251881Speter
2056251881Speter/* Return in *NODES a hash mapping name->struct svn_wc__db_walker_info_t for
2057251881Speter   the children of DIR_ABSPATH. "name" is the child's name relative to
2058251881Speter   DIR_ABSPATH, not an absolute path. */
2059251881Spetersvn_error_t *
2060251881Spetersvn_wc__db_read_children_walker_info(apr_hash_t **nodes,
2061251881Speter                                     svn_wc__db_t *db,
2062251881Speter                                     const char *dir_abspath,
2063251881Speter                                     apr_pool_t *result_pool,
2064251881Speter                                     apr_pool_t *scratch_pool);
2065251881Speter
2066251881Speter
2067251881Speter/**
2068251881Speter * Set *URL to the corresponding url for LOCAL_ABSPATH.
2069251881Speter * If the node is added, return the url it will have in the repository.
2070251881Speter */
2071251881Spetersvn_error_t *
2072251881Spetersvn_wc__db_read_url(const char **url,
2073251881Speter                    svn_wc__db_t *db,
2074251881Speter                    const char *local_abspath,
2075251881Speter                    apr_pool_t *result_pool,
2076251881Speter                    apr_pool_t *scratch_pool);
2077251881Speter
2078251881Speter
2079251881Speter/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the ACTUAL
2080251881Speter   tree (looking through to the WORKING or BASE tree as required).
2081251881Speter
2082251881Speter   ### *PROPS will be set to NULL in the following situations:
2083251881Speter   ### ... tbd
2084251881Speter
2085251881Speter   PROPS maps "const char *" names to "const svn_string_t *" values.
2086251881Speter   If the node has no properties, set *PROPS to an empty hash.
2087251881Speter   If the node is not present, return an error.
2088251881Speter   Allocate *PROPS and its keys and values in RESULT_POOL.
2089251881Speter*/
2090251881Spetersvn_error_t *
2091251881Spetersvn_wc__db_read_props(apr_hash_t **props,
2092251881Speter                      svn_wc__db_t *db,
2093251881Speter                      const char *local_abspath,
2094251881Speter                      apr_pool_t *result_pool,
2095251881Speter                      apr_pool_t *scratch_pool);
2096251881Speter
2097251881Speter/* Call RECEIVER_FUNC, passing RECEIVER_BATON, an absolute path, and
2098251881Speter * a hash table mapping <tt>char *</tt> names onto svn_string_t *
2099251881Speter * values for any properties of child nodes of LOCAL_ABSPATH (up to DEPTH).
2100251881Speter *
2101251881Speter * If PRISTINE is FALSE, read the properties from the WORKING layer (highest
2102251881Speter * op_depth); if PRISTINE is FALSE, local modifications will be visible.
2103251881Speter */
2104251881Spetersvn_error_t *
2105251881Spetersvn_wc__db_read_props_streamily(svn_wc__db_t *db,
2106251881Speter                                const char *local_abspath,
2107251881Speter                                svn_depth_t depth,
2108251881Speter                                svn_boolean_t pristine,
2109251881Speter                                const apr_array_header_t *changelists,
2110251881Speter                                svn_wc__proplist_receiver_t receiver_func,
2111251881Speter                                void *receiver_baton,
2112251881Speter                                svn_cancel_func_t cancel_func,
2113251881Speter                                void *cancel_baton,
2114251881Speter                                apr_pool_t *scratch_pool);
2115251881Speter
2116251881Speter
2117251881Speter/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the WORKING
2118251881Speter   tree (looking through to the BASE tree as required).
2119251881Speter
2120251881Speter   ### *PROPS will set set to NULL in the following situations:
2121251881Speter   ### ... tbd.  see props.c:svn_wc__get_pristine_props()
2122251881Speter
2123251881Speter   *PROPS maps "const char *" names to "const svn_string_t *" values.
2124251881Speter   If the node has no properties, set *PROPS to an empty hash.
2125251881Speter   If the node is not present, return an error.
2126251881Speter   Allocate *PROPS and its keys and values in RESULT_POOL.
2127251881Speter*/
2128251881Spetersvn_error_t *
2129251881Spetersvn_wc__db_read_pristine_props(apr_hash_t **props,
2130251881Speter                               svn_wc__db_t *db,
2131251881Speter                               const char *local_abspath,
2132251881Speter                               apr_pool_t *result_pool,
2133251881Speter                               apr_pool_t *scratch_pool);
2134251881Speter
2135251881Speter
2136251881Speter/**
2137251881Speter * Set @a *iprops to a depth-first ordered array of
2138251881Speter * #svn_prop_inherited_item_t * structures representing the properties
2139251881Speter * inherited by @a local_abspath from the ACTUAL tree above
2140251881Speter * @a local_abspath (looking through to the WORKING or BASE tree as
2141251881Speter * required), up to and including the root of the working copy and
2142251881Speter * any cached inherited properties inherited by the root.
2143251881Speter *
2144251881Speter * The #svn_prop_inherited_item_t->path_or_url members of the
2145251881Speter * #svn_prop_inherited_item_t * structures in @a *iprops are
2146251881Speter * paths relative to the repository root URL for cached inherited
2147251881Speter * properties and absolute working copy paths otherwise.
2148251881Speter *
2149251881Speter * If ACTUAL_PROPS is not NULL, then set *ACTUAL_PROPS to the actual
2150251881Speter * properties stored on LOCAL_ABSPATH.
2151251881Speter *
2152251881Speter * Allocate @a *iprops in @a result_pool.  Use @a scratch_pool
2153251881Speter * for temporary allocations.
2154251881Speter */
2155251881Spetersvn_error_t *
2156251881Spetersvn_wc__db_read_inherited_props(apr_array_header_t **iprops,
2157251881Speter                                apr_hash_t **actual_props,
2158251881Speter                                svn_wc__db_t *db,
2159251881Speter                                const char *local_abspath,
2160251881Speter                                const char *propname,
2161251881Speter                                apr_pool_t *result_pool,
2162251881Speter                                apr_pool_t *scratch_pool);
2163251881Speter
2164251881Speter/* Read a BASE node's inherited property information.
2165251881Speter
2166251881Speter   Set *IPROPS to to a depth-first ordered array of
2167251881Speter   svn_prop_inherited_item_t * structures representing the cached
2168251881Speter   inherited properties for the BASE node at LOCAL_ABSPATH.
2169251881Speter
2170251881Speter   If no cached properties are found, then set *IPROPS to NULL.
2171251881Speter   If LOCAL_ABSPATH represents the root of the repository, then set
2172251881Speter   *IPROPS to an empty array.
2173251881Speter
2174251881Speter   Allocate *IPROPS in RESULT_POOL, use SCRATCH_POOL for temporary
2175251881Speter   allocations. */
2176251881Spetersvn_error_t *
2177251881Spetersvn_wc__db_read_cached_iprops(apr_array_header_t **iprops,
2178251881Speter                              svn_wc__db_t *db,
2179251881Speter                              const char *local_abspath,
2180251881Speter                              apr_pool_t *result_pool,
2181251881Speter                              apr_pool_t *scratch_pool);
2182251881Speter
2183251881Speter/* Find BASE nodes with cached inherited properties.
2184251881Speter
2185251881Speter   Set *IPROPS_PATHS to a hash mapping const char * absolute working copy
2186251881Speter   paths to the repos_relpath of the path for each path in the working copy
2187251881Speter   at or below LOCAL_ABSPATH, limited by DEPTH, that has cached inherited
2188251881Speter   properties for the BASE node of the path.
2189251881Speter
2190251881Speter   Allocate *IPROP_PATHS in RESULT_POOL.
2191251881Speter   Use SCRATCH_POOL for temporary allocations. */
2192251881Spetersvn_error_t *
2193251881Spetersvn_wc__db_get_children_with_cached_iprops(apr_hash_t **iprop_paths,
2194251881Speter                                           svn_depth_t depth,
2195251881Speter                                           const char *local_abspath,
2196251881Speter                                           svn_wc__db_t *db,
2197251881Speter                                           apr_pool_t *result_pool,
2198251881Speter                                           apr_pool_t *scratch_pool);
2199251881Speter
2200251881Speter/** Obtain a mapping of const char * local_abspaths to const svn_string_t*
2201251881Speter * property values in *VALUES, of all PROPNAME properties on LOCAL_ABSPATH
2202251881Speter * and its descendants.
2203251881Speter *
2204251881Speter * Allocate the result in RESULT_POOL, and perform temporary allocations in
2205251881Speter * SCRATCH_POOL.
2206251881Speter */
2207251881Spetersvn_error_t *
2208251881Spetersvn_wc__db_prop_retrieve_recursive(apr_hash_t **values,
2209251881Speter                                   svn_wc__db_t *db,
2210251881Speter                                   const char *local_abspath,
2211251881Speter                                   const char *propname,
2212251881Speter                                   apr_pool_t *result_pool,
2213251881Speter                                   apr_pool_t *scratch_pool);
2214251881Speter
2215251881Speter/* Set *CHILDREN to a new array of the (const char *) basenames of the
2216251881Speter   immediate children of the working node at LOCAL_ABSPATH in DB.
2217251881Speter
2218251881Speter   Return every path that refers to a child of the working node at
2219251881Speter   LOCAL_ABSPATH.  Do not include a path just because it was a child of a
2220251881Speter   deleted directory that existed at LOCAL_ABSPATH if that directory is now
2221251881Speter   scheduled to be replaced by the working node at LOCAL_ABSPATH.
2222251881Speter
2223251881Speter   Allocate *CHILDREN in RESULT_POOL and do temporary allocations in
2224251881Speter   SCRATCH_POOL.
2225251881Speter
2226251881Speter   ### return some basic info for each child? e.g. kind.
2227251881Speter   ### maybe the data in _read_get_info should be a structure, and this
2228251881Speter   ### can return a struct for each one.
2229251881Speter   ### however: _read_get_info can say "not interested", which isn't the
2230251881Speter   ###   case with a struct. thus, a struct requires fetching and/or
2231251881Speter   ###   computing all info.
2232251881Speter*/
2233251881Spetersvn_error_t *
2234251881Spetersvn_wc__db_read_children_of_working_node(const apr_array_header_t **children,
2235251881Speter                                         svn_wc__db_t *db,
2236251881Speter                                         const char *local_abspath,
2237251881Speter                                         apr_pool_t *result_pool,
2238251881Speter                                         apr_pool_t *scratch_pool);
2239251881Speter
2240251881Speter/* Like svn_wc__db_read_children_of_working_node(), except also include any
2241251881Speter   path that was a child of a deleted directory that existed at
2242251881Speter   LOCAL_ABSPATH, even if that directory is now scheduled to be replaced by
2243251881Speter   the working node at LOCAL_ABSPATH.
2244251881Speter*/
2245251881Spetersvn_error_t *
2246251881Spetersvn_wc__db_read_children(const apr_array_header_t **children,
2247251881Speter                         svn_wc__db_t *db,
2248251881Speter                         const char *local_abspath,
2249251881Speter                         apr_pool_t *result_pool,
2250251881Speter                         apr_pool_t *scratch_pool);
2251251881Speter
2252251881Speter/* Read into *VICTIMS the basenames of the immediate children of
2253251881Speter   LOCAL_ABSPATH in DB that are conflicted.
2254251881Speter
2255251881Speter   In case of tree conflicts a victim doesn't have to be in the
2256251881Speter   working copy.
2257251881Speter
2258251881Speter   Allocate *VICTIMS in RESULT_POOL and do temporary allocations in
2259251881Speter   SCRATCH_POOL */
2260251881Speter/* ### This function will probably be removed. */
2261251881Spetersvn_error_t *
2262251881Spetersvn_wc__db_read_conflict_victims(const apr_array_header_t **victims,
2263251881Speter                                 svn_wc__db_t *db,
2264251881Speter                                 const char *local_abspath,
2265251881Speter                                 apr_pool_t *result_pool,
2266251881Speter                                 apr_pool_t *scratch_pool);
2267251881Speter
2268251881Speter/* Read into *MARKER_FILES the absolute paths of the marker files
2269251881Speter   of conflicts stored on LOCAL_ABSPATH and its immediate children in DB.
2270251881Speter   The on-disk files may have been deleted by the user.
2271251881Speter
2272251881Speter   Allocate *MARKER_FILES in RESULT_POOL and do temporary allocations
2273251881Speter   in SCRATCH_POOL */
2274251881Spetersvn_error_t *
2275251881Spetersvn_wc__db_get_conflict_marker_files(apr_hash_t **markers,
2276251881Speter                                     svn_wc__db_t *db,
2277251881Speter                                     const char *local_abspath,
2278251881Speter                                     apr_pool_t *result_pool,
2279251881Speter                                     apr_pool_t *scratch_pool);
2280251881Speter
2281251881Speter/* Read the conflict information recorded on LOCAL_ABSPATH in *CONFLICT,
2282251881Speter   an editable conflict skel.
2283251881Speter
2284251881Speter   If the node exists, but does not have a conflict set *CONFLICT to NULL,
2285251881Speter   otherwise return a SVN_ERR_WC_PATH_NOT_FOUND error.
2286251881Speter
2287251881Speter   Allocate *CONFLICTS in RESULT_POOL and do temporary allocations in
2288251881Speter   SCRATCH_POOL */
2289251881Spetersvn_error_t *
2290251881Spetersvn_wc__db_read_conflict(svn_skel_t **conflict,
2291251881Speter                         svn_wc__db_t *db,
2292251881Speter                         const char *local_abspath,
2293251881Speter                         apr_pool_t *result_pool,
2294251881Speter                         apr_pool_t *scratch_pool);
2295251881Speter
2296251881Speter
2297251881Speter/* Return the kind of the node in DB at LOCAL_ABSPATH. The WORKING tree will
2298251881Speter   be examined first, then the BASE tree. If the node is not present in either
2299251881Speter   tree and ALLOW_MISSING is TRUE, then svn_node_unknown is returned.
2300251881Speter   If the node is missing and ALLOW_MISSING is FALSE, then it will return
2301251881Speter   SVN_ERR_WC_PATH_NOT_FOUND.
2302251881Speter
2303251881Speter   The SHOW_HIDDEN and SHOW_DELETED flags report certain states as kind none.
2304251881Speter
2305251881Speter   When nodes have certain statee they are only reported when:
2306251881Speter      svn_wc__db_status_not_present         when show_hidden && show_deleted
2307251881Speter
2308251881Speter      svn_wc__db_status_excluded            when show_hidden
2309251881Speter      svn_wc__db_status_server_excluded     when show_hidden
2310251881Speter
2311251881Speter      svn_wc__db_status_deleted             when show_deleted
2312251881Speter
2313251881Speter   In other cases these nodes are reported with *KIND as svn_node_none.
2314251881Speter   (See also svn_wc_read_kind2()'s documentation)
2315251881Speter
2316251881Speter   Uses SCRATCH_POOL for temporary allocations.  */
2317251881Spetersvn_error_t *
2318251881Spetersvn_wc__db_read_kind(svn_node_kind_t *kind,
2319251881Speter                     svn_wc__db_t *db,
2320251881Speter                     const char *local_abspath,
2321251881Speter                     svn_boolean_t allow_missing,
2322251881Speter                     svn_boolean_t show_deleted,
2323251881Speter                     svn_boolean_t show_hidden,
2324251881Speter                     apr_pool_t *scratch_pool);
2325251881Speter
2326251881Speter
2327251881Speter/* An analog to svn_wc__entry_is_hidden().  Set *HIDDEN to TRUE if
2328251881Speter   LOCAL_ABSPATH in DB "is not present, and I haven't scheduled something
2329251881Speter   over the top of it." */
2330251881Spetersvn_error_t *
2331251881Spetersvn_wc__db_node_hidden(svn_boolean_t *hidden,
2332251881Speter                       svn_wc__db_t *db,
2333251881Speter                       const char *local_abspath,
2334251881Speter                       apr_pool_t *scratch_pool);
2335251881Speter
2336251881Speter/* Checks if a node replaces a node in a different layer. Also check if it
2337251881Speter   replaces a BASE (op_depth 0) node or just a node in a higher layer (a copy).
2338251881Speter   Finally check if this is the root of the replacement, or if the replacement
2339251881Speter   is initiated by the parent node.
2340251881Speter
2341251881Speter   IS_REPLACE_ROOT (if not NULL) is set to TRUE if the node is the root of a
2342251881Speter   replacement; otherwise to FALSE.
2343251881Speter
2344251881Speter   BASE_REPLACE (if not NULL) is set to TRUE if the node directly or indirectly
2345251881Speter   replaces a node in the BASE tree; otherwise to FALSE.
2346251881Speter
2347251881Speter   IS_REPLACE (if not NULL) is set to TRUE if the node directly replaces a node
2348251881Speter   in a lower layer; otherwise to FALSE.
2349251881Speter */
2350251881Spetersvn_error_t *
2351251881Spetersvn_wc__db_node_check_replace(svn_boolean_t *is_replace_root,
2352251881Speter                              svn_boolean_t *base_replace,
2353251881Speter                              svn_boolean_t *is_replace,
2354251881Speter                              svn_wc__db_t *db,
2355251881Speter                              const char *local_abspath,
2356251881Speter                              apr_pool_t *scratch_pool);
2357251881Speter
2358251881Speter/* ### changelists. return an array, or an iterator interface? how big
2359251881Speter   ### are these things? are we okay with an in-memory array? examine other
2360251881Speter   ### changelist usage -- we may already assume the list fits in memory.
2361251881Speter*/
2362251881Speter
2363251881Speter/* The DB-private version of svn_wc__is_wcroot(), which see.
2364251881Speter */
2365251881Spetersvn_error_t *
2366251881Spetersvn_wc__db_is_wcroot(svn_boolean_t *is_wcroot,
2367251881Speter                     svn_wc__db_t *db,
2368251881Speter                     const char *local_abspath,
2369251881Speter                     apr_pool_t *scratch_pool);
2370251881Speter
2371251881Speter/* Check whether a node is a working copy root and/or switched.
2372251881Speter
2373251881Speter   If LOCAL_ABSPATH is the root of a working copy, set *IS_WC_ROOT to TRUE,
2374251881Speter   otherwise to FALSE.
2375251881Speter
2376251881Speter   If LOCAL_ABSPATH is switched against its parent in the same working copy
2377251881Speter   set *IS_SWITCHED to TRUE, otherwise to FALSE.
2378251881Speter
2379251881Speter   If KIND is not null, set *KIND to the node type of LOCAL_ABSPATH.
2380251881Speter
2381251881Speter   Any of the output arguments can be null to specify that the result is not
2382251881Speter   interesting to the caller.
2383251881Speter
2384251881Speter   Use SCRATCH_POOL for temporary allocations.
2385251881Speter */
2386251881Spetersvn_error_t *
2387251881Spetersvn_wc__db_is_switched(svn_boolean_t *is_wcroot,
2388251881Speter                       svn_boolean_t *is_switched,
2389251881Speter                       svn_node_kind_t *kind,
2390251881Speter                       svn_wc__db_t *db,
2391251881Speter                       const char *local_abspath,
2392251881Speter                       apr_pool_t *scratch_pool);
2393251881Speter
2394251881Speter
2395251881Speter/* @} */
2396251881Speter
2397251881Speter
2398251881Speter/* @defgroup svn_wc__db_global  Operations that alter multiple trees
2399251881Speter   @{
2400251881Speter*/
2401251881Speter
2402251881Speter/* Associate LOCAL_DIR_ABSPATH, and all its children with the repository at
2403251881Speter   at REPOS_ROOT_URL.  The relative path to the repos root will not change,
2404251881Speter   just the repository root.  The repos uuid will also remain the same.
2405251881Speter   This also updates any locks which may exist for the node, as well as any
2406251881Speter   copyfrom repository information.  Finally, the DAV cache (aka
2407251881Speter   "wcprops") will be reset for affected entries.
2408251881Speter
2409251881Speter   Use SCRATCH_POOL for any temporary allocations.
2410251881Speter
2411251881Speter   ### local_dir_abspath "should be" the wcroot or a switch root. all URLs
2412251881Speter   ### under this directory (depth=infinity) will be rewritten.
2413251881Speter
2414251881Speter   ### This API had a depth parameter, which was removed, should it be
2415251881Speter   ### resurrected?  What's the purpose if we claim relocate is infinitely
2416251881Speter   ### recursive?
2417251881Speter
2418251881Speter   ### Assuming the future ability to copy across repositories, should we
2419251881Speter   ### refrain from resetting the copyfrom information in this operation?
2420251881Speter*/
2421251881Spetersvn_error_t *
2422251881Spetersvn_wc__db_global_relocate(svn_wc__db_t *db,
2423251881Speter                           const char *local_dir_abspath,
2424251881Speter                           const char *repos_root_url,
2425251881Speter                           apr_pool_t *scratch_pool);
2426251881Speter
2427251881Speter
2428251881Speter/* ### docco
2429251881Speter
2430251881Speter   ### collapse the WORKING and ACTUAL tree changes down into BASE, called
2431251881Speter       for each committed node.
2432251881Speter
2433251881Speter   NEW_REVISION must be the revision number of the revision created by
2434251881Speter   the commit. It will become the BASE node's 'revnum' and 'changed_rev'
2435251881Speter   values in the BASE_NODE table.
2436251881Speter
2437251881Speter   CHANGED_REVISION is the new 'last changed' revision. If the node is
2438251881Speter   modified its value is equivalent to NEW_REVISION, but in case of a
2439251881Speter   descendant of a copy/move it can be an older revision.
2440251881Speter
2441251881Speter   CHANGED_DATE is the (server-side) date of CHANGED_REVISION. It may be 0 if
2442251881Speter   the revprop is missing on the revision.
2443251881Speter
2444251881Speter   CHANGED_AUTHOR is the (server-side) author of CHANGED_REVISION. It may be
2445251881Speter   NULL if the revprop is missing on the revision.
2446251881Speter
2447251881Speter   One or both of NEW_CHECKSUM and NEW_CHILDREN should be NULL. For new:
2448251881Speter     files: NEW_CHILDREN should be NULL
2449251881Speter     dirs: NEW_CHECKSUM should be NULL
2450251881Speter     symlinks: both should be NULL
2451251881Speter
2452251881Speter   WORK_ITEMS will be place into the work queue.
2453251881Speter*/
2454251881Spetersvn_error_t *
2455251881Spetersvn_wc__db_global_commit(svn_wc__db_t *db,
2456251881Speter                         const char *local_abspath,
2457251881Speter                         svn_revnum_t new_revision,
2458251881Speter                         svn_revnum_t changed_revision,
2459251881Speter                         apr_time_t changed_date,
2460251881Speter                         const char *changed_author,
2461251881Speter                         const svn_checksum_t *new_checksum,
2462251881Speter                         const apr_array_header_t *new_children,
2463251881Speter                         apr_hash_t *new_dav_cache,
2464251881Speter                         svn_boolean_t keep_changelist,
2465251881Speter                         svn_boolean_t no_unlock,
2466251881Speter                         const svn_skel_t *work_items,
2467251881Speter                         apr_pool_t *scratch_pool);
2468251881Speter
2469251881Speter
2470251881Speter/* ### docco
2471251881Speter
2472251881Speter   Perform an "update" operation at this node. It will create/modify a BASE
2473251881Speter   node, and possibly update the ACTUAL tree's node (e.g put the node into
2474251881Speter   a conflicted state).
2475251881Speter
2476251881Speter   ### there may be cases where we need to tweak an existing WORKING node
2477251881Speter
2478251881Speter   ### this operations on a single node, but may affect children
2479251881Speter
2480251881Speter   ### the repository cannot be changed with this function, but a "switch"
2481251881Speter   ### (aka changing repos_relpath) is possible
2482251881Speter
2483251881Speter   ### one of NEW_CHILDREN, NEW_CHECKSUM, or NEW_TARGET must be provided.
2484251881Speter   ### the other two values must be NULL.
2485251881Speter   ### should this be broken out into an update_(directory|file|symlink) ?
2486251881Speter
2487251881Speter   ### how does this differ from base_add_*? just the CONFLICT param.
2488251881Speter   ### the WORK_ITEMS param is new here, but the base_add_* functions
2489251881Speter   ### should probably grow that. should we instead just (re)use base_add
2490251881Speter   ### rather than grow a new function?
2491251881Speter
2492251881Speter   ### this does not allow a change of depth
2493251881Speter
2494251881Speter   ### we do not update a file's TRANSLATED_SIZE here. at some future point,
2495251881Speter   ### when the file is installed, then a TRANSLATED_SIZE will be set.
2496251881Speter*/
2497251881Spetersvn_error_t *
2498251881Spetersvn_wc__db_global_update(svn_wc__db_t *db,
2499251881Speter                         const char *local_abspath,
2500251881Speter                         svn_node_kind_t new_kind,
2501251881Speter                         const char *new_repos_relpath,
2502251881Speter                         svn_revnum_t new_revision,
2503251881Speter                         const apr_hash_t *new_props,
2504251881Speter                         svn_revnum_t new_changed_rev,
2505251881Speter                         apr_time_t new_changed_date,
2506251881Speter                         const char *new_changed_author,
2507251881Speter                         const apr_array_header_t *new_children,
2508251881Speter                         const svn_checksum_t *new_checksum,
2509251881Speter                         const char *new_target,
2510251881Speter                         const apr_hash_t *new_dav_cache,
2511251881Speter                         const svn_skel_t *conflict,
2512251881Speter                         const svn_skel_t *work_items,
2513251881Speter                         apr_pool_t *scratch_pool);
2514251881Speter
2515251881Speter
2516251881Speter/* Modify the entry of working copy LOCAL_ABSPATH, presumably after an update
2517251881Speter   of depth DEPTH completes.  If LOCAL_ABSPATH doesn't exist, this routine
2518251881Speter   does nothing.
2519251881Speter
2520251881Speter   Set the node's repository relpath, repository root, repository uuid and
2521251881Speter   revision to NEW_REPOS_RELPATH, NEW_REPOS_ROOT and NEW_REPOS_UUID.  If
2522251881Speter   NEW_REPOS_RELPATH is null, the repository location is untouched; if
2523251881Speter   NEW_REVISION in invalid, the working revision field is untouched.
2524251881Speter   The modifications are mutually exclusive.  If NEW_REPOS_ROOT is non-NULL,
2525251881Speter   set the repository root of the entry to NEW_REPOS_ROOT.
2526251881Speter
2527251881Speter   If LOCAL_ABSPATH is a directory, then, walk entries below LOCAL_ABSPATH
2528251881Speter   according to DEPTH thusly:
2529251881Speter
2530251881Speter   If DEPTH is svn_depth_infinity, perform the following actions on
2531251881Speter   every entry below PATH; if svn_depth_immediates, svn_depth_files,
2532251881Speter   or svn_depth_empty, perform them only on LOCAL_ABSPATH.
2533251881Speter
2534251881Speter   If NEW_REVISION is valid, then tweak every entry to have this new
2535251881Speter   working revision (excluding files that are scheduled for addition
2536251881Speter   or replacement).  Likewise, if BASE_URL is non-null, then rewrite
2537251881Speter   all urls to be "telescoping" children of the base_url.
2538251881Speter
2539251881Speter   EXCLUDE_RELPATHS is a hash containing const char *local_relpath.  Nodes
2540251881Speter   for pathnames contained in EXCLUDE_RELPATHS are not touched by this
2541251881Speter   function.  These pathnames should be paths relative to the wcroot.
2542251881Speter
2543251881Speter   If WCROOT_IPROPS is not NULL it is a hash mapping const char * absolute
2544251881Speter   working copy paths to depth-first ordered arrays of
2545251881Speter   svn_prop_inherited_item_t * structures.  If LOCAL_ABSPATH exists in
2546251881Speter   WCROOT_IPROPS, then set the hashed value as the node's inherited
2547251881Speter   properties.
2548251881Speter*/
2549251881Spetersvn_error_t *
2550251881Spetersvn_wc__db_op_bump_revisions_post_update(svn_wc__db_t *db,
2551251881Speter                                         const char *local_abspath,
2552251881Speter                                         svn_depth_t depth,
2553251881Speter                                         const char *new_repos_relpath,
2554251881Speter                                         const char *new_repos_root_url,
2555251881Speter                                         const char *new_repos_uuid,
2556251881Speter                                         svn_revnum_t new_revision,
2557251881Speter                                         apr_hash_t *exclude_relpaths,
2558251881Speter                                         apr_hash_t *wcroot_iprops,
2559251881Speter                                         svn_wc_notify_func2_t notify_func,
2560251881Speter                                         void *notify_baton,
2561251881Speter                                         apr_pool_t *scratch_pool);
2562251881Speter
2563251881Speter
2564251881Speter/* Record the RECORDED_SIZE and RECORDED_TIME for a versioned node.
2565251881Speter
2566251881Speter   This function will record the information within the WORKING node,
2567251881Speter   if present, or within the BASE tree. If neither node is present, then
2568251881Speter   SVN_ERR_WC_PATH_NOT_FOUND will be returned.
2569251881Speter
2570251881Speter   RECORDED_SIZE may be SVN_INVALID_FILESIZE, which will be recorded
2571251881Speter   as such, implying "unknown size".
2572251881Speter
2573251881Speter   RECORDED_TIME may be 0, which will be recorded as such, implying
2574251881Speter   "unknown last mod time".
2575251881Speter*/
2576251881Spetersvn_error_t *
2577251881Spetersvn_wc__db_global_record_fileinfo(svn_wc__db_t *db,
2578251881Speter                                  const char *local_abspath,
2579251881Speter                                  svn_filesize_t recorded_size,
2580251881Speter                                  apr_time_t recorded_time,
2581251881Speter                                  apr_pool_t *scratch_pool);
2582251881Speter
2583251881Speter
2584251881Speter/* ### post-commit handling.
2585251881Speter   ### maybe multiple phases?
2586251881Speter   ### 1) mark a changelist as being-committed
2587251881Speter   ### 2) collect ACTUAL content, store for future use as TEXTBASE
2588251881Speter   ### 3) caller performs commit
2589251881Speter   ### 4) post-commit, integrate changelist into BASE
2590251881Speter*/
2591251881Speter
2592251881Speter
2593251881Speter/* @} */
2594251881Speter
2595251881Speter
2596251881Speter/* @defgroup svn_wc__db_lock  Function to manage the LOCKS table.
2597251881Speter   @{
2598251881Speter*/
2599251881Speter
2600251881Speter/* Add or replace LOCK for LOCAL_ABSPATH to DB.  */
2601251881Spetersvn_error_t *
2602251881Spetersvn_wc__db_lock_add(svn_wc__db_t *db,
2603251881Speter                    const char *local_abspath,
2604251881Speter                    const svn_wc__db_lock_t *lock,
2605251881Speter                    apr_pool_t *scratch_pool);
2606251881Speter
2607251881Speter
2608251881Speter/* Remove any lock for LOCAL_ABSPATH in DB.  */
2609251881Spetersvn_error_t *
2610251881Spetersvn_wc__db_lock_remove(svn_wc__db_t *db,
2611251881Speter                       const char *local_abspath,
2612251881Speter                       apr_pool_t *scratch_pool);
2613251881Speter
2614251881Speter
2615251881Speter/* @} */
2616251881Speter
2617251881Speter
2618251881Speter/* @defgroup svn_wc__db_scan  Functions to scan up a tree for further data.
2619251881Speter   @{
2620251881Speter*/
2621251881Speter
2622251881Speter/* Read a BASE node's repository information.
2623251881Speter
2624251881Speter   For the BASE node implied by LOCAL_ABSPATH, its location in the repository
2625251881Speter   returned in *REPOS_ROOT_URL and *REPOS_UUID will be returned in
2626251881Speter   *REPOS_RELPATH. Any of the OUT parameters may be NULL, indicating no
2627251881Speter   interest in that piece of information.
2628251881Speter
2629251881Speter   All returned data will be allocated in RESULT_POOL. All temporary
2630251881Speter   allocations will be made in SCRATCH_POOL.
2631251881Speter
2632251881Speter   ### Either delete this function and use _base_get_info instead, or
2633251881Speter   ### add a 'revision' output to make a complete repository node location
2634251881Speter   ### and rename to not say 'scan', because it doesn't.
2635251881Speter*/
2636251881Spetersvn_error_t *
2637251881Spetersvn_wc__db_scan_base_repos(const char **repos_relpath,
2638251881Speter                           const char **repos_root_url,
2639251881Speter                           const char **repos_uuid,
2640251881Speter                           svn_wc__db_t *db,
2641251881Speter                           const char *local_abspath,
2642251881Speter                           apr_pool_t *result_pool,
2643251881Speter                           apr_pool_t *scratch_pool);
2644251881Speter
2645251881Speter
2646251881Speter/* Scan upwards for information about a known addition to the WORKING tree.
2647251881Speter
2648251881Speter   IFF a node's status as returned by svn_wc__db_read_info() is
2649251881Speter   svn_wc__db_status_added (NOT obstructed_add!), then this function
2650251881Speter   returns a refined status in *STATUS, which is one of:
2651251881Speter
2652251881Speter     svn_wc__db_status_added -- this NODE is a simple add without history.
2653251881Speter       OP_ROOT_ABSPATH will be set to the topmost node in the added subtree
2654251881Speter       (implying its parent will be an unshadowed BASE node). The REPOS_*
2655251881Speter       values will be implied by that ancestor BASE node and this node's
2656251881Speter       position in the added subtree. ORIGINAL_* will be set to their
2657251881Speter       NULL values (and SVN_INVALID_REVNUM for ORIGINAL_REVISION).
2658251881Speter
2659251881Speter     svn_wc__db_status_copied -- this NODE is the root or child of a copy.
2660251881Speter       The root of the copy will be stored in OP_ROOT_ABSPATH. Note that
2661251881Speter       the parent of the operation root could be another WORKING node (from
2662251881Speter       an add, copy, or move). The REPOS_* values will be implied by the
2663251881Speter       ancestor unshadowed BASE node. ORIGINAL_* will indicate the source
2664251881Speter       of the copy.
2665251881Speter
2666251881Speter     svn_wc__db_status_incomplete -- this NODE is copied but incomplete.
2667251881Speter
2668251881Speter     svn_wc__db_status_moved_here -- this NODE arrived as a result of a move.
2669251881Speter       The root of the moved nodes will be stored in OP_ROOT_ABSPATH.
2670251881Speter       Similar to the copied state, its parent may be a WORKING node or a
2671251881Speter       BASE node. And again, the REPOS_* values are implied by this node's
2672251881Speter       position in the subtree under the ancestor unshadowed BASE node.
2673251881Speter       ORIGINAL_* will indicate the source of the move.
2674251881Speter
2675251881Speter   All OUT parameters may be NULL to indicate a lack of interest in
2676251881Speter   that piece of information.
2677251881Speter
2678251881Speter   STATUS, OP_ROOT_ABSPATH, and REPOS_* will always be assigned a value
2679251881Speter   if that information is requested (and assuming a successful return).
2680251881Speter
2681251881Speter   ORIGINAL_REPOS_RELPATH will refer to the *root* of the operation. It
2682251881Speter   does *not* correspond to the node given by LOCAL_ABSPATH. The caller
2683251881Speter   can use the suffix on LOCAL_ABSPATH (relative to OP_ROOT_ABSPATH) in
2684251881Speter   order to compute the source node which corresponds to LOCAL_ABSPATH.
2685251881Speter
2686251881Speter   If the node given by LOCAL_ABSPATH does not have changes recorded in
2687251881Speter   the WORKING tree, then SVN_ERR_WC_PATH_NOT_FOUND is returned. If it
2688251881Speter   doesn't have an "added" status, then SVN_ERR_WC_PATH_UNEXPECTED_STATUS
2689251881Speter   will be returned.
2690251881Speter
2691251881Speter   All returned data will be allocated in RESULT_POOL. All temporary
2692251881Speter   allocations will be made in SCRATCH_POOL.
2693251881Speter*/
2694251881Spetersvn_error_t *
2695251881Spetersvn_wc__db_scan_addition(svn_wc__db_status_t *status,
2696251881Speter                         const char **op_root_abspath,
2697251881Speter                         const char **repos_relpath,
2698251881Speter                         const char **repos_root_url,
2699251881Speter                         const char **repos_uuid,
2700251881Speter                         const char **original_repos_relpath,
2701251881Speter                         const char **original_root_url,
2702251881Speter                         const char **original_uuid,
2703251881Speter                         svn_revnum_t *original_revision,
2704251881Speter                         svn_wc__db_t *db,
2705251881Speter                         const char *local_abspath,
2706251881Speter                         apr_pool_t *result_pool,
2707251881Speter                         apr_pool_t *scratch_pool);
2708251881Speter
2709251881Speter/* Scan the working copy for move information of the node LOCAL_ABSPATH.
2710251881Speter * If LOCAL_ABSPATH return a SVN_ERR_WC_PATH_UNEXPECTED_STATUS error.
2711251881Speter *
2712251881Speter * If not NULL *MOVED_FROM_ABSPATH will be set to the previous location
2713251881Speter * of LOCAL_ABSPATH, before it or an ancestror was moved.
2714251881Speter *
2715251881Speter * If not NULL *OP_ROOT_ABSPATH will be set to the new location of the
2716251881Speter * path that was actually moved
2717251881Speter *
2718251881Speter * If not NULL *OP_ROOT_MOVED_FROM_ABSPATH will be set to the old location
2719251881Speter * of the path that was actually moved.
2720251881Speter *
2721251881Speter * If not NULL *MOVED_FROM_DELETE_ABSPATH will be set to the ancestor of the
2722251881Speter * moved from location that deletes the original location
2723251881Speter *
2724251881Speter * Given a working copy
2725251881Speter * A/B/C
2726251881Speter * svn mv A/B D
2727251881Speter * svn rm A
2728251881Speter *
2729251881Speter * You can call this function on D and D/C. When called on D/C all output
2730251881Speter *              MOVED_FROM_ABSPATH will be A/B/C
2731251881Speter *              OP_ROOT_ABSPATH will be D
2732251881Speter *              OP_ROOT_MOVED_FROM_ABSPATH will be A/B
2733251881Speter *              MOVED_FROM_DELETE_ABSPATH will be A
2734251881Speter */
2735251881Spetersvn_error_t *
2736251881Spetersvn_wc__db_scan_moved(const char **moved_from_abspath,
2737251881Speter                      const char **op_root_abspath,
2738251881Speter                      const char **op_root_moved_from_abspath,
2739251881Speter                      const char **moved_from_delete_abspath,
2740251881Speter                      svn_wc__db_t *db,
2741251881Speter                      const char *local_abspath,
2742251881Speter                      apr_pool_t *result_pool,
2743251881Speter                      apr_pool_t *scratch_pool);
2744251881Speter
2745251881Speter/* Scan upwards for additional information about a deleted node.
2746251881Speter
2747251881Speter   When a deleted node is discovered in the WORKING tree, the situation
2748251881Speter   may be quite complex. This function will provide the information to
2749251881Speter   resolve the circumstances of the deletion.
2750251881Speter
2751251881Speter   For discussion purposes, we will start with the most complex example
2752251881Speter   and then demonstrate simplified examples. Consider node B/W/D/N has been
2753251881Speter   found as deleted. B is an unmodified directory (thus, only in BASE). W is
2754251881Speter   "replacement" content that exists in WORKING, shadowing a similar B/W
2755251881Speter   directory in BASE. D is a deleted subtree in the WORKING tree, and N is
2756251881Speter   the deleted node.
2757251881Speter
2758251881Speter   In this example, BASE_DEL_ABSPATH will bet set to B/W. That is the root of
2759251881Speter   the BASE tree (implicitly) deleted by the replacement. WORK_DEL_ABSPATH
2760251881Speter   will be set to the subtree deleted within the replacement; in this case,
2761251881Speter   B/W/D. No move-away took place, so MOVED_TO_ABSPATH is set to NULL.
2762251881Speter
2763251881Speter   In another scenario, B/W was moved-away before W was put into the WORKING
2764251881Speter   tree through an add/copy/move-here. MOVED_TO_ABSPATH will indicate where
2765251881Speter   B/W was moved to. Note that further operations may have been performed
2766251881Speter   post-move, but that is not known or reported by this function.
2767251881Speter
2768251881Speter   If BASE does not have a B/W, then the WORKING B/W is not a replacement,
2769251881Speter   but a simple add/copy/move-here. BASE_DEL_ABSPATH will be set to NULL.
2770251881Speter
2771251881Speter   If B/W/D does not exist in the WORKING tree (we're only talking about a
2772251881Speter   deletion of nodes of the BASE tree), then deleting B/W/D would have marked
2773251881Speter   the subtree for deletion. BASE_DEL_ABSPATH will refer to B/W/D,
2774251881Speter   MOVED_TO_ABSPATH will be NULL, and WORK_DEL_ABSPATH will be NULL.
2775251881Speter
2776251881Speter   If the BASE node B/W/D was moved instead of deleted, then MOVED_TO_ABSPATH
2777251881Speter   would indicate the target location (and other OUT values as above).
2778251881Speter
2779251881Speter   When the user deletes B/W/D from the WORKING tree, there are a few
2780251881Speter   additional considerations. If B/W is a simple addition (not a copy or
2781251881Speter   a move-here), then the deletion will simply remove the nodes from WORKING
2782251881Speter   and possibly leave behind "base-delete" markers in the WORKING tree.
2783251881Speter   If the source is a copy/moved-here, then the nodes are replaced with
2784251881Speter   deletion markers.
2785251881Speter
2786251881Speter   If the user moves-away B/W/D from the WORKING tree, then behavior is
2787251881Speter   again dependent upon the origination of B/W. For a plain add, the nodes
2788251881Speter   simply move to the destination; this means that B/W/D ceases to be a
2789251881Speter   node and so cannot be scanned. For a copy, a deletion is made at B/W/D,
2790251881Speter   and a new copy (of a subtree of the original source) is made at the
2791251881Speter   destination. For a move-here, a deletion is made, and a copy is made at
2792251881Speter   the destination (we do not track multiple moves; the source is moved to
2793251881Speter   B/W, then B/W/D is deleted; then a copy is made at the destination;
2794251881Speter   however, note the double-move could have been performed by moving the
2795251881Speter   subtree first, then moving the source to B/W).
2796251881Speter
2797251881Speter   There are three further considerations when resolving a deleted node:
2798251881Speter
2799251881Speter     If the BASE B/W/D was deleted explicitly *and* B/W is a replacement,
2800251881Speter     then the explicit deletion is subsumed by the implicit deletion that
2801251881Speter     occurred with the B/W replacement. Thus, BASE_DEL_ABSPATH will point
2802251881Speter     to B/W as the root of the BASE deletion. IOW, we can detect the
2803251881Speter     explicit move-away, but not an explicit deletion.
2804251881Speter
2805251881Speter     If B/W/D/N refers to a node present in the BASE tree, and B/W was
2806251881Speter     replaced by a shallow subtree, then it is possible for N to be
2807251881Speter     reported as deleted (from BASE) yet no deletions occurred in the
2808251881Speter     WORKING tree above N. Thus, WORK_DEL_ABSPATH will be set to NULL.
2809251881Speter
2810251881Speter
2811251881Speter   Summary of OUT parameters:
2812251881Speter
2813251881Speter   BASE_DEL_ABSPATH will specify the nearest ancestor of the explicit or
2814251881Speter   implicit deletion (if any) that applies to the BASE tree.
2815251881Speter
2816251881Speter   WORK_DEL_ABSPATH will specify the root of a deleted subtree within
2817251881Speter   the WORKING tree (note there is no concept of layered delete operations
2818251881Speter   in WORKING, so there is only one deletion root in the ancestry).
2819251881Speter
2820251881Speter   MOVED_TO_ABSPATH will specify the path where this node was moved to
2821251881Speter   if the node has moved-away.
2822251881Speter
2823251881Speter   If the node was moved-away, MOVED_TO_OP_ROOT_ABSPATH will specify the
2824251881Speter   target path of the root of the move operation.  If LOCAL_ABSPATH itself
2825251881Speter   is the source path of the root of the move operation, then
2826251881Speter   MOVED_TO_OP_ROOT_ABSPATH equals MOVED_TO_ABSPATH.
2827251881Speter
2828251881Speter   All OUT parameters may be set to NULL to indicate a lack of interest in
2829251881Speter   that piece of information.
2830251881Speter
2831251881Speter   If the node given by LOCAL_ABSPATH does not exist, then
2832251881Speter   SVN_ERR_WC_PATH_NOT_FOUND is returned. If it doesn't have a "deleted"
2833251881Speter   status, then SVN_ERR_WC_PATH_UNEXPECTED_STATUS will be returned.
2834251881Speter
2835251881Speter   All returned data will be allocated in RESULT_POOL. All temporary
2836251881Speter   allocations will be made in SCRATCH_POOL.
2837251881Speter*/
2838251881Spetersvn_error_t *
2839251881Spetersvn_wc__db_scan_deletion(const char **base_del_abspath,
2840251881Speter                         const char **moved_to_abspath,
2841251881Speter                         const char **work_del_abspath,
2842251881Speter                         const char **moved_to_op_root_abspath,
2843251881Speter                         svn_wc__db_t *db,
2844251881Speter                         const char *local_abspath,
2845251881Speter                         apr_pool_t *result_pool,
2846251881Speter                         apr_pool_t *scratch_pool);
2847251881Speter
2848251881Speter
2849251881Speter/* @} */
2850251881Speter
2851251881Speter
2852251881Speter/* @defgroup svn_wc__db_upgrade  Functions for upgrading a working copy.
2853251881Speter   @{
2854251881Speter*/
2855251881Speter
2856262253Speter/* Installs or updates Sqlite schema statistics for the current (aka latest)
2857262253Speter   working copy schema.
2858262253Speter
2859262253Speter   This function should be called once on initializing the database and after
2860262253Speter   an schema update completes */
2861262253Spetersvn_error_t *
2862262253Spetersvn_wc__db_install_schema_statistics(svn_sqlite__db_t *sdb,
2863262253Speter                                     apr_pool_t *scratch_pool);
2864262253Speter
2865262253Speter
2866251881Speter/* Create a new wc.db file for LOCAL_DIR_ABSPATH, which is going to be a
2867251881Speter   working copy for the repository REPOS_ROOT_URL with uuid REPOS_UUID.
2868251881Speter   Return the raw sqlite handle, repository id and working copy id
2869251881Speter   and store the database in WC_DB.
2870251881Speter
2871251881Speter   Perform temporary allocations in SCRATCH_POOL. */
2872251881Spetersvn_error_t *
2873251881Spetersvn_wc__db_upgrade_begin(svn_sqlite__db_t **sdb,
2874251881Speter                         apr_int64_t *repos_id,
2875251881Speter                         apr_int64_t *wc_id,
2876251881Speter                         svn_wc__db_t *wc_db,
2877251881Speter                         const char *local_dir_abspath,
2878251881Speter                         const char *repos_root_url,
2879251881Speter                         const char *repos_uuid,
2880251881Speter                         apr_pool_t *scratch_pool);
2881251881Speter
2882251881Speter
2883251881Spetersvn_error_t *
2884251881Spetersvn_wc__db_upgrade_apply_dav_cache(svn_sqlite__db_t *sdb,
2885251881Speter                                   const char *dir_relpath,
2886251881Speter                                   apr_hash_t *cache_values,
2887251881Speter                                   apr_pool_t *scratch_pool);
2888251881Speter
2889251881Speter
2890251881Speter/* ### need much more docco
2891251881Speter
2892251881Speter   ### this function should be called within a sqlite transaction. it makes
2893251881Speter   ### assumptions around this fact.
2894251881Speter
2895251881Speter   Apply the various sets of properties to the database nodes based on
2896251881Speter   their existence/presence, the current state of the node, and the original
2897251881Speter   format of the working copy which provided these property sets.
2898251881Speter*/
2899251881Spetersvn_error_t *
2900251881Spetersvn_wc__db_upgrade_apply_props(svn_sqlite__db_t *sdb,
2901251881Speter                               const char *dir_abspath,
2902251881Speter                               const char *local_relpath,
2903251881Speter                               apr_hash_t *base_props,
2904251881Speter                               apr_hash_t *revert_props,
2905251881Speter                               apr_hash_t *working_props,
2906251881Speter                               int original_format,
2907251881Speter                               apr_int64_t wc_id,
2908251881Speter                               apr_pool_t *scratch_pool);
2909251881Speter
2910251881Speter/* Simply insert (or replace) one row in the EXTERNALS table. */
2911251881Spetersvn_error_t *
2912251881Spetersvn_wc__db_upgrade_insert_external(svn_wc__db_t *db,
2913251881Speter                                   const char *local_abspath,
2914251881Speter                                   svn_node_kind_t kind,
2915251881Speter                                   const char *parent_abspath,
2916251881Speter                                   const char *def_local_abspath,
2917251881Speter                                   const char *repos_relpath,
2918251881Speter                                   const char *repos_root_url,
2919251881Speter                                   const char *repos_uuid,
2920251881Speter                                   svn_revnum_t def_peg_revision,
2921251881Speter                                   svn_revnum_t def_revision,
2922251881Speter                                   apr_pool_t *scratch_pool);
2923251881Speter
2924251881Speter/* Get the repository identifier corresponding to REPOS_ROOT_URL from the
2925251881Speter   database in SDB. The value is returned in *REPOS_ID. All allocations
2926251881Speter   are allocated in SCRATCH_POOL.
2927251881Speter
2928251881Speter   NOTE: the row in REPOSITORY must exist. If not, then SVN_ERR_WC_DB_ERROR
2929251881Speter   is returned.
2930251881Speter
2931251881Speter   ### unclear on whether/how this interface will stay/evolve.  */
2932251881Spetersvn_error_t *
2933251881Spetersvn_wc__db_upgrade_get_repos_id(apr_int64_t *repos_id,
2934251881Speter                                svn_sqlite__db_t *sdb,
2935251881Speter                                const char *repos_root_url,
2936251881Speter                                apr_pool_t *scratch_pool);
2937251881Speter
2938251881Speter/* Upgrade the metadata concerning the WC at WCROOT_ABSPATH, in DB,
2939251881Speter * to the SVN_WC__VERSION format.
2940251881Speter *
2941251881Speter * This function is used for upgrading wc-ng working copies to a newer
2942251881Speter * wc-ng format. If a pre-1.7 working copy is found, this function
2943251881Speter * returns SVN_ERR_WC_UPGRADE_REQUIRED.
2944251881Speter *
2945251881Speter * Upgrading subdirectories of a working copy is not supported.
2946251881Speter * If WCROOT_ABSPATH is not a working copy root SVN_ERR_WC_INVALID_OP_ON_CWD
2947251881Speter * is returned.
2948253734Speter *
2949253734Speter * If BUMPED_FORMAT is not NULL, set *BUMPED_FORMAT to TRUE if the format
2950253734Speter * was bumped or to FALSE if the wc was already at the resulting format.
2951251881Speter */
2952251881Spetersvn_error_t *
2953251881Spetersvn_wc__db_bump_format(int *result_format,
2954253734Speter                       svn_boolean_t *bumped_format,
2955253734Speter                       svn_wc__db_t *db,
2956251881Speter                       const char *wcroot_abspath,
2957251881Speter                       apr_pool_t *scratch_pool);
2958251881Speter
2959251881Speter/* @} */
2960251881Speter
2961251881Speter
2962251881Speter/* @defgroup svn_wc__db_wq  Work queue manipulation. see workqueue.h
2963251881Speter   @{
2964251881Speter*/
2965251881Speter
2966251881Speter/* In the WCROOT associated with DB and WRI_ABSPATH, add WORK_ITEM to the
2967251881Speter   wcroot's work queue. Use SCRATCH_POOL for all temporary allocations.  */
2968251881Spetersvn_error_t *
2969251881Spetersvn_wc__db_wq_add(svn_wc__db_t *db,
2970251881Speter                  const char *wri_abspath,
2971251881Speter                  const svn_skel_t *work_item,
2972251881Speter                  apr_pool_t *scratch_pool);
2973251881Speter
2974251881Speter
2975251881Speter/* In the WCROOT associated with DB and WRI_ABSPATH, fetch a work item that
2976251881Speter   needs to be completed. Its identifier is returned in ID, and the data in
2977251881Speter   WORK_ITEM.
2978251881Speter
2979251881Speter   Items are returned in the same order they were queued. This allows for
2980251881Speter   (say) queueing work on a parent node to be handled before that of its
2981251881Speter   children.
2982251881Speter
2983251881Speter   If there are no work items to be completed, then ID will be set to zero,
2984251881Speter   and WORK_ITEM to NULL.
2985251881Speter
2986251881Speter   If COMPLETED_ID is not 0, the wq item COMPLETED_ID will be marked as
2987251881Speter   completed before returning the next item.
2988251881Speter
2989251881Speter   RESULT_POOL will be used to allocate WORK_ITEM, and SCRATCH_POOL
2990251881Speter   will be used for all temporary allocations.  */
2991251881Spetersvn_error_t *
2992251881Spetersvn_wc__db_wq_fetch_next(apr_uint64_t *id,
2993251881Speter                         svn_skel_t **work_item,
2994251881Speter                         svn_wc__db_t *db,
2995251881Speter                         const char *wri_abspath,
2996251881Speter                         apr_uint64_t completed_id,
2997251881Speter                         apr_pool_t *result_pool,
2998251881Speter                         apr_pool_t *scratch_pool);
2999251881Speter
3000251881Speter/* Special variant of svn_wc__db_wq_fetch_next(), which in the same transaction
3001251881Speter   also records timestamps and sizes for one or more nodes */
3002251881Spetersvn_error_t *
3003251881Spetersvn_wc__db_wq_record_and_fetch_next(apr_uint64_t *id,
3004251881Speter                                    svn_skel_t **work_item,
3005251881Speter                                    svn_wc__db_t *db,
3006251881Speter                                    const char *wri_abspath,
3007251881Speter                                    apr_uint64_t completed_id,
3008251881Speter                                    apr_hash_t *record_map,
3009251881Speter                                    apr_pool_t *result_pool,
3010251881Speter                                    apr_pool_t *scratch_pool);
3011251881Speter
3012251881Speter
3013251881Speter/* @} */
3014251881Speter
3015251881Speter
3016251881Speter/* Note: LEVELS_TO_LOCK is here strictly for backward compat.  The access
3017251881Speter   batons still have the notion of 'levels to lock' and we need to ensure
3018251881Speter   that they still function correctly, even in the new world.  'levels to
3019251881Speter   lock' should not be exposed through the wc-ng APIs at all: users either
3020251881Speter   get to lock the entire tree (rooted at some subdir, of course), or none.
3021251881Speter
3022251881Speter   An infinite depth lock is obtained with LEVELS_TO_LOCK set to -1, but until
3023251881Speter   we move to a single DB only depth 0 is supported.
3024251881Speter*/
3025251881Spetersvn_error_t *
3026251881Spetersvn_wc__db_wclock_obtain(svn_wc__db_t *db,
3027251881Speter                         const char *local_abspath,
3028251881Speter                         int levels_to_lock,
3029251881Speter                         svn_boolean_t steal_lock,
3030251881Speter                         apr_pool_t *scratch_pool);
3031251881Speter
3032251881Speter/* Set LOCK_ABSPATH to the path of the the directory that owns the
3033251881Speter   lock on LOCAL_ABSPATH, or NULL, if LOCAL_ABSPATH is not locked. */
3034251881Spetersvn_error_t*
3035251881Spetersvn_wc__db_wclock_find_root(const char **lock_abspath,
3036251881Speter                            svn_wc__db_t *db,
3037251881Speter                            const char *local_abspath,
3038251881Speter                            apr_pool_t *result_pool,
3039251881Speter                            apr_pool_t *scratch_pool);
3040251881Speter
3041251881Speter/* Check if somebody has a wclock on LOCAL_ABSPATH */
3042251881Spetersvn_error_t *
3043251881Spetersvn_wc__db_wclocked(svn_boolean_t *locked,
3044251881Speter                    svn_wc__db_t *db,
3045251881Speter                    const char *local_abspath,
3046251881Speter                    apr_pool_t *scratch_pool);
3047251881Speter
3048251881Speter/* Release the previously obtained lock on LOCAL_ABSPATH */
3049251881Spetersvn_error_t *
3050251881Spetersvn_wc__db_wclock_release(svn_wc__db_t *db,
3051251881Speter                          const char *local_abspath,
3052251881Speter                          apr_pool_t *scratch_pool);
3053251881Speter
3054251881Speter/* Checks whether DB currently owns a lock to operate on LOCAL_ABSPATH.
3055251881Speter   If EXACT is TRUE only lock roots are checked. */
3056251881Spetersvn_error_t *
3057251881Spetersvn_wc__db_wclock_owns_lock(svn_boolean_t *own_lock,
3058251881Speter                            svn_wc__db_t *db,
3059251881Speter                            const char *local_abspath,
3060251881Speter                            svn_boolean_t exact,
3061251881Speter                            apr_pool_t *scratch_pool);
3062251881Speter
3063251881Speter
3064251881Speter
3065251881Speter/* @defgroup svn_wc__db_temp Various temporary functions during transition
3066251881Speter
3067251881Speter  ### These functions SHOULD be completely removed before 1.7
3068251881Speter
3069251881Speter  @{
3070251881Speter*/
3071251881Speter
3072251881Speter/* Removes all references to LOCAL_ABSPATH from DB, while optionally leaving
3073251881Speter   a not present node.
3074251881Speter
3075251881Speter   This operation always recursively removes all nodes at and below
3076251881Speter   LOCAL_ABSPATH from NODES and ACTUAL.
3077251881Speter
3078251881Speter   If NOT_PRESENT_REVISION specifies a valid revision, leave a not_present
3079251881Speter   BASE node at local_abspath of the specified status and kind.
3080251881Speter   (Requires an existing BASE node before removing)
3081251881Speter
3082251881Speter   If DESTROY_WC is TRUE, this operation *installs* workqueue operations to
3083251881Speter   update the local filesystem after the database operation. If DESTROY_CHANGES
3084251881Speter   is FALSE, modified and unversioned files are left after running this
3085251881Speter   operation (and the WQ). If DESTROY_CHANGES and DESTROY_WC are TRUE,
3086251881Speter   LOCAL_ABSPATH and everything below it will be removed by the WQ.
3087251881Speter
3088251881Speter
3089251881Speter   Note: Unlike many similar functions it is a valid scenario for this
3090251881Speter   function to be called on a wcroot! In this case it will just leave the root
3091251881Speter   record in BASE
3092251881Speter */
3093251881Spetersvn_error_t *
3094251881Spetersvn_wc__db_op_remove_node(svn_boolean_t *left_changes,
3095251881Speter                          svn_wc__db_t *db,
3096251881Speter                          const char *local_abspath,
3097251881Speter                          svn_boolean_t destroy_wc,
3098251881Speter                          svn_boolean_t destroy_changes,
3099251881Speter                          svn_revnum_t not_present_revision,
3100251881Speter                          svn_wc__db_status_t not_present_status,
3101251881Speter                          svn_node_kind_t not_present_kind,
3102251881Speter                          const svn_skel_t *conflict,
3103251881Speter                          const svn_skel_t *work_items,
3104251881Speter                          svn_cancel_func_t cancel_func,
3105251881Speter                          void *cancel_baton,
3106251881Speter                          apr_pool_t *scratch_pool);
3107251881Speter
3108251881Speter/* Sets the depth of LOCAL_ABSPATH in its working copy to DEPTH using DB.
3109251881Speter
3110251881Speter   Returns SVN_ERR_WC_PATH_NOT_FOUND if LOCAL_ABSPATH is not a BASE directory
3111251881Speter */
3112251881Spetersvn_error_t *
3113251881Spetersvn_wc__db_op_set_base_depth(svn_wc__db_t *db,
3114251881Speter                             const char *local_abspath,
3115251881Speter                             svn_depth_t depth,
3116251881Speter                             apr_pool_t *scratch_pool);
3117251881Speter
3118251881Speter/* ### temp function. return the FORMAT for the directory LOCAL_ABSPATH.  */
3119251881Spetersvn_error_t *
3120251881Spetersvn_wc__db_temp_get_format(int *format,
3121251881Speter                           svn_wc__db_t *db,
3122251881Speter                           const char *local_dir_abspath,
3123251881Speter                           apr_pool_t *scratch_pool);
3124251881Speter
3125251881Speter/* ### temp functions to manage/store access batons within the DB.  */
3126251881Spetersvn_wc_adm_access_t *
3127251881Spetersvn_wc__db_temp_get_access(svn_wc__db_t *db,
3128251881Speter                           const char *local_dir_abspath,
3129251881Speter                           apr_pool_t *scratch_pool);
3130251881Spetervoid
3131251881Spetersvn_wc__db_temp_set_access(svn_wc__db_t *db,
3132251881Speter                           const char *local_dir_abspath,
3133251881Speter                           svn_wc_adm_access_t *adm_access,
3134251881Speter                           apr_pool_t *scratch_pool);
3135251881Spetersvn_error_t *
3136251881Spetersvn_wc__db_temp_close_access(svn_wc__db_t *db,
3137251881Speter                             const char *local_dir_abspath,
3138251881Speter                             svn_wc_adm_access_t *adm_access,
3139251881Speter                             apr_pool_t *scratch_pool);
3140251881Spetervoid
3141251881Spetersvn_wc__db_temp_clear_access(svn_wc__db_t *db,
3142251881Speter                             const char *local_dir_abspath,
3143251881Speter                             apr_pool_t *scratch_pool);
3144251881Speter
3145251881Speter/* ### shallow hash: abspath -> svn_wc_adm_access_t *  */
3146251881Speterapr_hash_t *
3147251881Spetersvn_wc__db_temp_get_all_access(svn_wc__db_t *db,
3148251881Speter                               apr_pool_t *result_pool);
3149251881Speter
3150251881Speter/* ### temp function to open the sqlite database to the appropriate location,
3151251881Speter   ### then borrow it for a bit.
3152251881Speter   ### The *only* reason for this function is because entries.c still
3153251881Speter   ### manually hacks the sqlite database.
3154251881Speter
3155251881Speter   ### No matter how tempted you may be DO NOT USE THIS FUNCTION!
3156251881Speter   ### (if you do, gstein will hunt you down and burn your knee caps off
3157251881Speter   ### in the middle of the night)
3158251881Speter   ### "Bet on it." --gstein
3159251881Speter*/
3160251881Spetersvn_error_t *
3161251881Spetersvn_wc__db_temp_borrow_sdb(svn_sqlite__db_t **sdb,
3162251881Speter                           svn_wc__db_t *db,
3163251881Speter                           const char *local_dir_abspath,
3164251881Speter                           apr_pool_t *scratch_pool);
3165251881Speter
3166251881Speter
3167251881Speter/* Return a directory in *TEMP_DIR_ABSPATH that is suitable for temporary
3168251881Speter   files which may need to be moved (atomically and same-device) into the
3169251881Speter   working copy indicated by WRI_ABSPATH.  */
3170251881Spetersvn_error_t *
3171251881Spetersvn_wc__db_temp_wcroot_tempdir(const char **temp_dir_abspath,
3172251881Speter                               svn_wc__db_t *db,
3173251881Speter                               const char *wri_abspath,
3174251881Speter                               apr_pool_t *result_pool,
3175251881Speter                               apr_pool_t *scratch_pool);
3176251881Speter
3177251881Speter/* Update the BASE_NODE of directory LOCAL_ABSPATH to be NEW_REPOS_RELPATH
3178251881Speter   at revision NEW_REV with status incomplete. */
3179251881Spetersvn_error_t *
3180251881Spetersvn_wc__db_temp_op_start_directory_update(svn_wc__db_t *db,
3181251881Speter                                          const char *local_abspath,
3182251881Speter                                          const char *new_repos_relpath,
3183251881Speter                                          svn_revnum_t new_rev,
3184251881Speter                                          apr_pool_t *scratch_pool);
3185251881Speter
3186251881Speter/* Marks a directory update started with
3187251881Speter   svn_wc__db_temp_op_start_directory_update as completed, by removing
3188251881Speter   the incomplete status */
3189251881Spetersvn_error_t *
3190251881Spetersvn_wc__db_temp_op_end_directory_update(svn_wc__db_t *db,
3191251881Speter                                        const char *local_dir_abspath,
3192251881Speter                                        apr_pool_t *scratch_pool);
3193251881Speter
3194251881Speter
3195251881Speter/* Copy the base tree at LOCAL_ABSPATH into the working tree as copy,
3196251881Speter   leaving any subtree additions and copies as-is.  This allows the
3197251881Speter   base node tree to be removed. */
3198251881Spetersvn_error_t *
3199251881Spetersvn_wc__db_op_make_copy(svn_wc__db_t *db,
3200251881Speter                        const char *local_abspath,
3201251881Speter                        const svn_skel_t *conflicts,
3202251881Speter                        const svn_skel_t *work_items,
3203251881Speter                        apr_pool_t *scratch_pool);
3204251881Speter
3205251881Speter/* Close the wc root LOCAL_ABSPATH and remove any per-directory
3206251881Speter   handles associated with it. */
3207251881Spetersvn_error_t *
3208251881Spetersvn_wc__db_drop_root(svn_wc__db_t *db,
3209251881Speter                     const char *local_abspath,
3210251881Speter                     apr_pool_t *scratch_pool);
3211251881Speter
3212251881Speter/* Return the OP_DEPTH for LOCAL_RELPATH. */
3213251881Speterint
3214251881Spetersvn_wc__db_op_depth_for_upgrade(const char *local_relpath);
3215251881Speter
3216251881Speter/* Set *HAVE_WORK TRUE if there is a working layer below the top layer and
3217251881Speter   *HAVE_BASE if there is a base layer. Set *STATUS to the status of the
3218251881Speter   highest layer below WORKING */
3219251881Spetersvn_error_t *
3220251881Spetersvn_wc__db_info_below_working(svn_boolean_t *have_base,
3221251881Speter                              svn_boolean_t *have_work,
3222251881Speter                              svn_wc__db_status_t *status,
3223251881Speter                              svn_wc__db_t *db,
3224251881Speter                              const char *local_abspath,
3225251881Speter                              apr_pool_t *scratch_pool);
3226251881Speter
3227251881Speter
3228251881Speter/* Gets an array of const char *local_relpaths of descendants of LOCAL_ABSPATH,
3229251881Speter * which itself must be the op root of an addition, copy or move.
3230251881Speter * The descendants returned are at the same op_depth, but are to be deleted
3231251881Speter * by the commit processing because they are not present in the local copy.
3232251881Speter */
3233251881Spetersvn_error_t *
3234251881Spetersvn_wc__db_get_not_present_descendants(const apr_array_header_t **descendants,
3235251881Speter                                       svn_wc__db_t *db,
3236251881Speter                                       const char *local_abspath,
3237251881Speter                                       apr_pool_t *result_pool,
3238251881Speter                                       apr_pool_t *scratch_pool);
3239251881Speter
3240251881Speter/* Gather revision status information about a working copy using DB.
3241251881Speter *
3242251881Speter * Set *MIN_REVISION and *MAX_REVISION to the lowest and highest revision
3243251881Speter * numbers found within LOCAL_ABSPATH.
3244251881Speter * Only nodes with op_depth zero and presence 'normal' or 'incomplete'
3245251881Speter * are considered, so that added, deleted or excluded nodes do not affect
3246251881Speter * the result.  If COMMITTED is TRUE, set *MIN_REVISION and *MAX_REVISION
3247251881Speter * to the lowest and highest committed (i.e. "last changed") revision numbers,
3248251881Speter * respectively.
3249251881Speter *
3250251881Speter * Indicate in *IS_SPARSE_CHECKOUT whether any of the nodes within
3251251881Speter * LOCAL_ABSPATH is sparse.
3252251881Speter * Indicate in *IS_MODIFIED whether the working copy has local modifications.
3253251881Speter *
3254251881Speter * Indicate in *IS_SWITCHED whether any node beneath LOCAL_ABSPATH
3255251881Speter * is switched. If TRAIL_URL is non-NULL, use it to determine if LOCAL_ABSPATH
3256251881Speter * itself is switched.  It should be any trailing portion of LOCAL_ABSPATH's
3257251881Speter * expected URL, long enough to include any parts that the caller considers
3258251881Speter * might be changed by a switch.  If it does not match the end of WC_PATH's
3259251881Speter * actual URL, then report a "switched" status.
3260251881Speter *
3261251881Speter * See also the functions below which provide a subset of this functionality.
3262251881Speter */
3263251881Spetersvn_error_t *
3264251881Spetersvn_wc__db_revision_status(svn_revnum_t *min_revision,
3265251881Speter                           svn_revnum_t *max_revision,
3266251881Speter                           svn_boolean_t *is_sparse_checkout,
3267251881Speter                           svn_boolean_t *is_modified,
3268251881Speter                           svn_boolean_t *is_switched,
3269251881Speter                           svn_wc__db_t *db,
3270251881Speter                           const char *local_abspath,
3271251881Speter                           const char *trail_url,
3272251881Speter                           svn_boolean_t committed,
3273251881Speter                           svn_cancel_func_t cancel_func,
3274251881Speter                           void *cancel_baton,
3275251881Speter                           apr_pool_t *scratch_pool);
3276251881Speter
3277251881Speter/* Set *MIN_REVISION and *MAX_REVISION to the lowest and highest revision
3278251881Speter * numbers found within LOCAL_ABSPATH in the working copy using DB.
3279251881Speter * Only nodes with op_depth zero and presence 'normal' or 'incomplete'
3280251881Speter * are considered, so that added, deleted or excluded nodes do not affect
3281251881Speter * the result.  If COMMITTED is TRUE, set *MIN_REVISION and *MAX_REVISION
3282251881Speter * to the lowest and highest committed (i.e. "last changed") revision numbers,
3283251881Speter * respectively. Use SCRATCH_POOL for temporary allocations.
3284251881Speter *
3285251881Speter * Either of MIN_REVISION and MAX_REVISION may be passed as NULL if
3286251881Speter * the caller doesn't care about that return value.
3287251881Speter *
3288251881Speter * This function provides a subset of the functionality of
3289251881Speter * svn_wc__db_revision_status() and is more efficient if the caller
3290251881Speter * doesn't need all information returned by svn_wc__db_revision_status(). */
3291251881Spetersvn_error_t *
3292251881Spetersvn_wc__db_min_max_revisions(svn_revnum_t *min_revision,
3293251881Speter                             svn_revnum_t *max_revision,
3294251881Speter                             svn_wc__db_t *db,
3295251881Speter                             const char *local_abspath,
3296251881Speter                             svn_boolean_t committed,
3297251881Speter                             apr_pool_t *scratch_pool);
3298251881Speter
3299251881Speter/* Indicate in *IS_SWITCHED whether any node beneath LOCAL_ABSPATH
3300251881Speter * is switched, using DB. Use SCRATCH_POOL for temporary allocations.
3301251881Speter *
3302251881Speter * If TRAIL_URL is non-NULL, use it to determine if LOCAL_ABSPATH itself
3303251881Speter * is switched.  It should be any trailing portion of LOCAL_ABSPATH's
3304251881Speter * expected URL, long enough to include any parts that the caller considers
3305251881Speter * might be changed by a switch.  If it does not match the end of WC_PATH's
3306251881Speter * actual URL, then report a "switched" status.
3307251881Speter *
3308251881Speter * This function provides a subset of the functionality of
3309251881Speter * svn_wc__db_revision_status() and is more efficient if the caller
3310251881Speter * doesn't need all information returned by svn_wc__db_revision_status(). */
3311251881Spetersvn_error_t *
3312251881Spetersvn_wc__db_has_switched_subtrees(svn_boolean_t *is_switched,
3313251881Speter                                 svn_wc__db_t *db,
3314251881Speter                                 const char *local_abspath,
3315251881Speter                                 const char *trail_url,
3316251881Speter                                 apr_pool_t *scratch_pool);
3317251881Speter
3318251881Speter/* Set @a *excluded_subtrees to a hash mapping <tt>const char *</tt>
3319251881Speter * local absolute paths to <tt>const char *</tt> local absolute paths for
3320251881Speter * every path under @a local_abspath in @a db which are excluded by
3321251881Speter * the server (e.g. due to authz), or user.  If no such paths are found then
3322251881Speter * @a *server_excluded_subtrees is set to @c NULL.
3323251881Speter * Allocate the hash and all items therein from @a result_pool.
3324251881Speter */
3325251881Spetersvn_error_t *
3326251881Spetersvn_wc__db_get_excluded_subtrees(apr_hash_t **server_excluded_subtrees,
3327251881Speter                                 svn_wc__db_t *db,
3328251881Speter                                 const char *local_abspath,
3329251881Speter                                 apr_pool_t *result_pool,
3330251881Speter                                 apr_pool_t *scratch_pool);
3331251881Speter
3332251881Speter/* Indicate in *IS_MODIFIED whether the working copy has local modifications,
3333251881Speter * using DB. Use SCRATCH_POOL for temporary allocations.
3334251881Speter *
3335251881Speter * This function provides a subset of the functionality of
3336251881Speter * svn_wc__db_revision_status() and is more efficient if the caller
3337251881Speter * doesn't need all information returned by svn_wc__db_revision_status(). */
3338251881Spetersvn_error_t *
3339251881Spetersvn_wc__db_has_local_mods(svn_boolean_t *is_modified,
3340251881Speter                          svn_wc__db_t *db,
3341251881Speter                          const char *local_abspath,
3342251881Speter                          svn_cancel_func_t cancel_func,
3343251881Speter                          void *cancel_baton,
3344251881Speter                          apr_pool_t *scratch_pool);
3345251881Speter
3346251881Speter
3347251881Speter/* Verify the consistency of metadata concerning the WC that contains
3348251881Speter * WRI_ABSPATH, in DB.  Return an error if any problem is found. */
3349251881Spetersvn_error_t *
3350251881Spetersvn_wc__db_verify(svn_wc__db_t *db,
3351251881Speter                  const char *wri_abspath,
3352251881Speter                  apr_pool_t *scratch_pool);
3353251881Speter
3354251881Speter
3355251881Speter/* Possibly need two structures, one with relpaths and with abspaths?
3356251881Speter * Only exposed for testing at present. */
3357251881Speterstruct svn_wc__db_moved_to_t {
3358251881Speter  const char *local_relpath;  /* moved-to destination */
3359251881Speter  int op_depth;       /* op-root of source */
3360251881Speter};
3361251881Speter
3362251881Speter/* Set *FINAL_ABSPATH to an array of svn_wc__db_moved_to_t for
3363251881Speter * LOCAL_ABSPATH after following any and all nested moves.
3364251881Speter * Only exposed for testing at present. */
3365251881Spetersvn_error_t *
3366251881Spetersvn_wc__db_follow_moved_to(apr_array_header_t **moved_tos,
3367251881Speter                           svn_wc__db_t *db,
3368251881Speter                           const char *local_abspath,
3369251881Speter                           apr_pool_t *result_pool,
3370251881Speter                           apr_pool_t *scratch_pool);
3371251881Speter
3372251881Speter/* Update a moved-away tree conflict victim at VICTIM_ABSPATH with changes
3373251881Speter * brought in by the update operation which flagged the tree conflict. */
3374251881Spetersvn_error_t *
3375251881Spetersvn_wc__db_update_moved_away_conflict_victim(svn_wc__db_t *db,
3376251881Speter                                             const char *victim_abspath,
3377251881Speter                                             svn_wc_notify_func2_t notify_func,
3378251881Speter                                             void *notify_baton,
3379251881Speter                                             svn_cancel_func_t cancel_func,
3380251881Speter                                             void *cancel_baton,
3381251881Speter                                             apr_pool_t *scratch_pool);
3382251881Speter
3383251881Speter/* LOCAL_ABSPATH is moved to MOVE_DST_ABSPATH.  MOVE_SRC_ROOT_ABSPATH
3384251881Speter * is the root of the move to MOVE_DST_OP_ROOT_ABSPATH.
3385251881Speter * MOVE_SRC_OP_ROOT_ABSPATH is the op-root of the move; it's the same
3386251881Speter * as MOVE_SRC_ROOT_ABSPATH except for moves inside deletes when it is
3387251881Speter * the op-root of the delete. */
3388251881Spetersvn_error_t *
3389251881Spetersvn_wc__db_base_moved_to(const char **move_dst_abspath,
3390251881Speter                         const char **move_dst_op_root_abspath,
3391251881Speter                         const char **move_src_root_abspath,
3392251881Speter                         const char **move_src_op_root_abspath,
3393251881Speter                         svn_wc__db_t *db,
3394251881Speter                         const char *local_abspath,
3395251881Speter                         apr_pool_t *result_pool,
3396251881Speter                         apr_pool_t *scratch_pool);
3397251881Speter
3398251881Speter/* Recover space from the database file for LOCAL_ABSPATH by running
3399251881Speter * the "vacuum" command. */
3400251881Spetersvn_error_t *
3401251881Spetersvn_wc__db_vacuum(svn_wc__db_t *db,
3402251881Speter                  const char *local_abspath,
3403251881Speter                  apr_pool_t *scratch_pool);
3404251881Speter
3405251881Speter/* This raises move-edit tree-conflicts on any moves inside the
3406251881Speter   delete-edit conflict on LOCAL_ABSPATH. This is experimental: see
3407251881Speter   comment in resolve_conflict_on_node about combining with another
3408251881Speter   function. */
3409251881Spetersvn_error_t *
3410251881Spetersvn_wc__db_resolve_delete_raise_moved_away(svn_wc__db_t *db,
3411251881Speter                                           const char *local_abspath,
3412251881Speter                                           svn_wc_notify_func2_t notify_func,
3413251881Speter                                           void *notify_baton,
3414251881Speter                                           apr_pool_t *scratch_pool);
3415251881Speter
3416251881Speter/* Like svn_wc__db_resolve_delete_raise_moved_away this should be
3417262253Speter   combined.
3418262253Speter
3419262253Speter   ### LOCAL_ABSPATH specifies the move origin, but the move origin
3420262253Speter   ### is not necessary unique enough. This function needs an op_root_abspath
3421262253Speter   ### argument to differentiate between different origins.
3422262253Speter
3423262253Speter   ### See move_tests.py: move_many_update_delete for an example case.
3424262253Speter   */
3425251881Spetersvn_error_t *
3426251881Spetersvn_wc__db_resolve_break_moved_away(svn_wc__db_t *db,
3427251881Speter                                    const char *local_abspath,
3428251881Speter                                    svn_wc_notify_func2_t notify_func,
3429251881Speter                                    void *notify_baton,
3430251881Speter                                    apr_pool_t *scratch_pool);
3431251881Speter
3432251881Speter/* Break moves for all moved-away children of LOCAL_ABSPATH, within
3433251881Speter * a single transaction.
3434251881Speter *
3435251881Speter * ### Like svn_wc__db_resolve_delete_raise_moved_away this should be
3436251881Speter * combined. */
3437251881Spetersvn_error_t *
3438251881Spetersvn_wc__db_resolve_break_moved_away_children(svn_wc__db_t *db,
3439251881Speter                                             const char *local_abspath,
3440251881Speter                                             svn_wc_notify_func2_t notify_func,
3441251881Speter                                             void *notify_baton,
3442251881Speter                                             apr_pool_t *scratch_pool);
3443251881Speter
3444251881Speter/* Set *REQUIRED_ABSPATH to the path that should be locked to ensure
3445251881Speter * that the lock covers all paths affected by resolving the conflicts
3446251881Speter * in the tree LOCAL_ABSPATH. */
3447251881Spetersvn_error_t *
3448251881Spetersvn_wc__required_lock_for_resolve(const char **required_abspath,
3449251881Speter                                  svn_wc__db_t *db,
3450251881Speter                                  const char *local_abspath,
3451251881Speter                                  apr_pool_t *result_pool,
3452251881Speter                                  apr_pool_t *scratch_pool);
3453251881Speter/* @} */
3454251881Speter
3455251881Speter
3456251881Speter#ifdef __cplusplus
3457251881Speter}
3458251881Speter#endif /* __cplusplus */
3459251881Speter
3460251881Speter#endif /* SVN_WC_DB_H */
3461