wc_db.h revision 289166
1/**
2 * @copyright
3 * ====================================================================
4 *    Licensed to the Apache Software Foundation (ASF) under one
5 *    or more contributor license agreements.  See the NOTICE file
6 *    distributed with this work for additional information
7 *    regarding copyright ownership.  The ASF licenses this file
8 *    to you under the Apache License, Version 2.0 (the
9 *    "License"); you may not use this file except in compliance
10 *    with the License.  You may obtain a copy of the License at
11 *
12 *      http://www.apache.org/licenses/LICENSE-2.0
13 *
14 *    Unless required by applicable law or agreed to in writing,
15 *    software distributed under the License is distributed on an
16 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 *    KIND, either express or implied.  See the License for the
18 *    specific language governing permissions and limitations
19 *    under the License.
20 * ====================================================================
21 * @endcopyright
22 *
23 * @file svn_wc_db.h
24 * @brief The Subversion Working Copy Library - Metadata/Base-Text Support
25 *
26 * Requires:
27 *            - A working copy
28 *
29 * Provides:
30 *            - Ability to manipulate working copy's administrative files.
31 *
32 * Used By:
33 *            - The main working copy library
34 */
35
36#ifndef SVN_WC_DB_H
37#define SVN_WC_DB_H
38
39#include "svn_wc.h"
40
41#include "svn_types.h"
42#include "svn_error.h"
43#include "svn_config.h"
44#include "svn_io.h"
45
46#include "private/svn_skel.h"
47#include "private/svn_sqlite.h"
48#include "private/svn_wc_private.h"
49
50#include "svn_private_config.h"
51
52#ifdef __cplusplus
53extern "C" {
54#endif /* __cplusplus */
55
56/* INTERFACE CONVENTIONS
57
58   "OUT" PARAMETERS
59
60   There are numerous functions within this API which take a (large) number
61   of "out" parameters. These are listed individually, rather than combined
62   into a struct, so that a caller can be fine-grained about the which
63   pieces of information are being requested. In many cases, only a subset
64   is required, so the implementation can perform various optimizations
65   to fulfill the limited request for information.
66
67
68   POOLS
69
70   wc_db uses the dual-pool paradigm for all of its functions. Any OUT
71   parameter will be allocated within the result pool, and all temporary
72   allocations will be performed within the scratch pool.
73
74   The pool that DB is allocated within (the "state" pool) is only used
75   for a few, limited allocations to track each of the working copy roots
76   that the DB is asked to operate upon. The memory usage on this pool
77   is O(# wcroots), which should normally be one or a few. Custom clients
78   which hold open structures over a significant period of time should
79   pay particular attention to the number of roots touched, and the
80   resulting impact on memory consumption (which should still be minimal).
81
82
83   PARAMETER CONVENTIONS
84
85   * Parameter Order
86     - any output arguments
87     - DB
88     - LOCAL_ABSPATH
89     - any other input arguments
90     - RESULT_POOL
91     - SCRATCH_POOL
92
93   * DB
94     This parameter is the primary context for all operations on the
95     metadata for working copies. This parameter is passed to almost every
96     function, and maintains information and state about every working
97     copy "touched" by any of the APIs in this interface.
98
99   * *_ABSPATH
100     All *_ABSPATH parameters in this API are absolute paths in the local
101     filesystem, represented in Subversion internal canonical form.
102
103   * LOCAL_ABSPATH
104     This parameter specifies a particular *versioned* node in the local
105     filesystem. From this node, a working copy root is implied, and will
106     be used for the given API operation.
107
108   * LOCAL_DIR_ABSPATH
109     This parameter is similar to LOCAL_ABSPATH, but the semantics of the
110     parameter and operation require the node to be a directory within
111     the working copy.
112
113   * WRI_ABSPATH
114     This is a "Working copy Root Indicator" path. This refers to a location
115     in the local filesystem that is anywhere inside a working copy. The given
116     operation will be performed within the context of the root of that
117     working copy. This does not necessarily need to refer to a specific
118     versioned node or the root of a working copy (although it can) -- any
119     location, existing or not, is sufficient, as long as it is inside a
120     working copy.
121     ### TODO: Define behaviour for switches and externals.
122     ### Preference has been stated that WRI_ABSPATH should imply the root
123     ### of the parent WC of all switches and externals, but that may
124     ### not play out well, especially with multiple repositories involved.
125*/
126
127/* Context data structure for interacting with the administrative data. */
128typedef struct svn_wc__db_t svn_wc__db_t;
129
130
131/* Enumerated values describing the state of a node. */
132typedef enum svn_wc__db_status_t {
133    /* The node is present and has no known modifications applied to it. */
134    svn_wc__db_status_normal,
135
136    /* The node has been added (potentially obscuring a delete or move of
137       the BASE node; see HAVE_BASE param [### What param? This is an enum
138       not a function.] ). The text will be marked as
139       modified, and if properties exist, they will be marked as modified.
140
141       In many cases svn_wc__db_status_added means any of added, moved-here
142       or copied-here. See individual functions for clarification and
143       svn_wc__db_scan_addition() to get more details. */
144    svn_wc__db_status_added,
145
146    /* This node has been added with history, based on the move source.
147       Text and property modifications are based on whether changes have
148       been made against their pristine versions. */
149    svn_wc__db_status_moved_here,
150
151    /* This node has been added with history, based on the copy source.
152       Text and property modifications are based on whether changes have
153       been made against their pristine versions. */
154    svn_wc__db_status_copied,
155
156    /* This node has been deleted. No text or property modifications
157       will be present. */
158    svn_wc__db_status_deleted,
159
160    /* This node was named by the server, but no information was provided. */
161    svn_wc__db_status_server_excluded,
162
163    /* This node has been administratively excluded. */
164    svn_wc__db_status_excluded,
165
166    /* This node is not present in this revision. This typically happens
167       when a node is deleted and committed without updating its parent.
168       The parent revision indicates it should be present, but this node's
169       revision states otherwise. */
170    svn_wc__db_status_not_present,
171
172    /* This node is known, but its information is incomplete. Generally,
173       it should be treated similar to the other missing status values
174       until some (later) process updates the node with its data.
175
176       When the incomplete status applies to a directory, the list of
177       children and the list of its base properties as recorded in the
178       working copy do not match their working copy versions.
179       The update editor can complete a directory by using a different
180       update algorithm. */
181    svn_wc__db_status_incomplete,
182
183    /* The BASE node has been marked as deleted. Only used as an internal
184       status in wc_db.c and entries.c.  */
185    svn_wc__db_status_base_deleted
186
187} svn_wc__db_status_t;
188
189/* Lock information.  We write/read it all as one, so let's use a struct
190   for convenience.  */
191typedef struct svn_wc__db_lock_t {
192  /* The lock token */
193  const char *token;
194
195  /* The owner of the lock, possibly NULL */
196  const char *owner;
197
198  /* A comment about the lock, possibly NULL */
199  const char *comment;
200
201  /* The date the lock was created */
202  apr_time_t date;
203} svn_wc__db_lock_t;
204
205
206/* ### NOTE: I have not provided docstrings for most of this file at this
207   ### point in time. The shape and extent of this API is still in massive
208   ### flux. I'm iterating in public, but do not want to doc until it feels
209   ### like it is "Right".
210*/
211
212/* ### where/how to handle: text_time, locks, working_size */
213
214
215/*
216  @defgroup svn_wc__db_admin  General administrative functions
217  @{
218*/
219
220/* Open a working copy administrative database context.
221
222   This context is (initially) not associated with any particular working
223   copy directory or working copy root (wcroot). As operations are performed,
224   this context will load the appropriate wcroot information.
225
226   The context is returned in DB.
227
228   CONFIG should hold the various configuration options that may apply to
229   the administrative operation. It should live at least as long as the
230   RESULT_POOL parameter.
231
232   When OPEN_WITHOUT_UPGRADE is TRUE, then the working copy databases will
233   be opened even when an old database format is found/detected during
234   the operation of a wc_db API). If open_without_upgrade is FALSE and an
235   upgrade is required, then SVN_ERR_WC_UPGRADE_REQUIRED will be returned
236   from that API.
237   Passing TRUE will allow a bare minimum of APIs to function (most notably,
238   the temp_get_format() function will always return a value) since most of
239   these APIs expect a current-format database to be present.
240
241   If ENFORCE_EMPTY_WQ is TRUE, then any databases with stale work items in
242   their work queue will raise an error when they are opened. The operation
243   will raise SVN_ERR_WC_CLEANUP_REQUIRED. Passing FALSE for this routine
244   means that the work queue is being processed (via 'svn cleanup') and all
245   operations should be allowed.
246
247   The DB will be closed when RESULT_POOL is cleared. It may also be closed
248   manually using svn_wc__db_close(). In particular, this will close any
249   SQLite databases that have been opened and cached.
250
251   The context is allocated in RESULT_POOL. This pool is *retained* and used
252   for future allocations within the DB. Be forewarned about unbounded
253   memory growth if this DB is used across an unbounded number of wcroots
254   and versioned directories.
255
256   Temporary allocations will be made in SCRATCH_POOL.
257*/
258svn_error_t *
259svn_wc__db_open(svn_wc__db_t **db,
260                svn_config_t *config,
261                svn_boolean_t open_without_upgrade,
262                svn_boolean_t enforce_empty_wq,
263                apr_pool_t *result_pool,
264                apr_pool_t *scratch_pool);
265
266
267/* Close DB.  */
268svn_error_t *
269svn_wc__db_close(svn_wc__db_t *db);
270
271
272/* Initialize the SDB for LOCAL_ABSPATH, which should be a working copy path.
273
274   A REPOSITORY row will be constructed for the repository identified by
275   REPOS_ROOT_URL and REPOS_UUID. Neither of these may be NULL.
276
277   A BASE_NODE row will be created for the directory at REPOS_RELPATH at
278   revision INITIAL_REV.
279   If INITIAL_REV is greater than zero, then the node will be marked as
280   "incomplete" because we don't know its children. Contrary, if the
281   INITIAL_REV is zero, then this directory should represent the root and
282   we know it has no children, so the node is complete.
283
284   ### Is there any benefit to marking it 'complete' if rev==0?  Seems like
285   ### an unnecessary special case.
286
287   DEPTH is the initial depth of the working copy; it must be a definite
288   depth, not svn_depth_unknown.
289
290   Use SCRATCH_POOL for temporary allocations.
291*/
292svn_error_t *
293svn_wc__db_init(svn_wc__db_t *db,
294                const char *local_abspath,
295                const char *repos_relpath,
296                const char *repos_root_url,
297                const char *repos_uuid,
298                svn_revnum_t initial_rev,
299                svn_depth_t depth,
300                apr_pool_t *scratch_pool);
301
302
303/* Compute the LOCAL_RELPATH for the given LOCAL_ABSPATH, relative
304   from wri_abspath.
305
306   The LOCAL_RELPATH is a relative path to the working copy's root. That
307   root will be located by this function, and the path will be relative to
308   that location. If LOCAL_ABSPATH is the wcroot directory, then "" will
309   be returned.
310
311   The LOCAL_RELPATH should ONLY be used for persisting paths to disk.
312   Those paths should not be abspaths, otherwise the working copy cannot
313   be moved. The working copy library should not make these paths visible
314   in its API (which should all be abspaths), and it should not be using
315   relpaths for other processing.
316
317   LOCAL_RELPATH will be allocated in RESULT_POOL. All other (temporary)
318   allocations will be made in SCRATCH_POOL.
319
320   This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
321   option.
322*/
323svn_error_t *
324svn_wc__db_to_relpath(const char **local_relpath,
325                      svn_wc__db_t *db,
326                      const char *wri_abspath,
327                      const char *local_abspath,
328                      apr_pool_t *result_pool,
329                      apr_pool_t *scratch_pool);
330
331
332/* Compute the LOCAL_ABSPATH for a LOCAL_RELPATH located within the working
333   copy identified by WRI_ABSPATH.
334
335   This is the reverse of svn_wc__db_to_relpath. It should be used for
336   returning a persisted relpath back into an abspath.
337
338   LOCAL_ABSPATH will be allocated in RESULT_POOL. All other (temporary)
339   allocations will be made in SCRATCH_POOL.
340
341   This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
342   option.
343 */
344svn_error_t *
345svn_wc__db_from_relpath(const char **local_abspath,
346                        svn_wc__db_t *db,
347                        const char *wri_abspath,
348                        const char *local_relpath,
349                        apr_pool_t *result_pool,
350                        apr_pool_t *scratch_pool);
351
352/* Compute the working copy root WCROOT_ABSPATH for WRI_ABSPATH using DB.
353
354   This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
355   option.
356 */
357svn_error_t *
358svn_wc__db_get_wcroot(const char **wcroot_abspath,
359                      svn_wc__db_t *db,
360                      const char *wri_abspath,
361                      apr_pool_t *result_pool,
362                      apr_pool_t *scratch_pool);
363
364
365/* @} */
366
367/* Different kinds of trees
368
369   The design doc mentions three different kinds of trees, BASE, WORKING and
370   ACTUAL: http://svn.apache.org/repos/asf/subversion/trunk/notes/wc-ng-design
371   We have different APIs to handle each tree, enumerated below, along with
372   a blurb to explain what that tree represents.
373*/
374
375/* @defgroup svn_wc__db_base  BASE tree management
376
377   BASE is what we get from the server.  It is the *absolute* pristine copy.
378   You need to use checkout, update, switch, or commit to alter your view of
379   the repository.
380
381   In the BASE tree, each node corresponds to a particular node-rev in the
382   repository.  It can be a mixed-revision tree.  Each node holds either a
383   copy of the node-rev as it exists in the repository (if presence =
384   'normal'), or a place-holder (if presence = 'server-excluded' or 'excluded' or
385   'not-present').
386
387   @{
388*/
389
390/* Add or replace a directory in the BASE tree.
391
392   The directory is located at LOCAL_ABSPATH on the local filesystem, and
393   corresponds to <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID> in the
394   repository, at revision REVISION.
395
396   The directory properties are given by the PROPS hash (which is
397   const char *name => const svn_string_t *).
398
399   The last-change information is given by <CHANGED_REV, CHANGED_DATE,
400   CHANGED_AUTHOR>.
401
402   The directory's children are listed in CHILDREN, as an array of
403   const char *. The child nodes do NOT have to exist when this API
404   is called. For each child node which does not exists, an "incomplete"
405   node will be added. These child nodes will be added regardless of
406   the DEPTH value. The caller must sort out which must be recorded,
407   and which must be omitted.
408
409   This subsystem does not use DEPTH, but it can be recorded here in
410   the BASE tree for higher-level code to use.
411
412   If DAV_CACHE is not NULL, sets LOCAL_ABSPATH's dav cache to the specified
413   data.
414
415   If CONFLICT is not NULL, then it describes a conflict for this node. The
416   node will be record as conflicted (in ACTUAL).
417
418   If UPDATE_ACTUAL_PROPS is TRUE, set the properties store NEW_ACTUAL_PROPS
419   as the new set of properties in ACTUAL. If NEW_ACTUAL_PROPS is NULL or
420   when the value of NEW_ACTUAL_PROPS matches NEW_PROPS, store NULL in
421   ACTUAL, to mark the properties unmodified.
422
423   If NEW_IPROPS is not NULL, then it is a depth-first ordered array of
424   svn_prop_inherited_item_t * structures that is set as the base node's
425   inherited_properties.
426
427   Any work items that are necessary as part of this node construction may
428   be passed in WORK_ITEMS.
429
430   All temporary allocations will be made in SCRATCH_POOL.
431*/
432svn_error_t *
433svn_wc__db_base_add_directory(svn_wc__db_t *db,
434                              const char *local_abspath,
435                              const char *wri_abspath,
436                              const char *repos_relpath,
437                              const char *repos_root_url,
438                              const char *repos_uuid,
439                              svn_revnum_t revision,
440                              const apr_hash_t *props,
441                              svn_revnum_t changed_rev,
442                              apr_time_t changed_date,
443                              const char *changed_author,
444                              const apr_array_header_t *children,
445                              svn_depth_t depth,
446                              apr_hash_t *dav_cache,
447                              const svn_skel_t *conflict,
448                              svn_boolean_t update_actual_props,
449                              apr_hash_t *new_actual_props,
450                              apr_array_header_t *new_iprops,
451                              const svn_skel_t *work_items,
452                              apr_pool_t *scratch_pool);
453
454/* Add a new directory in BASE, whether WORKING nodes exist or not. Mark it
455   as incomplete and with revision REVISION. If REPOS_RELPATH is not NULL,
456   apply REPOS_RELPATH, REPOS_ROOT_URL and REPOS_UUID.
457   Perform all temporary allocations in SCRATCH_POOL.
458   */
459svn_error_t *
460svn_wc__db_base_add_incomplete_directory(svn_wc__db_t *db,
461                                         const char *local_abspath,
462                                         const char *repos_relpath,
463                                         const char *repos_root_url,
464                                         const char *repos_uuid,
465                                         svn_revnum_t revision,
466                                         svn_depth_t depth,
467                                         svn_boolean_t insert_base_deleted,
468                                         svn_boolean_t delete_working,
469                                         svn_skel_t *conflict,
470                                         svn_skel_t *work_items,
471                                         apr_pool_t *scratch_pool);
472
473
474/* Add or replace a file in the BASE tree.
475
476   The file is located at LOCAL_ABSPATH on the local filesystem, and
477   corresponds to <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID> in the
478   repository, at revision REVISION.
479
480   The file properties are given by the PROPS hash (which is
481   const char *name => const svn_string_t *).
482
483   The last-change information is given by <CHANGED_REV, CHANGED_DATE,
484   CHANGED_AUTHOR>.
485
486   The checksum of the file contents is given in CHECKSUM. An entry in
487   the pristine text base is NOT required when this API is called.
488
489   If DAV_CACHE is not NULL, sets LOCAL_ABSPATH's dav cache to the specified
490   data.
491
492   If CONFLICT is not NULL, then it describes a conflict for this node. The
493   node will be record as conflicted (in ACTUAL).
494
495   If UPDATE_ACTUAL_PROPS is TRUE, set the properties store NEW_ACTUAL_PROPS
496   as the new set of properties in ACTUAL. If NEW_ACTUAL_PROPS is NULL or
497   when the value of NEW_ACTUAL_PROPS matches NEW_PROPS, store NULL in
498   ACTUAL, to mark the properties unmodified.
499
500   Any work items that are necessary as part of this node construction may
501   be passed in WORK_ITEMS.
502
503   Unless KEEP_RECORDED_INFO is set to TRUE, recorded size and timestamp values
504   will be cleared.
505
506   All temporary allocations will be made in SCRATCH_POOL.
507*/
508svn_error_t *
509svn_wc__db_base_add_file(svn_wc__db_t *db,
510                         const char *local_abspath,
511                         const char *wri_abspath,
512                         const char *repos_relpath,
513                         const char *repos_root_url,
514                         const char *repos_uuid,
515                         svn_revnum_t revision,
516                         const apr_hash_t *props,
517                         svn_revnum_t changed_rev,
518                         apr_time_t changed_date,
519                         const char *changed_author,
520                         const svn_checksum_t *checksum,
521                         apr_hash_t *dav_cache,
522                         svn_boolean_t delete_working,
523                         svn_boolean_t update_actual_props,
524                         apr_hash_t *new_actual_props,
525                         apr_array_header_t *new_iprops,
526                         svn_boolean_t keep_recorded_info,
527                         svn_boolean_t insert_base_deleted,
528                         const svn_skel_t *conflict,
529                         const svn_skel_t *work_items,
530                         apr_pool_t *scratch_pool);
531
532
533/* Add or replace a symlink in the BASE tree.
534
535   The symlink is located at LOCAL_ABSPATH on the local filesystem, and
536   corresponds to <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID> in the
537   repository, at revision REVISION.
538
539   The symlink's properties are given by the PROPS hash (which is
540   const char *name => const svn_string_t *).
541
542   The last-change information is given by <CHANGED_REV, CHANGED_DATE,
543   CHANGED_AUTHOR>.
544
545   The target of the symlink is specified by TARGET.
546
547   If DAV_CACHE is not NULL, sets LOCAL_ABSPATH's dav cache to the specified
548   data.
549
550   If CONFLICT is not NULL, then it describes a conflict for this node. The
551   node will be record as conflicted (in ACTUAL).
552
553   If UPDATE_ACTUAL_PROPS is TRUE, set the properties store NEW_ACTUAL_PROPS
554   as the new set of properties in ACTUAL. If NEW_ACTUAL_PROPS is NULL or
555   when the value of NEW_ACTUAL_PROPS matches NEW_PROPS, store NULL in
556   ACTUAL, to mark the properties unmodified.
557
558   Any work items that are necessary as part of this node construction may
559   be passed in WORK_ITEMS.
560
561   All temporary allocations will be made in SCRATCH_POOL.
562*/
563/* ### KFF: This is an interesting question, because currently
564   ### symlinks are versioned as regular files with the svn:special
565   ### property; then the file's text contents indicate that it is a
566   ### symlink and where that symlink points.  That's for portability:
567   ### you can check 'em out onto a platform that doesn't support
568   ### symlinks, and even modify the link and check it back in.  It's
569   ### a great solution; but then the question for wc-ng is:
570   ###
571   ### Suppose you check out a symlink on platform X and platform Y.
572   ### X supports symlinks; Y does not.  Should the wc-ng storage for
573   ### those two be the same?  I mean, on platform Y, the file is just
574   ### going to look and behave like a regular file.  It would be sort
575   ### of odd for the wc-ng storage for that file to be of a different
576   ### type from all the other files.  (On the other hand, maybe it's
577   ### weird today that the wc-1 storage for a working symlink is to
578   ### be like a regular file (i.e., regular text-base and whatnot).
579   ###
580   ### I'm still feeling my way around this problem; just pointing out
581   ### the issues.
582
583   ### gjs: symlinks are stored in the database as first-class objects,
584   ###   rather than in the filesystem as "special" regular files. thus,
585   ###   all portability concerns are moot. higher-levels can figure out
586   ###   how to represent the link in ACTUAL. higher-levels can also
587   ###   deal with translating to/from the svn:special property and
588   ###   the plain-text file contents.
589   ### dlr: What about hard links? At minimum, mention in doc string.
590*/
591svn_error_t *
592svn_wc__db_base_add_symlink(svn_wc__db_t *db,
593                            const char *local_abspath,
594                            const char *wri_abspath,
595                            const char *repos_relpath,
596                            const char *repos_root_url,
597                            const char *repos_uuid,
598                            svn_revnum_t revision,
599                            const apr_hash_t *props,
600                            svn_revnum_t changed_rev,
601                            apr_time_t changed_date,
602                            const char *changed_author,
603                            const char *target,
604                            apr_hash_t *dav_cache,
605                            svn_boolean_t delete_working,
606                            svn_boolean_t update_actual_props,
607                            apr_hash_t *new_actual_props,
608                            apr_array_header_t *new_iprops,
609                            svn_boolean_t keep_recorded_info,
610                            svn_boolean_t insert_base_deleted,
611                            const svn_skel_t *conflict,
612                            const svn_skel_t *work_items,
613                            apr_pool_t *scratch_pool);
614
615
616/* Create a node in the BASE tree that is present in name only.
617
618   The new node will be located at LOCAL_ABSPATH, and correspond to the
619   repository node described by <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID>
620   at revision REVISION.
621
622   The node's kind is described by KIND, and the reason for its absence
623   is specified by STATUS. Only these values are allowed for STATUS:
624
625     svn_wc__db_status_server_excluded
626     svn_wc__db_status_excluded
627
628   If CONFLICT is not NULL, then it describes a conflict for this node. The
629   node will be record as conflicted (in ACTUAL).
630
631   Any work items that are necessary as part of this node construction may
632   be passed in WORK_ITEMS.
633
634   All temporary allocations will be made in SCRATCH_POOL.
635*/
636svn_error_t *
637svn_wc__db_base_add_excluded_node(svn_wc__db_t *db,
638                                  const char *local_abspath,
639                                  const char *repos_relpath,
640                                  const char *repos_root_url,
641                                  const char *repos_uuid,
642                                  svn_revnum_t revision,
643                                  svn_node_kind_t kind,
644                                  svn_wc__db_status_t status,
645                                  const svn_skel_t *conflict,
646                                  const svn_skel_t *work_items,
647                                  apr_pool_t *scratch_pool);
648
649
650/* Create a node in the BASE tree that is present in name only.
651
652   The new node will be located at LOCAL_ABSPATH, and correspond to the
653   repository node described by <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID>
654   at revision REVISION.
655
656   The node's kind is described by KIND, and the reason for its absence
657   is 'svn_wc__db_status_not_present'.
658
659   If CONFLICT is not NULL, then it describes a conflict for this node. The
660   node will be record as conflicted (in ACTUAL).
661
662   Any work items that are necessary as part of this node construction may
663   be passed in WORK_ITEMS.
664
665   All temporary allocations will be made in SCRATCH_POOL.
666*/
667svn_error_t *
668svn_wc__db_base_add_not_present_node(svn_wc__db_t *db,
669                                     const char *local_abspath,
670                                     const char *repos_relpath,
671                                     const char *repos_root_url,
672                                     const char *repos_uuid,
673                                     svn_revnum_t revision,
674                                     svn_node_kind_t kind,
675                                     const svn_skel_t *conflict,
676                                     const svn_skel_t *work_items,
677                                     apr_pool_t *scratch_pool);
678
679
680/* Remove a node and all its descendants from the BASE tree. This handles
681   the deletion of a tree from the update editor and some file external
682   scenarios.
683
684   The node to remove is indicated by LOCAL_ABSPATH from the local
685   filesystem.
686
687   This operation *installs* workqueue operations to update the local
688   filesystem after the database operation.
689
690   To maintain a consistent database this function will also remove
691   any working node that marks LOCAL_ABSPATH as base-deleted.  If this
692   results in there being no working node for LOCAL_ABSPATH then any
693   actual node will be removed if the actual node does not mark a
694   conflict.
695
696   If KEEP_AS_WORKING is TRUE, then the base tree is copied to higher
697   layers as a copy of itself before deleting the BASE nodes.
698
699   If KEEP_AS_WORKING is FALSE, and QUEUE_DELETES is TRUE, also queue
700   workqueue items to delete all in-wc representations that aren't
701   shadowed by higher layers.
702   (With KEEP_AS_WORKING TRUE, this is a no-op, as everything is
703    automatically shadowed by the created copy)
704
705   If REMOVE_LOCKS is TRUE, all locks of this node and any subnodes
706   are also removed. This is to be done during commit of deleted nodes.
707
708   If NOT_PRESENT_REVISION specifies a valid revision a not-present
709   node is installed in BASE node with kind NOT_PRESENT_KIND after
710   deleting.
711
712   If CONFLICT and/or WORK_ITEMS are passed they are installed as part
713   of the operation, after the work items inserted by the operation
714   itself.
715*/
716svn_error_t *
717svn_wc__db_base_remove(svn_wc__db_t *db,
718                       const char *local_abspath,
719                       svn_boolean_t keep_as_working,
720                       svn_boolean_t queue_deletes,
721                       svn_boolean_t remove_locks,
722                       svn_revnum_t not_present_revision,
723                       svn_skel_t *conflict,
724                       svn_skel_t *work_items,
725                       apr_pool_t *scratch_pool);
726
727
728/* Retrieve information about a node in the BASE tree.
729
730   For the BASE node implied by LOCAL_ABSPATH from the local filesystem,
731   return information in the provided OUT parameters. Each OUT parameter
732   may be NULL, indicating that specific item is not requested.
733
734   If there is no information about this node, then SVN_ERR_WC_PATH_NOT_FOUND
735   will be returned.
736
737   The OUT parameters, and their "not available" values are:
738     STATUS             n/a (always available)
739     KIND               n/a (always available)
740     REVISION           SVN_INVALID_REVNUM
741     REPOS_RELPATH      NULL (caller should scan up)
742     REPOS_ROOT_URL     NULL (caller should scan up)
743     REPOS_UUID         NULL (caller should scan up)
744     CHANGED_REV        SVN_INVALID_REVNUM
745     CHANGED_DATE       0
746     CHANGED_AUTHOR     NULL
747     DEPTH              svn_depth_unknown
748     CHECKSUM           NULL
749     TARGET             NULL
750     LOCK               NULL
751
752     HAD_PROPS          FALSE
753     PROPS              NULL
754
755     UPDATE_ROOT        FALSE
756
757   If the STATUS is normal, the REPOS_* values will be non-NULL.
758
759   If DEPTH is requested, and the node is NOT a directory, then the
760   value will be set to svn_depth_unknown. If LOCAL_ABSPATH is a link,
761   it's up to the caller to resolve depth for the link's target.
762
763   If CHECKSUM is requested, and the node is NOT a file, then it will
764   be set to NULL.
765
766   If TARGET is requested, and the node is NOT a symlink, then it will
767   be set to NULL.
768
769   *PROPS maps "const char *" names to "const svn_string_t *" values.  If
770   the base node is capable of having properties but has none, set
771   *PROPS to an empty hash.  If its status is such that it cannot have
772   properties, set *PROPS to NULL.
773
774   If UPDATE_ROOT is requested, set it to TRUE if the node should only
775   be updated when it is the root of an update (e.g. file externals).
776
777   All returned data will be allocated in RESULT_POOL. All temporary
778   allocations will be made in SCRATCH_POOL.
779*/
780svn_error_t *
781svn_wc__db_base_get_info(svn_wc__db_status_t *status,
782                         svn_node_kind_t *kind,
783                         svn_revnum_t *revision,
784                         const char **repos_relpath,
785                         const char **repos_root_url,
786                         const char **repos_uuid,
787                         svn_revnum_t *changed_rev,
788                         apr_time_t *changed_date,
789                         const char **changed_author,
790                         svn_depth_t *depth,
791                         const svn_checksum_t **checksum,
792                         const char **target,
793                         svn_wc__db_lock_t **lock,
794                         svn_boolean_t *had_props,
795                         apr_hash_t **props,
796                         svn_boolean_t *update_root,
797                         svn_wc__db_t *db,
798                         const char *local_abspath,
799                         apr_pool_t *result_pool,
800                         apr_pool_t *scratch_pool);
801
802/* Structure returned by svn_wc__db_base_get_children_info.  Only has the
803   fields needed by the adm crawler. */
804struct svn_wc__db_base_info_t {
805  svn_wc__db_status_t status;
806  svn_node_kind_t kind;
807  svn_revnum_t revnum;
808  const char *repos_relpath;
809  const char *repos_root_url;
810  svn_depth_t depth;
811  svn_boolean_t update_root;
812  svn_wc__db_lock_t *lock;
813};
814
815/* Return in *NODES a hash mapping name->struct svn_wc__db_base_info_t for
816   the children of DIR_ABSPATH at op_depth 0.
817 */
818svn_error_t *
819svn_wc__db_base_get_children_info(apr_hash_t **nodes,
820                                  svn_wc__db_t *db,
821                                  const char *dir_abspath,
822                                  apr_pool_t *result_pool,
823                                  apr_pool_t *scratch_pool);
824
825
826/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the BASE tree.
827
828   *PROPS maps "const char *" names to "const svn_string_t *" values.
829   If the node has no properties, set *PROPS to an empty hash.
830   *PROPS will never be set to NULL.
831   If the node is not present in the BASE tree (with presence 'normal'
832   or 'incomplete'), return an error.
833   Allocate *PROPS and its keys and values in RESULT_POOL.
834*/
835svn_error_t *
836svn_wc__db_base_get_props(apr_hash_t **props,
837                          svn_wc__db_t *db,
838                          const char *local_abspath,
839                          apr_pool_t *result_pool,
840                          apr_pool_t *scratch_pool);
841
842
843/* Return a list of the BASE tree node's children's names.
844
845   For the node indicated by LOCAL_ABSPATH, this function will return
846   the names of all of its children in the array CHILDREN. The array
847   elements are const char * values.
848
849   If the node is not a directory, then SVN_ERR_WC_NOT_WORKING_COPY will
850   be returned.
851
852   All returned data will be allocated in RESULT_POOL. All temporary
853   allocations will be made in SCRATCH_POOL.
854*/
855svn_error_t *
856svn_wc__db_base_get_children(const apr_array_header_t **children,
857                             svn_wc__db_t *db,
858                             const char *local_abspath,
859                             apr_pool_t *result_pool,
860                             apr_pool_t *scratch_pool);
861
862
863/* Set the dav cache for LOCAL_ABSPATH to PROPS.  Use SCRATCH_POOL for
864   temporary allocations. */
865svn_error_t *
866svn_wc__db_base_set_dav_cache(svn_wc__db_t *db,
867                              const char *local_abspath,
868                              const apr_hash_t *props,
869                              apr_pool_t *scratch_pool);
870
871
872/* Retrieve the dav cache for LOCAL_ABSPATH into *PROPS, allocated in
873   RESULT_POOL.  Use SCRATCH_POOL for temporary allocations.  Return
874   SVN_ERR_WC_PATH_NOT_FOUND if no dav cache can be located for
875   LOCAL_ABSPATH in DB.  */
876svn_error_t *
877svn_wc__db_base_get_dav_cache(apr_hash_t **props,
878                              svn_wc__db_t *db,
879                              const char *local_abspath,
880                              apr_pool_t *result_pool,
881                              apr_pool_t *scratch_pool);
882
883/* Recursively clear the dav cache for LOCAL_ABSPATH.  Use
884   SCRATCH_POOL for temporary allocations. */
885svn_error_t *
886svn_wc__db_base_clear_dav_cache_recursive(svn_wc__db_t *db,
887                                          const char *local_abspath,
888                                          apr_pool_t *scratch_pool);
889
890/* Set LOCK_TOKENS to a hash mapping const char * full URLs to const char *
891 * lock tokens for every base node at or under LOCAL_ABSPATH in DB which has
892 * such a lock token set on it.
893 * Allocate the hash and all items therein from RESULT_POOL.  */
894svn_error_t *
895svn_wc__db_base_get_lock_tokens_recursive(apr_hash_t **lock_tokens,
896                                          svn_wc__db_t *db,
897                                          const char *local_abspath,
898                                          apr_pool_t *result_pool,
899                                          apr_pool_t *scratch_pool);
900
901/* ### anything else needed for maintaining the BASE tree? */
902
903
904/* @} */
905
906/* @defgroup svn_wc__db_pristine  Pristine ("text base") management
907   @{
908*/
909
910/* Set *PRISTINE_ABSPATH to the path to the pristine text file
911   identified by SHA1_CHECKSUM.  Error if it does not exist.
912
913   ### This is temporary - callers should not be looking at the file
914   directly.
915
916   Allocate the path in RESULT_POOL. */
917svn_error_t *
918svn_wc__db_pristine_get_path(const char **pristine_abspath,
919                             svn_wc__db_t *db,
920                             const char *wri_abspath,
921                             const svn_checksum_t *checksum,
922                             apr_pool_t *result_pool,
923                             apr_pool_t *scratch_pool);
924
925/* Set *PRISTINE_ABSPATH to the path under WCROOT_ABSPATH that will be
926   used by the pristine text identified by SHA1_CHECKSUM.  The file
927   need not exist.
928 */
929svn_error_t *
930svn_wc__db_pristine_get_future_path(const char **pristine_abspath,
931                                    const char *wcroot_abspath,
932                                    const svn_checksum_t *sha1_checksum,
933                                    apr_pool_t *result_pool,
934                                    apr_pool_t *scratch_pool);
935
936
937/* If requested set *CONTENTS to a readable stream that will yield the pristine
938   text identified by SHA1_CHECKSUM (must be a SHA-1 checksum) within the WC
939   identified by WRI_ABSPATH in DB.
940
941   If requested set *SIZE to the size of the pristine stream in bytes,
942
943   Even if the pristine text is removed from the store while it is being
944   read, the stream will remain valid and readable until it is closed.
945
946   Allocate the stream in RESULT_POOL. */
947svn_error_t *
948svn_wc__db_pristine_read(svn_stream_t **contents,
949                         svn_filesize_t *size,
950                         svn_wc__db_t *db,
951                         const char *wri_abspath,
952                         const svn_checksum_t *sha1_checksum,
953                         apr_pool_t *result_pool,
954                         apr_pool_t *scratch_pool);
955
956
957/* Set *TEMP_DIR_ABSPATH to a directory in which the caller should create
958   a uniquely named file for later installation as a pristine text file.
959
960   The directory is guaranteed to be one that svn_wc__db_pristine_install()
961   can use: specifically, one from which it can atomically move the file.
962
963   Allocate *TEMP_DIR_ABSPATH in RESULT_POOL. */
964svn_error_t *
965svn_wc__db_pristine_get_tempdir(const char **temp_dir_abspath,
966                                svn_wc__db_t *db,
967                                const char *wri_abspath,
968                                apr_pool_t *result_pool,
969                                apr_pool_t *scratch_pool);
970
971
972/* Install the file TEMPFILE_ABSPATH (which is sitting in a directory given by
973   svn_wc__db_pristine_get_tempdir()) into the pristine data store, to be
974   identified by the SHA-1 checksum of its contents, SHA1_CHECKSUM, and whose
975   MD-5 checksum is MD5_CHECKSUM. */
976svn_error_t *
977svn_wc__db_pristine_install(svn_wc__db_t *db,
978                            const char *tempfile_abspath,
979                            const svn_checksum_t *sha1_checksum,
980                            const svn_checksum_t *md5_checksum,
981                            apr_pool_t *scratch_pool);
982
983
984/* Set *MD5_CHECKSUM to the MD-5 checksum of a pristine text
985   identified by its SHA-1 checksum SHA1_CHECKSUM. Return an error
986   if the pristine text does not exist or its MD5 checksum is not found.
987
988   Allocate *MD5_CHECKSUM in RESULT_POOL. */
989svn_error_t *
990svn_wc__db_pristine_get_md5(const svn_checksum_t **md5_checksum,
991                            svn_wc__db_t *db,
992                            const char *wri_abspath,
993                            const svn_checksum_t *sha1_checksum,
994                            apr_pool_t *result_pool,
995                            apr_pool_t *scratch_pool);
996
997
998/* Set *SHA1_CHECKSUM to the SHA-1 checksum of a pristine text
999   identified by its MD-5 checksum MD5_CHECKSUM. Return an error
1000   if the pristine text does not exist or its SHA-1 checksum is not found.
1001
1002   Note: The MD-5 checksum is not strictly guaranteed to be unique in the
1003   database table, although duplicates are expected to be extremely rare.
1004   ### TODO: The behaviour is currently unspecified if the MD-5 checksum is
1005   not unique. Need to see whether this function is going to stay in use,
1006   and, if so, address this somehow.
1007
1008   Allocate *SHA1_CHECKSUM in RESULT_POOL. */
1009svn_error_t *
1010svn_wc__db_pristine_get_sha1(const svn_checksum_t **sha1_checksum,
1011                             svn_wc__db_t *db,
1012                             const char *wri_abspath,
1013                             const svn_checksum_t *md5_checksum,
1014                             apr_pool_t *result_pool,
1015                             apr_pool_t *scratch_pool);
1016
1017
1018/* If necessary transfers the PRISTINE files of the tree rooted at
1019   SRC_LOCAL_ABSPATH to the working copy identified by DST_WRI_ABSPATH. */
1020svn_error_t *
1021svn_wc__db_pristine_transfer(svn_wc__db_t *db,
1022                             const char *src_local_abspath,
1023                             const char *dst_wri_abspath,
1024                             svn_cancel_func_t cancel_func,
1025                             void *cancel_baton,
1026                             apr_pool_t *scratch_pool);
1027
1028/* Remove the pristine text with SHA-1 checksum SHA1_CHECKSUM from the
1029 * pristine store, iff it is not referenced by any of the (other) WC DB
1030 * tables. */
1031svn_error_t *
1032svn_wc__db_pristine_remove(svn_wc__db_t *db,
1033                           const char *wri_abspath,
1034                           const svn_checksum_t *sha1_checksum,
1035                           apr_pool_t *scratch_pool);
1036
1037
1038/* Remove all unreferenced pristines in the WC of WRI_ABSPATH in DB. */
1039svn_error_t *
1040svn_wc__db_pristine_cleanup(svn_wc__db_t *db,
1041                            const char *wri_abspath,
1042                            apr_pool_t *scratch_pool);
1043
1044
1045/* Set *PRESENT to true if the pristine store for WRI_ABSPATH in DB contains
1046   a pristine text with SHA-1 checksum SHA1_CHECKSUM, and to false otherwise.
1047*/
1048svn_error_t *
1049svn_wc__db_pristine_check(svn_boolean_t *present,
1050                          svn_wc__db_t *db,
1051                          const char *wri_abspath,
1052                          const svn_checksum_t *sha1_checksum,
1053                          apr_pool_t *scratch_pool);
1054
1055/* @defgroup svn_wc__db_external  External management
1056   @{ */
1057
1058/* Adds (or overwrites) a file external LOCAL_ABSPATH to the working copy
1059   identified by WRI_ABSPATH.
1060
1061   It updates both EXTERNALS and NODES in one atomic step.
1062 */
1063svn_error_t *
1064svn_wc__db_external_add_file(svn_wc__db_t *db,
1065                             const char *local_abspath,
1066                             const char *wri_abspath,
1067
1068                             const char *repos_relpath,
1069                             const char *repos_root_url,
1070                             const char *repos_uuid,
1071                             svn_revnum_t revision,
1072
1073                             const apr_hash_t *props,
1074                             apr_array_header_t *iprops,
1075
1076                             svn_revnum_t changed_rev,
1077                             apr_time_t changed_date,
1078                             const char *changed_author,
1079
1080                             const svn_checksum_t *checksum,
1081
1082                             const apr_hash_t *dav_cache,
1083
1084                             const char *record_ancestor_abspath,
1085                             const char *recorded_repos_relpath,
1086                             svn_revnum_t recorded_peg_revision,
1087                             svn_revnum_t recorded_revision,
1088
1089                             svn_boolean_t update_actual_props,
1090                             apr_hash_t *new_actual_props,
1091
1092                             svn_boolean_t keep_recorded_info,
1093                             const svn_skel_t *conflict,
1094                             const svn_skel_t *work_items,
1095                             apr_pool_t *scratch_pool);
1096
1097/* Adds (or overwrites) a symlink external LOCAL_ABSPATH to the working copy
1098   identified by WRI_ABSPATH.
1099 */
1100svn_error_t *
1101svn_wc__db_external_add_symlink(svn_wc__db_t *db,
1102                                const char *local_abspath,
1103                                const char *wri_abspath,
1104
1105                                const char *repos_relpath,
1106                                const char *repos_root_url,
1107                                const char *repos_uuid,
1108                                svn_revnum_t revision,
1109
1110                                const apr_hash_t *props,
1111
1112                                svn_revnum_t changed_rev,
1113                                apr_time_t changed_date,
1114                                const char *changed_author,
1115
1116                                const char *target,
1117
1118                                const apr_hash_t *dav_cache,
1119
1120                                const char *record_ancestor_abspath,
1121                                const char *recorded_repos_relpath,
1122                                svn_revnum_t recorded_peg_revision,
1123                                svn_revnum_t recorded_revision,
1124
1125                                svn_boolean_t update_actual_props,
1126                                apr_hash_t *new_actual_props,
1127
1128                                svn_boolean_t keep_recorded_info,
1129                                const svn_skel_t *work_items,
1130                                apr_pool_t *scratch_pool);
1131
1132/* Adds (or overwrites) a directory external LOCAL_ABSPATH to the working copy
1133   identified by WRI_ABSPATH.
1134
1135  Directory externals are stored in their own working copy, so one should use
1136  the normal svn_wc__db functions to access the normal working copy
1137  information.
1138 */
1139svn_error_t *
1140svn_wc__db_external_add_dir(svn_wc__db_t *db,
1141                            const char *local_abspath,
1142                            const char *wri_abspath,
1143
1144                            const char *repos_root_url,
1145                            const char *repos_uuid,
1146
1147                            const char *record_ancestor_abspath,
1148                            const char *recorded_repos_relpath,
1149                            svn_revnum_t recorded_peg_revision,
1150                            svn_revnum_t recorded_revision,
1151
1152                            const svn_skel_t *work_items,
1153                            apr_pool_t *scratch_pool);
1154
1155/* Remove a registered external LOCAL_ABSPATH from the working copy identified
1156   by WRI_ABSPATH.
1157 */
1158svn_error_t *
1159svn_wc__db_external_remove(svn_wc__db_t *db,
1160                           const char *local_abspath,
1161                           const char *wri_abspath,
1162
1163                           const svn_skel_t *work_items,
1164                           apr_pool_t *scratch_pool);
1165
1166
1167/* Reads information on the external LOCAL_ABSPATH as stored in the working
1168   copy identified with WRI_ABSPATH (If NULL the parent directory of
1169   LOCAL_ABSPATH is taken as WRI_ABSPATH).
1170
1171   Return SVN_ERR_WC_PATH_NOT_FOUND if LOCAL_ABSPATH is not an external in
1172   this working copy.
1173
1174   When STATUS is requested it has one of these values
1175      svn_wc__db_status_normal           The external is available
1176      svn_wc__db_status_excluded         The external is user excluded
1177
1178   When KIND is requested then the value will be set to the kind of external.
1179
1180   If DEFINING_ABSPATH is requested, then the value will be set to the
1181   absolute path of the directory which originally defined the external.
1182   (The path with the svn:externals property)
1183
1184   If REPOS_ROOT_URL is requested, then the value will be set to the
1185   repository root of the external.
1186
1187   If REPOS_UUID is requested, then the value will be set to the
1188   repository uuid of the external.
1189
1190   If RECORDED_REPOS_RELPATH is requested, then the value will be set to the
1191   original repository relative path inside REPOS_ROOT_URL of the external.
1192
1193   If RECORDED_PEG_REVISION is requested, then the value will be set to the
1194   original recorded operational (peg) revision of the external.
1195
1196   If RECORDED_REVISION is requested, then the value will be set to the
1197   original recorded revision of the external.
1198
1199   Allocate the result in RESULT_POOL and perform temporary allocations in
1200   SCRATCH_POOL.
1201 */
1202svn_error_t *
1203svn_wc__db_external_read(svn_wc__db_status_t *status,
1204                         svn_node_kind_t *kind,
1205                         const char **defining_abspath,
1206
1207                         const char **repos_root_url,
1208                         const char **repos_uuid,
1209
1210                         const char **recorded_repos_relpath,
1211                         svn_revnum_t *recorded_peg_revision,
1212                         svn_revnum_t *recorded_revision,
1213
1214                         svn_wc__db_t *db,
1215                         const char *local_abspath,
1216                         const char *wri_abspath,
1217                         apr_pool_t *result_pool,
1218                         apr_pool_t *scratch_pool);
1219
1220/* Return in *EXTERNALS a list of svn_wc__committable_external_info_t *
1221 * containing info on externals defined to be checked out below LOCAL_ABSPATH,
1222 * returning only those externals that are not fixed to a specific revision.
1223 *
1224 * If IMMEDIATES_ONLY is TRUE, only those externals defined to be checked out
1225 * as immediate children of LOCAL_ABSPATH are returned (this is useful for
1226 * treating user requested depth < infinity).
1227 *
1228 * If there are no externals to be returned, set *EXTERNALS to NULL. Otherwise
1229 * set *EXTERNALS to an APR array newly cleated in RESULT_POOL.
1230 *
1231 * NOTE: This only returns the externals known by the immediate WC root for
1232 * LOCAL_ABSPATH; i.e.:
1233 * - If there is a further parent WC "above" the immediate WC root, and if
1234 *   that parent WC defines externals to live somewhere within this WC, these
1235 *   externals will appear to be foreign/unversioned and won't be picked up.
1236 * - Likewise, only the topmost level of externals nestings (externals
1237 *   defined within a checked out external dir) is picked up by this function.
1238 *   (For recursion, see svn_wc__committable_externals_below().)
1239 *
1240 * ###TODO: Add a WRI_ABSPATH (wc root indicator) separate from LOCAL_ABSPATH,
1241 * to allow searching any wc-root for externals under LOCAL_ABSPATH, not only
1242 * LOCAL_ABSPATH's most immediate wc-root. */
1243svn_error_t *
1244svn_wc__db_committable_externals_below(apr_array_header_t **externals,
1245                                       svn_wc__db_t *db,
1246                                       const char *local_abspath,
1247                                       svn_boolean_t immediates_only,
1248                                       apr_pool_t *result_pool,
1249                                       apr_pool_t *scratch_pool);
1250
1251/* Gets a mapping from const char * local abspaths of externals to the const
1252   char * local abspath of where they are defined for all externals defined
1253   at or below LOCAL_ABSPATH.
1254
1255   ### Returns NULL in *EXTERNALS until we bumped to format 29.
1256
1257   Allocate the result in RESULT_POOL and perform temporary allocations in
1258   SCRATCH_POOL. */
1259svn_error_t *
1260svn_wc__db_externals_defined_below(apr_hash_t **externals,
1261                                   svn_wc__db_t *db,
1262                                   const char *local_abspath,
1263                                   apr_pool_t *result_pool,
1264                                   apr_pool_t *scratch_pool);
1265
1266/* Gather all svn:externals property values from the actual properties on
1267   directories below LOCAL_ABSPATH as a mapping of const char *local_abspath
1268   to const char * property values.
1269
1270   If DEPTHS is not NULL, set *depths to an apr_hash_t* mapping the same
1271   local_abspaths to the const char * ambient depth of the node.
1272
1273   Allocate the result in RESULT_POOL and perform temporary allocations in
1274   SCRATCH_POOL. */
1275svn_error_t *
1276svn_wc__db_externals_gather_definitions(apr_hash_t **externals,
1277                                        apr_hash_t **depths,
1278                                        svn_wc__db_t *db,
1279                                        const char *local_abspath,
1280                                        apr_pool_t *result_pool,
1281                                        apr_pool_t *scratch_pool);
1282
1283/* @} */
1284
1285/* @defgroup svn_wc__db_op  Operations on WORKING tree
1286   @{
1287*/
1288
1289/* Copy the node at SRC_ABSPATH (in NODES and ACTUAL_NODE tables) to
1290 * DST_ABSPATH, both in DB but not necessarily in the same WC.  The parent
1291 * of DST_ABSPATH must be a versioned directory.
1292 *
1293 * This copy is NOT recursive. It simply establishes this one node, plus
1294 * incomplete nodes for the children.
1295 *
1296 * If IS_MOVE is TRUE, mark this copy operation as the copy-half of
1297 * a move. The delete-half of the move needs to be created separately
1298 * with svn_wc__db_op_delete().
1299 *
1300 * Add WORK_ITEMS to the work queue. */
1301svn_error_t *
1302svn_wc__db_op_copy(svn_wc__db_t *db,
1303                   const char *src_abspath,
1304                   const char *dst_abspath,
1305                   const char *dst_op_root_abspath,
1306                   svn_boolean_t is_move,
1307                   const svn_skel_t *work_items,
1308                   apr_pool_t *scratch_pool);
1309
1310/* Checks if LOCAL_ABSPATH represents a move back to its original location,
1311 * and if it is reverts the move while keeping local changes after it has been
1312 * moved from MOVED_FROM_ABSPATH.
1313 *
1314 * If MOVED_BACK is not NULL, set *MOVED_BACK to TRUE when a move was reverted,
1315 * otherwise to FALSE.
1316 */
1317svn_error_t *
1318svn_wc__db_op_handle_move_back(svn_boolean_t *moved_back,
1319                               svn_wc__db_t *db,
1320                               const char *local_abspath,
1321                               const char *moved_from_abspath,
1322                               const svn_skel_t *work_items,
1323                               apr_pool_t *scratch_pool);
1324
1325
1326/* Copy the leaves of the op_depth layer directly shadowed by the operation
1327 * of SRC_ABSPATH (so SRC_ABSPATH must be an op_root) to dst_abspaths
1328 * parents layer.
1329 *
1330 * This operation is recursive. It copies all the descendants at the lower
1331 * layer and adds base-deleted nodes on dst_abspath layer to mark these nodes
1332 * properly deleted.
1333 *
1334 * Usually this operation is directly followed by a call to svn_wc__db_op_copy
1335 * which performs the real copy from src_abspath to dst_abspath.
1336 */
1337svn_error_t *
1338svn_wc__db_op_copy_shadowed_layer(svn_wc__db_t *db,
1339                                  const char *src_abspath,
1340                                  const char *dst_abspath,
1341                                  svn_boolean_t is_move,
1342                                  apr_pool_t *scratch_pool);
1343
1344
1345/* Record a copy at LOCAL_ABSPATH from a repository directory.
1346
1347   This copy is NOT recursive. It simply establishes this one node.
1348   CHILDREN must be provided, and incomplete nodes will be constructed
1349   for them.
1350
1351   ### arguments docco.  */
1352svn_error_t *
1353svn_wc__db_op_copy_dir(svn_wc__db_t *db,
1354                       const char *local_abspath,
1355                       const apr_hash_t *props,
1356                       svn_revnum_t changed_rev,
1357                       apr_time_t changed_date,
1358                       const char *changed_author,
1359                       const char *original_repos_relpath,
1360                       const char *original_root_url,
1361                       const char *original_uuid,
1362                       svn_revnum_t original_revision,
1363                       const apr_array_header_t *children,
1364                       svn_depth_t depth,
1365                       svn_boolean_t is_move,
1366                       const svn_skel_t *conflict,
1367                       const svn_skel_t *work_items,
1368                       apr_pool_t *scratch_pool);
1369
1370
1371/* Record a copy at LOCAL_ABSPATH from a repository file.
1372
1373   ### arguments docco.  */
1374svn_error_t *
1375svn_wc__db_op_copy_file(svn_wc__db_t *db,
1376                        const char *local_abspath,
1377                        const apr_hash_t *props,
1378                        svn_revnum_t changed_rev,
1379                        apr_time_t changed_date,
1380                        const char *changed_author,
1381                        const char *original_repos_relpath,
1382                        const char *original_root_url,
1383                        const char *original_uuid,
1384                        svn_revnum_t original_revision,
1385                        const svn_checksum_t *checksum,
1386                        svn_boolean_t update_actual_props,
1387                        const apr_hash_t *new_actual_props,
1388                        svn_boolean_t is_move,
1389                        const svn_skel_t *conflict,
1390                        const svn_skel_t *work_items,
1391                        apr_pool_t *scratch_pool);
1392
1393
1394svn_error_t *
1395svn_wc__db_op_copy_symlink(svn_wc__db_t *db,
1396                           const char *local_abspath,
1397                           const apr_hash_t *props,
1398                           svn_revnum_t changed_rev,
1399                           apr_time_t changed_date,
1400                           const char *changed_author,
1401                           const char *original_repos_relpath,
1402                           const char *original_root_url,
1403                           const char *original_uuid,
1404                           svn_revnum_t original_revision,
1405                           const char *target,
1406                           svn_boolean_t is_move,
1407                           const svn_skel_t *conflict,
1408                           const svn_skel_t *work_items,
1409                           apr_pool_t *scratch_pool);
1410
1411
1412/* ### do we need svn_wc__db_op_copy_server_excluded() ??  */
1413
1414
1415/* ### add a new versioned directory. a list of children is NOT passed
1416   ### since they are added in future, distinct calls to db_op_add_*.
1417   PROPS gives the properties; empty or NULL means none. */
1418/* ### do we need a CONFLICTS param?  */
1419svn_error_t *
1420svn_wc__db_op_add_directory(svn_wc__db_t *db,
1421                            const char *local_abspath,
1422                            const apr_hash_t *props,
1423                            const svn_skel_t *work_items,
1424                            apr_pool_t *scratch_pool);
1425
1426
1427/* Add a file.
1428   PROPS gives the properties; empty or NULL means none.
1429   ### this file has no "pristine"
1430   ### contents, so a checksum [reference] is not required.  */
1431/* ### do we need a CONFLICTS param?  */
1432svn_error_t *
1433svn_wc__db_op_add_file(svn_wc__db_t *db,
1434                       const char *local_abspath,
1435                       const apr_hash_t *props,
1436                       const svn_skel_t *work_items,
1437                       apr_pool_t *scratch_pool);
1438
1439
1440/* Add a symlink.
1441   PROPS gives the properties; empty or NULL means none. */
1442/* ### do we need a CONFLICTS param?  */
1443svn_error_t *
1444svn_wc__db_op_add_symlink(svn_wc__db_t *db,
1445                          const char *local_abspath,
1446                          const char *target,
1447                          const apr_hash_t *props,
1448                          const svn_skel_t *work_items,
1449                          apr_pool_t *scratch_pool);
1450
1451
1452/* Set the properties of the node LOCAL_ABSPATH in the ACTUAL tree to
1453   PROPS.
1454
1455   PROPS maps "const char *" names to "const svn_string_t *" values.
1456   To specify no properties, PROPS must be an empty hash, not NULL.
1457   If the node is not present, return an error.
1458
1459   If PROPS is NULL, set the properties to be the same as the pristine
1460   properties.
1461
1462   If CONFLICT is not NULL, it is used to register a conflict on this
1463   node at the same time the properties are changed.
1464
1465   WORK_ITEMS are inserted into the work queue, as additional things that
1466   need to be completed before the working copy is stable.
1467
1468
1469   If CLEAR_RECORDED_INFO is true, the recorded information for the node
1470   is cleared. (commonly used when updating svn:* magic properties).
1471
1472   NOTE: This will overwrite ALL working properties the node currently
1473   has. There is no db_op_set_prop() function. Callers must read all the
1474   properties, change one, and write all the properties.
1475   ### ugh. this has poor transaction semantics...
1476
1477
1478   NOTE: This will create an entry in the ACTUAL table for the node if it
1479   does not yet have one.
1480*/
1481svn_error_t *
1482svn_wc__db_op_set_props(svn_wc__db_t *db,
1483                        const char *local_abspath,
1484                        apr_hash_t *props,
1485                        svn_boolean_t clear_recorded_info,
1486                        const svn_skel_t *conflict,
1487                        const svn_skel_t *work_items,
1488                        apr_pool_t *scratch_pool);
1489
1490/* Mark LOCAL_ABSPATH, and all children, for deletion.
1491 *
1492 * This function removes the file externals (and if DELETE_DIR_EXTERNALS is
1493 * TRUE also the directory externals) registered below LOCAL_ABSPATH.
1494 * (DELETE_DIR_EXTERNALS should be true if also removing unversioned nodes)
1495 *
1496 * If MOVED_TO_ABSPATH is not NULL, mark the deletion of LOCAL_ABSPATH
1497 * as the delete-half of a move from LOCAL_ABSPATH to MOVED_TO_ABSPATH.
1498 *
1499 * If NOTIFY_FUNC is not NULL, then it will be called (with NOTIFY_BATON)
1500 * for each node deleted. While this processing occurs, if CANCEL_FUNC is
1501 * not NULL, then it will be called (with CANCEL_BATON) to detect cancellation
1502 * during the processing.
1503 *
1504 * Note: the notification (and cancellation) occur outside of a SQLite
1505 * transaction.
1506 */
1507svn_error_t *
1508svn_wc__db_op_delete(svn_wc__db_t *db,
1509                     const char *local_abspath,
1510                     const char *moved_to_abspath,
1511                     svn_boolean_t delete_dir_externals,
1512                     svn_skel_t *conflict,
1513                     svn_skel_t *work_items,
1514                     svn_cancel_func_t cancel_func,
1515                     void *cancel_baton,
1516                     svn_wc_notify_func2_t notify_func,
1517                     void *notify_baton,
1518                     apr_pool_t *scratch_pool);
1519
1520
1521/* Mark all LOCAL_ABSPATH in the TARGETS array, and all of their children,
1522 * for deletion.
1523 *
1524 * This function is more efficient than svn_wc__db_op_delete() because
1525 * only one sqlite transaction is used for all targets.
1526 * It currently lacks support for moves (though this could be changed,
1527 * at which point svn_wc__db_op_delete() becomes redundant).
1528 *
1529 * This function removes the file externals (and if DELETE_DIR_EXTERNALS is
1530 * TRUE also the directory externals) registered below the targets.
1531 * (DELETE_DIR_EXTERNALS should be true if also removing unversioned nodes)
1532 *
1533 * If NOTIFY_FUNC is not NULL, then it will be called (with NOTIFY_BATON)
1534 * for each node deleted. While this processing occurs, if CANCEL_FUNC is
1535 * not NULL, then it will be called (with CANCEL_BATON) to detect cancellation
1536 * during the processing.
1537 *
1538 * Note: the notification (and cancellation) occur outside of a SQLite
1539 * transaction.
1540 */
1541svn_error_t *
1542svn_wc__db_op_delete_many(svn_wc__db_t *db,
1543                          apr_array_header_t *targets,
1544                          svn_boolean_t delete_dir_externals,
1545                          const svn_skel_t *conflict,
1546                          svn_cancel_func_t cancel_func,
1547                          void *cancel_baton,
1548                          svn_wc_notify_func2_t notify_func,
1549                          void *notify_baton,
1550                          apr_pool_t *scratch_pool);
1551
1552
1553/* ### mark PATH as (possibly) modified. "svn edit" ... right API here? */
1554svn_error_t *
1555svn_wc__db_op_modified(svn_wc__db_t *db,
1556                       const char *local_abspath,
1557                       apr_pool_t *scratch_pool);
1558
1559
1560/* ### use NULL to remove from a changelist.
1561
1562   ### NOTE: only depth=svn_depth_empty is supported right now.
1563 */
1564svn_error_t *
1565svn_wc__db_op_set_changelist(svn_wc__db_t *db,
1566                             const char *local_abspath,
1567                             const char *new_changelist,
1568                             const apr_array_header_t *changelist_filter,
1569                             svn_depth_t depth,
1570                             /* ### flip to CANCEL, then NOTIFY. precedent.  */
1571                             svn_wc_notify_func2_t notify_func,
1572                             void *notify_baton,
1573                             svn_cancel_func_t cancel_func,
1574                             void *cancel_baton,
1575                             apr_pool_t *scratch_pool);
1576
1577/* Record CONFLICT on LOCAL_ABSPATH, potentially replacing other conflicts
1578   recorded on LOCAL_ABSPATH.
1579
1580   Users should in most cases pass CONFLICT to another WC_DB call instead of
1581   calling svn_wc__db_op_mark_conflict() directly outside a transaction, to
1582   allow recording atomically with the operation involved.
1583
1584   Any work items that are necessary as part of marking this node conflicted
1585   can be passed in WORK_ITEMS.
1586 */
1587svn_error_t *
1588svn_wc__db_op_mark_conflict(svn_wc__db_t *db,
1589                            const char *local_abspath,
1590                            const svn_skel_t *conflict,
1591                            const svn_skel_t *work_items,
1592                            apr_pool_t *scratch_pool);
1593
1594
1595/* ### caller maintains ACTUAL, and how the resolution occurred. we're just
1596   ### recording state.
1597   ###
1598   ### I'm not sure that these three values are the best way to do this,
1599   ### but they're handy for now.  */
1600svn_error_t *
1601svn_wc__db_op_mark_resolved(svn_wc__db_t *db,
1602                            const char *local_abspath,
1603                            svn_boolean_t resolved_text,
1604                            svn_boolean_t resolved_props,
1605                            svn_boolean_t resolved_tree,
1606                            const svn_skel_t *work_items,
1607                            apr_pool_t *scratch_pool);
1608
1609
1610/* Revert all local changes which are being maintained in the database,
1611 * including conflict storage, properties and text modification status.
1612 *
1613 * Returns SVN_ERR_WC_INVALID_OPERATION_DEPTH if the revert is not
1614 * possible, e.g. copy/delete but not a root, or a copy root with
1615 * children.
1616 *
1617 * At present only depth=empty and depth=infinity are supported.
1618 *
1619 * This function populates the revert list that can be queried to
1620 * determine what was reverted.
1621 */
1622svn_error_t *
1623svn_wc__db_op_revert(svn_wc__db_t *db,
1624                     const char *local_abspath,
1625                     svn_depth_t depth,
1626                     apr_pool_t *result_pool,
1627                     apr_pool_t *scratch_pool);
1628
1629/* Query the revert list for LOCAL_ABSPATH and set *REVERTED if the
1630 * path was reverted.  Set *MARKER_FILES to a const char *list of
1631 * marker files if any were recorded on LOCAL_ABSPATH.
1632 *
1633 * Set *COPIED_HERE if the reverted node was copied here and is the
1634 * operation root of the copy.
1635 * Set *KIND to the node kind of the reverted node.
1636 *
1637 * Removes the row for LOCAL_ABSPATH from the revert list.
1638 */
1639svn_error_t *
1640svn_wc__db_revert_list_read(svn_boolean_t *reverted,
1641                            const apr_array_header_t **marker_files,
1642                            svn_boolean_t *copied_here,
1643                            svn_node_kind_t *kind,
1644                            svn_wc__db_t *db,
1645                            const char *local_abspath,
1646                            apr_pool_t *result_pool,
1647                            apr_pool_t *scratch_pool);
1648
1649/* The type of elements in the array returned by
1650 * svn_wc__db_revert_list_read_copied_children(). */
1651typedef struct svn_wc__db_revert_list_copied_child_info_t {
1652  const char *abspath;
1653  svn_node_kind_t kind;
1654} svn_wc__db_revert_list_copied_child_info_t ;
1655
1656/* Return in *CHILDREN a list of reverted copied nodes at or within
1657 * LOCAL_ABSPATH (which is a reverted file or a reverted directory).
1658 * Allocate *COPIED_CHILDREN and its elements in RESULT_POOL.
1659 * The elements are of type svn_wc__db_revert_list_copied_child_info_t. */
1660svn_error_t *
1661svn_wc__db_revert_list_read_copied_children(const apr_array_header_t **children,
1662                                            svn_wc__db_t *db,
1663                                            const char *local_abspath,
1664                                            apr_pool_t *result_pool,
1665                                            apr_pool_t *scratch_pool);
1666
1667
1668/* Make revert notifications for all paths in the revert list that are
1669 * equal to LOCAL_ABSPATH or below LOCAL_ABSPATH.
1670 *
1671 * Removes all the corresponding rows from the revert list.
1672 *
1673 * ### Pass in cancel_func?
1674 */
1675svn_error_t *
1676svn_wc__db_revert_list_notify(svn_wc_notify_func2_t notify_func,
1677                              void *notify_baton,
1678                              svn_wc__db_t *db,
1679                              const char *local_abspath,
1680                              apr_pool_t *scratch_pool);
1681
1682/* Clean up after svn_wc__db_op_revert by removing the revert list.
1683 */
1684svn_error_t *
1685svn_wc__db_revert_list_done(svn_wc__db_t *db,
1686                            const char *local_abspath,
1687                            apr_pool_t *scratch_pool);
1688
1689/* ### status */
1690
1691
1692/* @} */
1693
1694/* @defgroup svn_wc__db_read  Read operations on the BASE/WORKING tree
1695   @{
1696
1697   These functions query information about nodes in ACTUAL, and returns
1698   the requested information from the appropriate ACTUAL, WORKING, or
1699   BASE tree.
1700
1701   For example, asking for the checksum of the pristine version will
1702   return the one recorded in WORKING, or if no WORKING node exists, then
1703   the checksum comes from BASE.
1704*/
1705
1706/* Retrieve information about a node.
1707
1708   For the node implied by LOCAL_ABSPATH from the local filesystem, return
1709   information in the provided OUT parameters. Each OUT parameter may be
1710   NULL, indicating that specific item is not requested.
1711
1712   The information returned comes from the BASE tree, as possibly modified
1713   by the WORKING and ACTUAL trees.
1714
1715   If there is no information about the node, then SVN_ERR_WC_PATH_NOT_FOUND
1716   will be returned.
1717
1718   The OUT parameters, and their "not available" values are:
1719     STATUS                  n/a (always available)
1720     KIND                    svn_node_unknown   (For ACTUAL only nodes)
1721     REVISION                SVN_INVALID_REVNUM
1722     REPOS_RELPATH           NULL
1723     REPOS_ROOT_URL          NULL
1724     REPOS_UUID              NULL
1725     CHANGED_REV             SVN_INVALID_REVNUM
1726     CHANGED_DATE            0
1727     CHANGED_AUTHOR          NULL
1728     DEPTH                   svn_depth_unknown
1729     CHECKSUM                NULL
1730     TARGET                  NULL
1731
1732     ORIGINAL_REPOS_RELPATH  NULL
1733     ORIGINAL_ROOT_URL       NULL
1734     ORIGINAL_UUID           NULL
1735     ORIGINAL_REVISION       SVN_INVALID_REVNUM
1736
1737     LOCK                    NULL
1738
1739     RECORDED_SIZE           SVN_INVALID_FILESIZE
1740     RECORDED_TIME       0
1741
1742     CHANGELIST              NULL
1743     CONFLICTED              FALSE
1744
1745     OP_ROOT                 FALSE
1746     HAD_PROPS               FALSE
1747     PROPS_MOD               FALSE
1748
1749     HAVE_BASE               FALSE
1750     HAVE_MORE_WORK          FALSE
1751     HAVE_WORK               FALSE
1752
1753   When STATUS is requested, then it will be one of these values:
1754
1755     svn_wc__db_status_normal
1756       A plain BASE node, with no local changes.
1757
1758     svn_wc__db_status_added
1759       A node has been added/copied/moved to here. See HAVE_BASE to see
1760       if this change overwrites a BASE node. Use scan_addition() to resolve
1761       whether this has been added, copied, or moved, and the details of the
1762       operation (this function only looks at LOCAL_ABSPATH, but resolving
1763       the details requires scanning one or more ancestor nodes).
1764
1765     svn_wc__db_status_deleted
1766       This node has been deleted or moved away. It may be a delete/move of
1767       a BASE node, or a child node of a subtree that was copied/moved to
1768       an ancestor location. Call scan_deletion() to determine the full
1769       details of the operations upon this node.
1770
1771     svn_wc__db_status_server_excluded
1772       The node is versioned/known by the server, but the server has
1773       decided not to provide further information about the node. This
1774       is a BASE node (since changes are not allowed to this node).
1775
1776     svn_wc__db_status_excluded
1777       The node has been excluded from the working copy tree. This may
1778       be an exclusion from the BASE tree, or an exclusion in the
1779       WORKING tree for a child node of a copied/moved parent.
1780
1781     svn_wc__db_status_not_present
1782       This is a node from the BASE tree, has been marked as "not-present"
1783       within this mixed-revision working copy. This node is at a revision
1784       that is not in the tree, contrary to its inclusion in the parent
1785       node's revision.
1786
1787     svn_wc__db_status_incomplete
1788       The BASE is incomplete due to an interrupted operation.  An
1789       incomplete WORKING node will be svn_wc__db_status_added.
1790
1791   If REVISION is requested, it will be set to the revision of the
1792   unmodified (BASE) node, or to SVN_INVALID_REVNUM if any structural
1793   changes have been made to that node (that is, if the node has a row in
1794   the WORKING table).
1795
1796   If DEPTH is requested, and the node is NOT a directory, then
1797   the value will be set to svn_depth_unknown.
1798
1799   If CHECKSUM is requested, and the node is NOT a file, then it will
1800   be set to NULL.
1801
1802   If TARGET is requested, and the node is NOT a symlink, then it will
1803   be set to NULL.
1804
1805   If TRANSLATED_SIZE is requested, and the node is NOT a file, then
1806   it will be set to SVN_INVALID_FILESIZE.
1807
1808   If HAVE_WORK is TRUE, the returned information is from the highest WORKING
1809   layer. In that case HAVE_MORE_WORK and HAVE_BASE provide information about
1810   what other layers exist for this node.
1811
1812   If HAVE_WORK is FALSE and HAVE_BASE is TRUE then the information is from
1813   the BASE tree.
1814
1815   If HAVE_WORK and HAVE_BASE are both FALSE and when retrieving CONFLICTED,
1816   then the node doesn't exist at all.
1817
1818   If OP_ROOT is requested and the node has a WORKING layer, OP_ROOT will be
1819   set to true if this node is the op_root for this layer.
1820
1821   If HAD_PROPS is requested and the node has pristine props, the value will
1822   be set to TRUE.
1823
1824   If PROPS_MOD is requested and the node has property modification the value
1825   will be set to TRUE.
1826
1827   ### add information about the need to scan upwards to get a complete
1828   ### picture of the state of this node.
1829
1830   ### add some documentation about OUT parameter values based on STATUS ??
1831
1832   ### the TEXT_MOD may become an enumerated value at some point to
1833   ### indicate different states of knowledge about text modifications.
1834   ### for example, an "svn edit" command in the future might set a
1835   ### flag indicating administratively-defined modification. and/or we
1836   ### might have a status indicating that we saw it was modified while
1837   ### performing a filesystem traversal.
1838
1839   All returned data will be allocated in RESULT_POOL. All temporary
1840   allocations will be made in SCRATCH_POOL.
1841*/
1842/* ### old docco. needs to be incorporated as appropriate. there is
1843   ### some pending, potential changes to the definition of this API,
1844   ### so not worrying about it just yet.
1845
1846   ### if the node has not been committed (after adding):
1847   ###   revision will be SVN_INVALID_REVNUM
1848   ###   repos_* will be NULL
1849   ###   changed_rev will be SVN_INVALID_REVNUM
1850   ###   changed_date will be 0
1851   ###   changed_author will be NULL
1852   ###   status will be svn_wc__db_status_added
1853   ###   text_mod will be TRUE
1854   ###   prop_mod will be TRUE if any props have been set
1855   ###   base_shadowed will be FALSE
1856
1857   ### if the node is not a copy, or a move destination:
1858   ###   original_repos_path will be NULL
1859   ###   original_root_url will be NULL
1860   ###   original_uuid will be NULL
1861   ###   original_revision will be SVN_INVALID_REVNUM
1862
1863   ### note that @a base_shadowed can be derived. if the status specifies
1864   ### an add/copy/move *and* there is a corresponding node in BASE, then
1865   ### the BASE has been deleted to open the way for this node.
1866*/
1867svn_error_t *
1868svn_wc__db_read_info(svn_wc__db_status_t *status,  /* ### derived */
1869                     svn_node_kind_t *kind,
1870                     svn_revnum_t *revision,
1871                     const char **repos_relpath,
1872                     const char **repos_root_url,
1873                     const char **repos_uuid,
1874                     svn_revnum_t *changed_rev,
1875                     apr_time_t *changed_date,
1876                     const char **changed_author,
1877                     svn_depth_t *depth,  /* dirs only */
1878                     const svn_checksum_t **checksum, /* files only */
1879                     const char **target, /* symlinks only */
1880
1881                     /* ### the following fields if copied/moved (history) */
1882                     const char **original_repos_relpath,
1883                     const char **original_root_url,
1884                     const char **original_uuid,
1885                     svn_revnum_t *original_revision,
1886
1887                     /* For BASE nodes */
1888                     svn_wc__db_lock_t **lock,
1889
1890                     /* Recorded for files present in the working copy */
1891                     svn_filesize_t *recorded_size,
1892                     apr_time_t *recorded_time,
1893
1894                     /* From ACTUAL */
1895                     const char **changelist,
1896                     svn_boolean_t *conflicted,
1897
1898                     /* ### the followed are derived fields */
1899                     svn_boolean_t *op_root,
1900
1901                     svn_boolean_t *had_props,
1902                     svn_boolean_t *props_mod,
1903
1904                     svn_boolean_t *have_base,
1905                     svn_boolean_t *have_more_work,
1906                     svn_boolean_t *have_work,
1907
1908                     svn_wc__db_t *db,
1909                     const char *local_abspath,
1910                     apr_pool_t *result_pool,
1911                     apr_pool_t *scratch_pool);
1912
1913/* Structure used as linked list in svn_wc__db_info_t to describe all nodes
1914   in this location that were moved to another location */
1915struct svn_wc__db_moved_to_info_t
1916{
1917  const char *moved_to_abspath;
1918  const char *shadow_op_root_abspath;
1919
1920  struct svn_wc__db_moved_to_info_t *next;
1921};
1922
1923/* Structure returned by svn_wc__db_read_children_info.  Only has the
1924   fields needed by status. */
1925struct svn_wc__db_info_t {
1926  svn_wc__db_status_t status;
1927  svn_node_kind_t kind;
1928  svn_revnum_t revnum;
1929  const char *repos_relpath;
1930  const char *repos_root_url;
1931  const char *repos_uuid;
1932  svn_revnum_t changed_rev;
1933  const char *changed_author;
1934  apr_time_t changed_date;
1935  svn_depth_t depth;
1936
1937  svn_filesize_t recorded_size;
1938  apr_time_t recorded_time;
1939
1940  const char *changelist;
1941  svn_boolean_t conflicted;
1942#ifdef HAVE_SYMLINK
1943  svn_boolean_t special;
1944#endif
1945  svn_boolean_t op_root;
1946
1947  svn_boolean_t has_checksum;
1948  svn_boolean_t copied;
1949  svn_boolean_t had_props;
1950  svn_boolean_t props_mod;
1951
1952  svn_boolean_t have_base;
1953  svn_boolean_t have_more_work;
1954
1955  svn_boolean_t locked;     /* WC directory lock */
1956  svn_wc__db_lock_t *lock;  /* Repository file lock */
1957  svn_boolean_t incomplete; /* TRUE if a working node is incomplete */
1958
1959  struct svn_wc__db_moved_to_info_t *moved_to; /* A linked list of locations
1960                                                 where nodes at this path
1961                                                 are moved to. Highest layers
1962                                                 first */
1963  svn_boolean_t moved_here;     /* Only on op-roots. */
1964
1965  svn_boolean_t file_external;
1966};
1967
1968/* Return in *NODES a hash mapping name->struct svn_wc__db_info_t for
1969   the children of DIR_ABSPATH, and in *CONFLICTS a hash of names in
1970   conflict.
1971
1972   The results include any path that was a child of a deleted directory that
1973   existed at LOCAL_ABSPATH, even if that directory is now scheduled to be
1974   replaced by the working node at LOCAL_ABSPATH.
1975 */
1976svn_error_t *
1977svn_wc__db_read_children_info(apr_hash_t **nodes,
1978                              apr_hash_t **conflicts,
1979                              svn_wc__db_t *db,
1980                              const char *dir_abspath,
1981                              apr_pool_t *result_pool,
1982                              apr_pool_t *scratch_pool);
1983
1984/* Like svn_wc__db_read_children_info, but only gets an info node for the root
1985   element. */
1986svn_error_t *
1987svn_wc__db_read_single_info(const struct svn_wc__db_info_t **info,
1988                            svn_wc__db_t *db,
1989                            const char *local_abspath,
1990                            apr_pool_t *result_pool,
1991                            apr_pool_t *scratch_pool);
1992
1993/* Structure returned by svn_wc__db_read_walker_info.  Only has the
1994   fields needed by svn_wc__internal_walk_children(). */
1995struct svn_wc__db_walker_info_t {
1996  svn_wc__db_status_t status;
1997  svn_node_kind_t kind;
1998};
1999
2000/* When a node is deleted in WORKING, some of its information is no longer
2001   available. But in some cases it might still be relevant to obtain this
2002   information even when the information isn't stored in the BASE tree.
2003
2004   This function allows access to that specific information.
2005
2006   When a node is not deleted, this node returns the same information
2007   as svn_wc__db_read_info().
2008
2009   All output arguments are optional and behave in the same way as when
2010   calling svn_wc__db_read_info().
2011
2012   (All other information (like original_*) can be obtained via other apis).
2013
2014   *PROPS maps "const char *" names to "const svn_string_t *" values.  If
2015   the pristine node is capable of having properties but has none, set
2016   *PROPS to an empty hash.  If its status is such that it cannot have
2017   properties, set *PROPS to NULL.
2018 */
2019svn_error_t *
2020svn_wc__db_read_pristine_info(svn_wc__db_status_t *status,
2021                              svn_node_kind_t *kind,
2022                              svn_revnum_t *changed_rev,
2023                              apr_time_t *changed_date,
2024                              const char **changed_author,
2025                              svn_depth_t *depth,  /* dirs only */
2026                              const svn_checksum_t **checksum, /* files only */
2027                              const char **target, /* symlinks only */
2028                              svn_boolean_t *had_props,
2029                              apr_hash_t **props,
2030                              svn_wc__db_t *db,
2031                              const char *local_abspath,
2032                              apr_pool_t *result_pool,
2033                              apr_pool_t *scratch_pool);
2034
2035/* Gets the information required to install a pristine file to the working copy
2036
2037   Set WCROOT_ABSPATH to the working copy root, SHA1_CHECKSUM to the
2038   checksum of the node (a valid reference into the pristine store)
2039   and PRISTINE_PROPS to the node's pristine properties (to use for
2040   installing the file).
2041
2042   If WRI_ABSPATH is not NULL, check for information in the working copy
2043   identified by WRI_ABSPATH.
2044   */
2045svn_error_t *
2046svn_wc__db_read_node_install_info(const char **wcroot_abspath,
2047                                  const svn_checksum_t **sha1_checksum,
2048                                  apr_hash_t **pristine_props,
2049                                  apr_time_t *changed_date,
2050                                  svn_wc__db_t *db,
2051                                  const char *local_abspath,
2052                                  const char *wri_abspath,
2053                                  apr_pool_t *result_pool,
2054                                  apr_pool_t *scratch_pool);
2055
2056/* Return in *NODES a hash mapping name->struct svn_wc__db_walker_info_t for
2057   the children of DIR_ABSPATH. "name" is the child's name relative to
2058   DIR_ABSPATH, not an absolute path. */
2059svn_error_t *
2060svn_wc__db_read_children_walker_info(apr_hash_t **nodes,
2061                                     svn_wc__db_t *db,
2062                                     const char *dir_abspath,
2063                                     apr_pool_t *result_pool,
2064                                     apr_pool_t *scratch_pool);
2065
2066
2067/**
2068 * Set *URL to the corresponding url for LOCAL_ABSPATH.
2069 * If the node is added, return the url it will have in the repository.
2070 */
2071svn_error_t *
2072svn_wc__db_read_url(const char **url,
2073                    svn_wc__db_t *db,
2074                    const char *local_abspath,
2075                    apr_pool_t *result_pool,
2076                    apr_pool_t *scratch_pool);
2077
2078
2079/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the ACTUAL
2080   tree (looking through to the WORKING or BASE tree as required).
2081
2082   ### *PROPS will be set to NULL in the following situations:
2083   ### ... tbd
2084
2085   PROPS maps "const char *" names to "const svn_string_t *" values.
2086   If the node has no properties, set *PROPS to an empty hash.
2087   If the node is not present, return an error.
2088   Allocate *PROPS and its keys and values in RESULT_POOL.
2089*/
2090svn_error_t *
2091svn_wc__db_read_props(apr_hash_t **props,
2092                      svn_wc__db_t *db,
2093                      const char *local_abspath,
2094                      apr_pool_t *result_pool,
2095                      apr_pool_t *scratch_pool);
2096
2097/* Call RECEIVER_FUNC, passing RECEIVER_BATON, an absolute path, and
2098 * a hash table mapping <tt>char *</tt> names onto svn_string_t *
2099 * values for any properties of child nodes of LOCAL_ABSPATH (up to DEPTH).
2100 *
2101 * If PRISTINE is FALSE, read the properties from the WORKING layer (highest
2102 * op_depth); if PRISTINE is FALSE, local modifications will be visible.
2103 */
2104svn_error_t *
2105svn_wc__db_read_props_streamily(svn_wc__db_t *db,
2106                                const char *local_abspath,
2107                                svn_depth_t depth,
2108                                svn_boolean_t pristine,
2109                                const apr_array_header_t *changelists,
2110                                svn_wc__proplist_receiver_t receiver_func,
2111                                void *receiver_baton,
2112                                svn_cancel_func_t cancel_func,
2113                                void *cancel_baton,
2114                                apr_pool_t *scratch_pool);
2115
2116
2117/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the WORKING
2118   tree (looking through to the BASE tree as required).
2119
2120   ### *PROPS will set set to NULL in the following situations:
2121   ### ... tbd.  see props.c:svn_wc__get_pristine_props()
2122
2123   *PROPS maps "const char *" names to "const svn_string_t *" values.
2124   If the node has no properties, set *PROPS to an empty hash.
2125   If the node is not present, return an error.
2126   Allocate *PROPS and its keys and values in RESULT_POOL.
2127*/
2128svn_error_t *
2129svn_wc__db_read_pristine_props(apr_hash_t **props,
2130                               svn_wc__db_t *db,
2131                               const char *local_abspath,
2132                               apr_pool_t *result_pool,
2133                               apr_pool_t *scratch_pool);
2134
2135
2136/**
2137 * Set @a *iprops to a depth-first ordered array of
2138 * #svn_prop_inherited_item_t * structures representing the properties
2139 * inherited by @a local_abspath from the ACTUAL tree above
2140 * @a local_abspath (looking through to the WORKING or BASE tree as
2141 * required), up to and including the root of the working copy and
2142 * any cached inherited properties inherited by the root.
2143 *
2144 * The #svn_prop_inherited_item_t->path_or_url members of the
2145 * #svn_prop_inherited_item_t * structures in @a *iprops are
2146 * paths relative to the repository root URL for cached inherited
2147 * properties and absolute working copy paths otherwise.
2148 *
2149 * If ACTUAL_PROPS is not NULL, then set *ACTUAL_PROPS to the actual
2150 * properties stored on LOCAL_ABSPATH.
2151 *
2152 * Allocate @a *iprops in @a result_pool.  Use @a scratch_pool
2153 * for temporary allocations.
2154 */
2155svn_error_t *
2156svn_wc__db_read_inherited_props(apr_array_header_t **iprops,
2157                                apr_hash_t **actual_props,
2158                                svn_wc__db_t *db,
2159                                const char *local_abspath,
2160                                const char *propname,
2161                                apr_pool_t *result_pool,
2162                                apr_pool_t *scratch_pool);
2163
2164/* Read a BASE node's inherited property information.
2165
2166   Set *IPROPS to to a depth-first ordered array of
2167   svn_prop_inherited_item_t * structures representing the cached
2168   inherited properties for the BASE node at LOCAL_ABSPATH.
2169
2170   If no cached properties are found, then set *IPROPS to NULL.
2171   If LOCAL_ABSPATH represents the root of the repository, then set
2172   *IPROPS to an empty array.
2173
2174   Allocate *IPROPS in RESULT_POOL, use SCRATCH_POOL for temporary
2175   allocations. */
2176svn_error_t *
2177svn_wc__db_read_cached_iprops(apr_array_header_t **iprops,
2178                              svn_wc__db_t *db,
2179                              const char *local_abspath,
2180                              apr_pool_t *result_pool,
2181                              apr_pool_t *scratch_pool);
2182
2183/* Find BASE nodes with cached inherited properties.
2184
2185   Set *IPROPS_PATHS to a hash mapping const char * absolute working copy
2186   paths to the repos_relpath of the path for each path in the working copy
2187   at or below LOCAL_ABSPATH, limited by DEPTH, that has cached inherited
2188   properties for the BASE node of the path.
2189
2190   Allocate *IPROP_PATHS in RESULT_POOL.
2191   Use SCRATCH_POOL for temporary allocations. */
2192svn_error_t *
2193svn_wc__db_get_children_with_cached_iprops(apr_hash_t **iprop_paths,
2194                                           svn_depth_t depth,
2195                                           const char *local_abspath,
2196                                           svn_wc__db_t *db,
2197                                           apr_pool_t *result_pool,
2198                                           apr_pool_t *scratch_pool);
2199
2200/** Obtain a mapping of const char * local_abspaths to const svn_string_t*
2201 * property values in *VALUES, of all PROPNAME properties on LOCAL_ABSPATH
2202 * and its descendants.
2203 *
2204 * Allocate the result in RESULT_POOL, and perform temporary allocations in
2205 * SCRATCH_POOL.
2206 */
2207svn_error_t *
2208svn_wc__db_prop_retrieve_recursive(apr_hash_t **values,
2209                                   svn_wc__db_t *db,
2210                                   const char *local_abspath,
2211                                   const char *propname,
2212                                   apr_pool_t *result_pool,
2213                                   apr_pool_t *scratch_pool);
2214
2215/* Set *CHILDREN to a new array of the (const char *) basenames of the
2216   immediate children of the working node at LOCAL_ABSPATH in DB.
2217
2218   Return every path that refers to a child of the working node at
2219   LOCAL_ABSPATH.  Do not include a path just because it was a child of a
2220   deleted directory that existed at LOCAL_ABSPATH if that directory is now
2221   scheduled to be replaced by the working node at LOCAL_ABSPATH.
2222
2223   Allocate *CHILDREN in RESULT_POOL and do temporary allocations in
2224   SCRATCH_POOL.
2225
2226   ### return some basic info for each child? e.g. kind.
2227   ### maybe the data in _read_get_info should be a structure, and this
2228   ### can return a struct for each one.
2229   ### however: _read_get_info can say "not interested", which isn't the
2230   ###   case with a struct. thus, a struct requires fetching and/or
2231   ###   computing all info.
2232*/
2233svn_error_t *
2234svn_wc__db_read_children_of_working_node(const apr_array_header_t **children,
2235                                         svn_wc__db_t *db,
2236                                         const char *local_abspath,
2237                                         apr_pool_t *result_pool,
2238                                         apr_pool_t *scratch_pool);
2239
2240/* Like svn_wc__db_read_children_of_working_node(), except also include any
2241   path that was a child of a deleted directory that existed at
2242   LOCAL_ABSPATH, even if that directory is now scheduled to be replaced by
2243   the working node at LOCAL_ABSPATH.
2244*/
2245svn_error_t *
2246svn_wc__db_read_children(const apr_array_header_t **children,
2247                         svn_wc__db_t *db,
2248                         const char *local_abspath,
2249                         apr_pool_t *result_pool,
2250                         apr_pool_t *scratch_pool);
2251
2252/* Read into *VICTIMS the basenames of the immediate children of
2253   LOCAL_ABSPATH in DB that are conflicted.
2254
2255   In case of tree conflicts a victim doesn't have to be in the
2256   working copy.
2257
2258   Allocate *VICTIMS in RESULT_POOL and do temporary allocations in
2259   SCRATCH_POOL */
2260/* ### This function will probably be removed. */
2261svn_error_t *
2262svn_wc__db_read_conflict_victims(const apr_array_header_t **victims,
2263                                 svn_wc__db_t *db,
2264                                 const char *local_abspath,
2265                                 apr_pool_t *result_pool,
2266                                 apr_pool_t *scratch_pool);
2267
2268/* Read into *MARKER_FILES the absolute paths of the marker files
2269   of conflicts stored on LOCAL_ABSPATH and its immediate children in DB.
2270   The on-disk files may have been deleted by the user.
2271
2272   Allocate *MARKER_FILES in RESULT_POOL and do temporary allocations
2273   in SCRATCH_POOL */
2274svn_error_t *
2275svn_wc__db_get_conflict_marker_files(apr_hash_t **markers,
2276                                     svn_wc__db_t *db,
2277                                     const char *local_abspath,
2278                                     apr_pool_t *result_pool,
2279                                     apr_pool_t *scratch_pool);
2280
2281/* Read the conflict information recorded on LOCAL_ABSPATH in *CONFLICT,
2282   an editable conflict skel.
2283
2284   If the node exists, but does not have a conflict set *CONFLICT to NULL,
2285   otherwise return a SVN_ERR_WC_PATH_NOT_FOUND error.
2286
2287   Allocate *CONFLICTS in RESULT_POOL and do temporary allocations in
2288   SCRATCH_POOL */
2289svn_error_t *
2290svn_wc__db_read_conflict(svn_skel_t **conflict,
2291                         svn_wc__db_t *db,
2292                         const char *local_abspath,
2293                         apr_pool_t *result_pool,
2294                         apr_pool_t *scratch_pool);
2295
2296
2297/* Return the kind of the node in DB at LOCAL_ABSPATH. The WORKING tree will
2298   be examined first, then the BASE tree. If the node is not present in either
2299   tree and ALLOW_MISSING is TRUE, then svn_node_unknown is returned.
2300   If the node is missing and ALLOW_MISSING is FALSE, then it will return
2301   SVN_ERR_WC_PATH_NOT_FOUND.
2302
2303   The SHOW_HIDDEN and SHOW_DELETED flags report certain states as kind none.
2304
2305   When nodes have certain statee they are only reported when:
2306      svn_wc__db_status_not_present         when show_hidden && show_deleted
2307
2308      svn_wc__db_status_excluded            when show_hidden
2309      svn_wc__db_status_server_excluded     when show_hidden
2310
2311      svn_wc__db_status_deleted             when show_deleted
2312
2313   In other cases these nodes are reported with *KIND as svn_node_none.
2314   (See also svn_wc_read_kind2()'s documentation)
2315
2316   Uses SCRATCH_POOL for temporary allocations.  */
2317svn_error_t *
2318svn_wc__db_read_kind(svn_node_kind_t *kind,
2319                     svn_wc__db_t *db,
2320                     const char *local_abspath,
2321                     svn_boolean_t allow_missing,
2322                     svn_boolean_t show_deleted,
2323                     svn_boolean_t show_hidden,
2324                     apr_pool_t *scratch_pool);
2325
2326
2327/* An analog to svn_wc__entry_is_hidden().  Set *HIDDEN to TRUE if
2328   LOCAL_ABSPATH in DB "is not present, and I haven't scheduled something
2329   over the top of it." */
2330svn_error_t *
2331svn_wc__db_node_hidden(svn_boolean_t *hidden,
2332                       svn_wc__db_t *db,
2333                       const char *local_abspath,
2334                       apr_pool_t *scratch_pool);
2335
2336/* Checks if a node replaces a node in a different layer. Also check if it
2337   replaces a BASE (op_depth 0) node or just a node in a higher layer (a copy).
2338   Finally check if this is the root of the replacement, or if the replacement
2339   is initiated by the parent node.
2340
2341   IS_REPLACE_ROOT (if not NULL) is set to TRUE if the node is the root of a
2342   replacement; otherwise to FALSE.
2343
2344   BASE_REPLACE (if not NULL) is set to TRUE if the node directly or indirectly
2345   replaces a node in the BASE tree; otherwise to FALSE.
2346
2347   IS_REPLACE (if not NULL) is set to TRUE if the node directly replaces a node
2348   in a lower layer; otherwise to FALSE.
2349 */
2350svn_error_t *
2351svn_wc__db_node_check_replace(svn_boolean_t *is_replace_root,
2352                              svn_boolean_t *base_replace,
2353                              svn_boolean_t *is_replace,
2354                              svn_wc__db_t *db,
2355                              const char *local_abspath,
2356                              apr_pool_t *scratch_pool);
2357
2358/* ### changelists. return an array, or an iterator interface? how big
2359   ### are these things? are we okay with an in-memory array? examine other
2360   ### changelist usage -- we may already assume the list fits in memory.
2361*/
2362
2363/* The DB-private version of svn_wc__is_wcroot(), which see.
2364 */
2365svn_error_t *
2366svn_wc__db_is_wcroot(svn_boolean_t *is_wcroot,
2367                     svn_wc__db_t *db,
2368                     const char *local_abspath,
2369                     apr_pool_t *scratch_pool);
2370
2371/* Check whether a node is a working copy root and/or switched.
2372
2373   If LOCAL_ABSPATH is the root of a working copy, set *IS_WC_ROOT to TRUE,
2374   otherwise to FALSE.
2375
2376   If LOCAL_ABSPATH is switched against its parent in the same working copy
2377   set *IS_SWITCHED to TRUE, otherwise to FALSE.
2378
2379   If KIND is not null, set *KIND to the node type of LOCAL_ABSPATH.
2380
2381   Any of the output arguments can be null to specify that the result is not
2382   interesting to the caller.
2383
2384   Use SCRATCH_POOL for temporary allocations.
2385 */
2386svn_error_t *
2387svn_wc__db_is_switched(svn_boolean_t *is_wcroot,
2388                       svn_boolean_t *is_switched,
2389                       svn_node_kind_t *kind,
2390                       svn_wc__db_t *db,
2391                       const char *local_abspath,
2392                       apr_pool_t *scratch_pool);
2393
2394
2395/* @} */
2396
2397
2398/* @defgroup svn_wc__db_global  Operations that alter multiple trees
2399   @{
2400*/
2401
2402/* Associate LOCAL_DIR_ABSPATH, and all its children with the repository at
2403   at REPOS_ROOT_URL.  The relative path to the repos root will not change,
2404   just the repository root.  The repos uuid will also remain the same.
2405   This also updates any locks which may exist for the node, as well as any
2406   copyfrom repository information.  Finally, the DAV cache (aka
2407   "wcprops") will be reset for affected entries.
2408
2409   Use SCRATCH_POOL for any temporary allocations.
2410
2411   ### local_dir_abspath "should be" the wcroot or a switch root. all URLs
2412   ### under this directory (depth=infinity) will be rewritten.
2413
2414   ### This API had a depth parameter, which was removed, should it be
2415   ### resurrected?  What's the purpose if we claim relocate is infinitely
2416   ### recursive?
2417
2418   ### Assuming the future ability to copy across repositories, should we
2419   ### refrain from resetting the copyfrom information in this operation?
2420*/
2421svn_error_t *
2422svn_wc__db_global_relocate(svn_wc__db_t *db,
2423                           const char *local_dir_abspath,
2424                           const char *repos_root_url,
2425                           apr_pool_t *scratch_pool);
2426
2427
2428/* ### docco
2429
2430   ### collapse the WORKING and ACTUAL tree changes down into BASE, called
2431       for each committed node.
2432
2433   NEW_REVISION must be the revision number of the revision created by
2434   the commit. It will become the BASE node's 'revnum' and 'changed_rev'
2435   values in the BASE_NODE table.
2436
2437   CHANGED_REVISION is the new 'last changed' revision. If the node is
2438   modified its value is equivalent to NEW_REVISION, but in case of a
2439   descendant of a copy/move it can be an older revision.
2440
2441   CHANGED_DATE is the (server-side) date of CHANGED_REVISION. It may be 0 if
2442   the revprop is missing on the revision.
2443
2444   CHANGED_AUTHOR is the (server-side) author of CHANGED_REVISION. It may be
2445   NULL if the revprop is missing on the revision.
2446
2447   One or both of NEW_CHECKSUM and NEW_CHILDREN should be NULL. For new:
2448     files: NEW_CHILDREN should be NULL
2449     dirs: NEW_CHECKSUM should be NULL
2450     symlinks: both should be NULL
2451
2452   WORK_ITEMS will be place into the work queue.
2453*/
2454svn_error_t *
2455svn_wc__db_global_commit(svn_wc__db_t *db,
2456                         const char *local_abspath,
2457                         svn_revnum_t new_revision,
2458                         svn_revnum_t changed_revision,
2459                         apr_time_t changed_date,
2460                         const char *changed_author,
2461                         const svn_checksum_t *new_checksum,
2462                         const apr_array_header_t *new_children,
2463                         apr_hash_t *new_dav_cache,
2464                         svn_boolean_t keep_changelist,
2465                         svn_boolean_t no_unlock,
2466                         const svn_skel_t *work_items,
2467                         apr_pool_t *scratch_pool);
2468
2469
2470/* ### docco
2471
2472   Perform an "update" operation at this node. It will create/modify a BASE
2473   node, and possibly update the ACTUAL tree's node (e.g put the node into
2474   a conflicted state).
2475
2476   ### there may be cases where we need to tweak an existing WORKING node
2477
2478   ### this operations on a single node, but may affect children
2479
2480   ### the repository cannot be changed with this function, but a "switch"
2481   ### (aka changing repos_relpath) is possible
2482
2483   ### one of NEW_CHILDREN, NEW_CHECKSUM, or NEW_TARGET must be provided.
2484   ### the other two values must be NULL.
2485   ### should this be broken out into an update_(directory|file|symlink) ?
2486
2487   ### how does this differ from base_add_*? just the CONFLICT param.
2488   ### the WORK_ITEMS param is new here, but the base_add_* functions
2489   ### should probably grow that. should we instead just (re)use base_add
2490   ### rather than grow a new function?
2491
2492   ### this does not allow a change of depth
2493
2494   ### we do not update a file's TRANSLATED_SIZE here. at some future point,
2495   ### when the file is installed, then a TRANSLATED_SIZE will be set.
2496*/
2497svn_error_t *
2498svn_wc__db_global_update(svn_wc__db_t *db,
2499                         const char *local_abspath,
2500                         svn_node_kind_t new_kind,
2501                         const char *new_repos_relpath,
2502                         svn_revnum_t new_revision,
2503                         const apr_hash_t *new_props,
2504                         svn_revnum_t new_changed_rev,
2505                         apr_time_t new_changed_date,
2506                         const char *new_changed_author,
2507                         const apr_array_header_t *new_children,
2508                         const svn_checksum_t *new_checksum,
2509                         const char *new_target,
2510                         const apr_hash_t *new_dav_cache,
2511                         const svn_skel_t *conflict,
2512                         const svn_skel_t *work_items,
2513                         apr_pool_t *scratch_pool);
2514
2515
2516/* Modify the entry of working copy LOCAL_ABSPATH, presumably after an update
2517   of depth DEPTH completes.  If LOCAL_ABSPATH doesn't exist, this routine
2518   does nothing.
2519
2520   Set the node's repository relpath, repository root, repository uuid and
2521   revision to NEW_REPOS_RELPATH, NEW_REPOS_ROOT and NEW_REPOS_UUID.  If
2522   NEW_REPOS_RELPATH is null, the repository location is untouched; if
2523   NEW_REVISION in invalid, the working revision field is untouched.
2524   The modifications are mutually exclusive.  If NEW_REPOS_ROOT is non-NULL,
2525   set the repository root of the entry to NEW_REPOS_ROOT.
2526
2527   If LOCAL_ABSPATH is a directory, then, walk entries below LOCAL_ABSPATH
2528   according to DEPTH thusly:
2529
2530   If DEPTH is svn_depth_infinity, perform the following actions on
2531   every entry below PATH; if svn_depth_immediates, svn_depth_files,
2532   or svn_depth_empty, perform them only on LOCAL_ABSPATH.
2533
2534   If NEW_REVISION is valid, then tweak every entry to have this new
2535   working revision (excluding files that are scheduled for addition
2536   or replacement).  Likewise, if BASE_URL is non-null, then rewrite
2537   all urls to be "telescoping" children of the base_url.
2538
2539   EXCLUDE_RELPATHS is a hash containing const char *local_relpath.  Nodes
2540   for pathnames contained in EXCLUDE_RELPATHS are not touched by this
2541   function.  These pathnames should be paths relative to the wcroot.
2542
2543   If WCROOT_IPROPS is not NULL it is a hash mapping const char * absolute
2544   working copy paths to depth-first ordered arrays of
2545   svn_prop_inherited_item_t * structures.  If LOCAL_ABSPATH exists in
2546   WCROOT_IPROPS, then set the hashed value as the node's inherited
2547   properties.
2548*/
2549svn_error_t *
2550svn_wc__db_op_bump_revisions_post_update(svn_wc__db_t *db,
2551                                         const char *local_abspath,
2552                                         svn_depth_t depth,
2553                                         const char *new_repos_relpath,
2554                                         const char *new_repos_root_url,
2555                                         const char *new_repos_uuid,
2556                                         svn_revnum_t new_revision,
2557                                         apr_hash_t *exclude_relpaths,
2558                                         apr_hash_t *wcroot_iprops,
2559                                         svn_wc_notify_func2_t notify_func,
2560                                         void *notify_baton,
2561                                         apr_pool_t *scratch_pool);
2562
2563
2564/* Record the RECORDED_SIZE and RECORDED_TIME for a versioned node.
2565
2566   This function will record the information within the WORKING node,
2567   if present, or within the BASE tree. If neither node is present, then
2568   SVN_ERR_WC_PATH_NOT_FOUND will be returned.
2569
2570   RECORDED_SIZE may be SVN_INVALID_FILESIZE, which will be recorded
2571   as such, implying "unknown size".
2572
2573   RECORDED_TIME may be 0, which will be recorded as such, implying
2574   "unknown last mod time".
2575*/
2576svn_error_t *
2577svn_wc__db_global_record_fileinfo(svn_wc__db_t *db,
2578                                  const char *local_abspath,
2579                                  svn_filesize_t recorded_size,
2580                                  apr_time_t recorded_time,
2581                                  apr_pool_t *scratch_pool);
2582
2583
2584/* ### post-commit handling.
2585   ### maybe multiple phases?
2586   ### 1) mark a changelist as being-committed
2587   ### 2) collect ACTUAL content, store for future use as TEXTBASE
2588   ### 3) caller performs commit
2589   ### 4) post-commit, integrate changelist into BASE
2590*/
2591
2592
2593/* @} */
2594
2595
2596/* @defgroup svn_wc__db_lock  Function to manage the LOCKS table.
2597   @{
2598*/
2599
2600/* Add or replace LOCK for LOCAL_ABSPATH to DB.  */
2601svn_error_t *
2602svn_wc__db_lock_add(svn_wc__db_t *db,
2603                    const char *local_abspath,
2604                    const svn_wc__db_lock_t *lock,
2605                    apr_pool_t *scratch_pool);
2606
2607
2608/* Remove any lock for LOCAL_ABSPATH in DB.  */
2609svn_error_t *
2610svn_wc__db_lock_remove(svn_wc__db_t *db,
2611                       const char *local_abspath,
2612                       apr_pool_t *scratch_pool);
2613
2614
2615/* @} */
2616
2617
2618/* @defgroup svn_wc__db_scan  Functions to scan up a tree for further data.
2619   @{
2620*/
2621
2622/* Read a BASE node's repository information.
2623
2624   For the BASE node implied by LOCAL_ABSPATH, its location in the repository
2625   returned in *REPOS_ROOT_URL and *REPOS_UUID will be returned in
2626   *REPOS_RELPATH. Any of the OUT parameters may be NULL, indicating no
2627   interest in that piece of information.
2628
2629   All returned data will be allocated in RESULT_POOL. All temporary
2630   allocations will be made in SCRATCH_POOL.
2631
2632   ### Either delete this function and use _base_get_info instead, or
2633   ### add a 'revision' output to make a complete repository node location
2634   ### and rename to not say 'scan', because it doesn't.
2635*/
2636svn_error_t *
2637svn_wc__db_scan_base_repos(const char **repos_relpath,
2638                           const char **repos_root_url,
2639                           const char **repos_uuid,
2640                           svn_wc__db_t *db,
2641                           const char *local_abspath,
2642                           apr_pool_t *result_pool,
2643                           apr_pool_t *scratch_pool);
2644
2645
2646/* Scan upwards for information about a known addition to the WORKING tree.
2647
2648   IFF a node's status as returned by svn_wc__db_read_info() is
2649   svn_wc__db_status_added (NOT obstructed_add!), then this function
2650   returns a refined status in *STATUS, which is one of:
2651
2652     svn_wc__db_status_added -- this NODE is a simple add without history.
2653       OP_ROOT_ABSPATH will be set to the topmost node in the added subtree
2654       (implying its parent will be an unshadowed BASE node). The REPOS_*
2655       values will be implied by that ancestor BASE node and this node's
2656       position in the added subtree. ORIGINAL_* will be set to their
2657       NULL values (and SVN_INVALID_REVNUM for ORIGINAL_REVISION).
2658
2659     svn_wc__db_status_copied -- this NODE is the root or child of a copy.
2660       The root of the copy will be stored in OP_ROOT_ABSPATH. Note that
2661       the parent of the operation root could be another WORKING node (from
2662       an add, copy, or move). The REPOS_* values will be implied by the
2663       ancestor unshadowed BASE node. ORIGINAL_* will indicate the source
2664       of the copy.
2665
2666     svn_wc__db_status_incomplete -- this NODE is copied but incomplete.
2667
2668     svn_wc__db_status_moved_here -- this NODE arrived as a result of a move.
2669       The root of the moved nodes will be stored in OP_ROOT_ABSPATH.
2670       Similar to the copied state, its parent may be a WORKING node or a
2671       BASE node. And again, the REPOS_* values are implied by this node's
2672       position in the subtree under the ancestor unshadowed BASE node.
2673       ORIGINAL_* will indicate the source of the move.
2674
2675   All OUT parameters may be NULL to indicate a lack of interest in
2676   that piece of information.
2677
2678   STATUS, OP_ROOT_ABSPATH, and REPOS_* will always be assigned a value
2679   if that information is requested (and assuming a successful return).
2680
2681   ORIGINAL_REPOS_RELPATH will refer to the *root* of the operation. It
2682   does *not* correspond to the node given by LOCAL_ABSPATH. The caller
2683   can use the suffix on LOCAL_ABSPATH (relative to OP_ROOT_ABSPATH) in
2684   order to compute the source node which corresponds to LOCAL_ABSPATH.
2685
2686   If the node given by LOCAL_ABSPATH does not have changes recorded in
2687   the WORKING tree, then SVN_ERR_WC_PATH_NOT_FOUND is returned. If it
2688   doesn't have an "added" status, then SVN_ERR_WC_PATH_UNEXPECTED_STATUS
2689   will be returned.
2690
2691   All returned data will be allocated in RESULT_POOL. All temporary
2692   allocations will be made in SCRATCH_POOL.
2693*/
2694svn_error_t *
2695svn_wc__db_scan_addition(svn_wc__db_status_t *status,
2696                         const char **op_root_abspath,
2697                         const char **repos_relpath,
2698                         const char **repos_root_url,
2699                         const char **repos_uuid,
2700                         const char **original_repos_relpath,
2701                         const char **original_root_url,
2702                         const char **original_uuid,
2703                         svn_revnum_t *original_revision,
2704                         svn_wc__db_t *db,
2705                         const char *local_abspath,
2706                         apr_pool_t *result_pool,
2707                         apr_pool_t *scratch_pool);
2708
2709/* Scan the working copy for move information of the node LOCAL_ABSPATH.
2710 * If LOCAL_ABSPATH return a SVN_ERR_WC_PATH_UNEXPECTED_STATUS error.
2711 *
2712 * If not NULL *MOVED_FROM_ABSPATH will be set to the previous location
2713 * of LOCAL_ABSPATH, before it or an ancestror was moved.
2714 *
2715 * If not NULL *OP_ROOT_ABSPATH will be set to the new location of the
2716 * path that was actually moved
2717 *
2718 * If not NULL *OP_ROOT_MOVED_FROM_ABSPATH will be set to the old location
2719 * of the path that was actually moved.
2720 *
2721 * If not NULL *MOVED_FROM_DELETE_ABSPATH will be set to the ancestor of the
2722 * moved from location that deletes the original location
2723 *
2724 * Given a working copy
2725 * A/B/C
2726 * svn mv A/B D
2727 * svn rm A
2728 *
2729 * You can call this function on D and D/C. When called on D/C all output
2730 *              MOVED_FROM_ABSPATH will be A/B/C
2731 *              OP_ROOT_ABSPATH will be D
2732 *              OP_ROOT_MOVED_FROM_ABSPATH will be A/B
2733 *              MOVED_FROM_DELETE_ABSPATH will be A
2734 */
2735svn_error_t *
2736svn_wc__db_scan_moved(const char **moved_from_abspath,
2737                      const char **op_root_abspath,
2738                      const char **op_root_moved_from_abspath,
2739                      const char **moved_from_delete_abspath,
2740                      svn_wc__db_t *db,
2741                      const char *local_abspath,
2742                      apr_pool_t *result_pool,
2743                      apr_pool_t *scratch_pool);
2744
2745/* Scan upwards for additional information about a deleted node.
2746
2747   When a deleted node is discovered in the WORKING tree, the situation
2748   may be quite complex. This function will provide the information to
2749   resolve the circumstances of the deletion.
2750
2751   For discussion purposes, we will start with the most complex example
2752   and then demonstrate simplified examples. Consider node B/W/D/N has been
2753   found as deleted. B is an unmodified directory (thus, only in BASE). W is
2754   "replacement" content that exists in WORKING, shadowing a similar B/W
2755   directory in BASE. D is a deleted subtree in the WORKING tree, and N is
2756   the deleted node.
2757
2758   In this example, BASE_DEL_ABSPATH will bet set to B/W. That is the root of
2759   the BASE tree (implicitly) deleted by the replacement. WORK_DEL_ABSPATH
2760   will be set to the subtree deleted within the replacement; in this case,
2761   B/W/D. No move-away took place, so MOVED_TO_ABSPATH is set to NULL.
2762
2763   In another scenario, B/W was moved-away before W was put into the WORKING
2764   tree through an add/copy/move-here. MOVED_TO_ABSPATH will indicate where
2765   B/W was moved to. Note that further operations may have been performed
2766   post-move, but that is not known or reported by this function.
2767
2768   If BASE does not have a B/W, then the WORKING B/W is not a replacement,
2769   but a simple add/copy/move-here. BASE_DEL_ABSPATH will be set to NULL.
2770
2771   If B/W/D does not exist in the WORKING tree (we're only talking about a
2772   deletion of nodes of the BASE tree), then deleting B/W/D would have marked
2773   the subtree for deletion. BASE_DEL_ABSPATH will refer to B/W/D,
2774   MOVED_TO_ABSPATH will be NULL, and WORK_DEL_ABSPATH will be NULL.
2775
2776   If the BASE node B/W/D was moved instead of deleted, then MOVED_TO_ABSPATH
2777   would indicate the target location (and other OUT values as above).
2778
2779   When the user deletes B/W/D from the WORKING tree, there are a few
2780   additional considerations. If B/W is a simple addition (not a copy or
2781   a move-here), then the deletion will simply remove the nodes from WORKING
2782   and possibly leave behind "base-delete" markers in the WORKING tree.
2783   If the source is a copy/moved-here, then the nodes are replaced with
2784   deletion markers.
2785
2786   If the user moves-away B/W/D from the WORKING tree, then behavior is
2787   again dependent upon the origination of B/W. For a plain add, the nodes
2788   simply move to the destination; this means that B/W/D ceases to be a
2789   node and so cannot be scanned. For a copy, a deletion is made at B/W/D,
2790   and a new copy (of a subtree of the original source) is made at the
2791   destination. For a move-here, a deletion is made, and a copy is made at
2792   the destination (we do not track multiple moves; the source is moved to
2793   B/W, then B/W/D is deleted; then a copy is made at the destination;
2794   however, note the double-move could have been performed by moving the
2795   subtree first, then moving the source to B/W).
2796
2797   There are three further considerations when resolving a deleted node:
2798
2799     If the BASE B/W/D was deleted explicitly *and* B/W is a replacement,
2800     then the explicit deletion is subsumed by the implicit deletion that
2801     occurred with the B/W replacement. Thus, BASE_DEL_ABSPATH will point
2802     to B/W as the root of the BASE deletion. IOW, we can detect the
2803     explicit move-away, but not an explicit deletion.
2804
2805     If B/W/D/N refers to a node present in the BASE tree, and B/W was
2806     replaced by a shallow subtree, then it is possible for N to be
2807     reported as deleted (from BASE) yet no deletions occurred in the
2808     WORKING tree above N. Thus, WORK_DEL_ABSPATH will be set to NULL.
2809
2810
2811   Summary of OUT parameters:
2812
2813   BASE_DEL_ABSPATH will specify the nearest ancestor of the explicit or
2814   implicit deletion (if any) that applies to the BASE tree.
2815
2816   WORK_DEL_ABSPATH will specify the root of a deleted subtree within
2817   the WORKING tree (note there is no concept of layered delete operations
2818   in WORKING, so there is only one deletion root in the ancestry).
2819
2820   MOVED_TO_ABSPATH will specify the path where this node was moved to
2821   if the node has moved-away.
2822
2823   If the node was moved-away, MOVED_TO_OP_ROOT_ABSPATH will specify the
2824   target path of the root of the move operation.  If LOCAL_ABSPATH itself
2825   is the source path of the root of the move operation, then
2826   MOVED_TO_OP_ROOT_ABSPATH equals MOVED_TO_ABSPATH.
2827
2828   All OUT parameters may be set to NULL to indicate a lack of interest in
2829   that piece of information.
2830
2831   If the node given by LOCAL_ABSPATH does not exist, then
2832   SVN_ERR_WC_PATH_NOT_FOUND is returned. If it doesn't have a "deleted"
2833   status, then SVN_ERR_WC_PATH_UNEXPECTED_STATUS will be returned.
2834
2835   All returned data will be allocated in RESULT_POOL. All temporary
2836   allocations will be made in SCRATCH_POOL.
2837*/
2838svn_error_t *
2839svn_wc__db_scan_deletion(const char **base_del_abspath,
2840                         const char **moved_to_abspath,
2841                         const char **work_del_abspath,
2842                         const char **moved_to_op_root_abspath,
2843                         svn_wc__db_t *db,
2844                         const char *local_abspath,
2845                         apr_pool_t *result_pool,
2846                         apr_pool_t *scratch_pool);
2847
2848
2849/* @} */
2850
2851
2852/* @defgroup svn_wc__db_upgrade  Functions for upgrading a working copy.
2853   @{
2854*/
2855
2856/* Installs or updates Sqlite schema statistics for the current (aka latest)
2857   working copy schema.
2858
2859   This function should be called once on initializing the database and after
2860   an schema update completes */
2861svn_error_t *
2862svn_wc__db_install_schema_statistics(svn_sqlite__db_t *sdb,
2863                                     apr_pool_t *scratch_pool);
2864
2865
2866/* Create a new wc.db file for LOCAL_DIR_ABSPATH, which is going to be a
2867   working copy for the repository REPOS_ROOT_URL with uuid REPOS_UUID.
2868   Return the raw sqlite handle, repository id and working copy id
2869   and store the database in WC_DB.
2870
2871   Perform temporary allocations in SCRATCH_POOL. */
2872svn_error_t *
2873svn_wc__db_upgrade_begin(svn_sqlite__db_t **sdb,
2874                         apr_int64_t *repos_id,
2875                         apr_int64_t *wc_id,
2876                         svn_wc__db_t *wc_db,
2877                         const char *local_dir_abspath,
2878                         const char *repos_root_url,
2879                         const char *repos_uuid,
2880                         apr_pool_t *scratch_pool);
2881
2882
2883svn_error_t *
2884svn_wc__db_upgrade_apply_dav_cache(svn_sqlite__db_t *sdb,
2885                                   const char *dir_relpath,
2886                                   apr_hash_t *cache_values,
2887                                   apr_pool_t *scratch_pool);
2888
2889
2890/* ### need much more docco
2891
2892   ### this function should be called within a sqlite transaction. it makes
2893   ### assumptions around this fact.
2894
2895   Apply the various sets of properties to the database nodes based on
2896   their existence/presence, the current state of the node, and the original
2897   format of the working copy which provided these property sets.
2898*/
2899svn_error_t *
2900svn_wc__db_upgrade_apply_props(svn_sqlite__db_t *sdb,
2901                               const char *dir_abspath,
2902                               const char *local_relpath,
2903                               apr_hash_t *base_props,
2904                               apr_hash_t *revert_props,
2905                               apr_hash_t *working_props,
2906                               int original_format,
2907                               apr_int64_t wc_id,
2908                               apr_pool_t *scratch_pool);
2909
2910/* Simply insert (or replace) one row in the EXTERNALS table. */
2911svn_error_t *
2912svn_wc__db_upgrade_insert_external(svn_wc__db_t *db,
2913                                   const char *local_abspath,
2914                                   svn_node_kind_t kind,
2915                                   const char *parent_abspath,
2916                                   const char *def_local_abspath,
2917                                   const char *repos_relpath,
2918                                   const char *repos_root_url,
2919                                   const char *repos_uuid,
2920                                   svn_revnum_t def_peg_revision,
2921                                   svn_revnum_t def_revision,
2922                                   apr_pool_t *scratch_pool);
2923
2924/* Get the repository identifier corresponding to REPOS_ROOT_URL from the
2925   database in SDB. The value is returned in *REPOS_ID. All allocations
2926   are allocated in SCRATCH_POOL.
2927
2928   NOTE: the row in REPOSITORY must exist. If not, then SVN_ERR_WC_DB_ERROR
2929   is returned.
2930
2931   ### unclear on whether/how this interface will stay/evolve.  */
2932svn_error_t *
2933svn_wc__db_upgrade_get_repos_id(apr_int64_t *repos_id,
2934                                svn_sqlite__db_t *sdb,
2935                                const char *repos_root_url,
2936                                apr_pool_t *scratch_pool);
2937
2938/* Upgrade the metadata concerning the WC at WCROOT_ABSPATH, in DB,
2939 * to the SVN_WC__VERSION format.
2940 *
2941 * This function is used for upgrading wc-ng working copies to a newer
2942 * wc-ng format. If a pre-1.7 working copy is found, this function
2943 * returns SVN_ERR_WC_UPGRADE_REQUIRED.
2944 *
2945 * Upgrading subdirectories of a working copy is not supported.
2946 * If WCROOT_ABSPATH is not a working copy root SVN_ERR_WC_INVALID_OP_ON_CWD
2947 * is returned.
2948 *
2949 * If BUMPED_FORMAT is not NULL, set *BUMPED_FORMAT to TRUE if the format
2950 * was bumped or to FALSE if the wc was already at the resulting format.
2951 */
2952svn_error_t *
2953svn_wc__db_bump_format(int *result_format,
2954                       svn_boolean_t *bumped_format,
2955                       svn_wc__db_t *db,
2956                       const char *wcroot_abspath,
2957                       apr_pool_t *scratch_pool);
2958
2959/* @} */
2960
2961
2962/* @defgroup svn_wc__db_wq  Work queue manipulation. see workqueue.h
2963   @{
2964*/
2965
2966/* In the WCROOT associated with DB and WRI_ABSPATH, add WORK_ITEM to the
2967   wcroot's work queue. Use SCRATCH_POOL for all temporary allocations.  */
2968svn_error_t *
2969svn_wc__db_wq_add(svn_wc__db_t *db,
2970                  const char *wri_abspath,
2971                  const svn_skel_t *work_item,
2972                  apr_pool_t *scratch_pool);
2973
2974
2975/* In the WCROOT associated with DB and WRI_ABSPATH, fetch a work item that
2976   needs to be completed. Its identifier is returned in ID, and the data in
2977   WORK_ITEM.
2978
2979   Items are returned in the same order they were queued. This allows for
2980   (say) queueing work on a parent node to be handled before that of its
2981   children.
2982
2983   If there are no work items to be completed, then ID will be set to zero,
2984   and WORK_ITEM to NULL.
2985
2986   If COMPLETED_ID is not 0, the wq item COMPLETED_ID will be marked as
2987   completed before returning the next item.
2988
2989   RESULT_POOL will be used to allocate WORK_ITEM, and SCRATCH_POOL
2990   will be used for all temporary allocations.  */
2991svn_error_t *
2992svn_wc__db_wq_fetch_next(apr_uint64_t *id,
2993                         svn_skel_t **work_item,
2994                         svn_wc__db_t *db,
2995                         const char *wri_abspath,
2996                         apr_uint64_t completed_id,
2997                         apr_pool_t *result_pool,
2998                         apr_pool_t *scratch_pool);
2999
3000/* Special variant of svn_wc__db_wq_fetch_next(), which in the same transaction
3001   also records timestamps and sizes for one or more nodes */
3002svn_error_t *
3003svn_wc__db_wq_record_and_fetch_next(apr_uint64_t *id,
3004                                    svn_skel_t **work_item,
3005                                    svn_wc__db_t *db,
3006                                    const char *wri_abspath,
3007                                    apr_uint64_t completed_id,
3008                                    apr_hash_t *record_map,
3009                                    apr_pool_t *result_pool,
3010                                    apr_pool_t *scratch_pool);
3011
3012
3013/* @} */
3014
3015
3016/* Note: LEVELS_TO_LOCK is here strictly for backward compat.  The access
3017   batons still have the notion of 'levels to lock' and we need to ensure
3018   that they still function correctly, even in the new world.  'levels to
3019   lock' should not be exposed through the wc-ng APIs at all: users either
3020   get to lock the entire tree (rooted at some subdir, of course), or none.
3021
3022   An infinite depth lock is obtained with LEVELS_TO_LOCK set to -1, but until
3023   we move to a single DB only depth 0 is supported.
3024*/
3025svn_error_t *
3026svn_wc__db_wclock_obtain(svn_wc__db_t *db,
3027                         const char *local_abspath,
3028                         int levels_to_lock,
3029                         svn_boolean_t steal_lock,
3030                         apr_pool_t *scratch_pool);
3031
3032/* Set LOCK_ABSPATH to the path of the the directory that owns the
3033   lock on LOCAL_ABSPATH, or NULL, if LOCAL_ABSPATH is not locked. */
3034svn_error_t*
3035svn_wc__db_wclock_find_root(const char **lock_abspath,
3036                            svn_wc__db_t *db,
3037                            const char *local_abspath,
3038                            apr_pool_t *result_pool,
3039                            apr_pool_t *scratch_pool);
3040
3041/* Check if somebody has a wclock on LOCAL_ABSPATH */
3042svn_error_t *
3043svn_wc__db_wclocked(svn_boolean_t *locked,
3044                    svn_wc__db_t *db,
3045                    const char *local_abspath,
3046                    apr_pool_t *scratch_pool);
3047
3048/* Release the previously obtained lock on LOCAL_ABSPATH */
3049svn_error_t *
3050svn_wc__db_wclock_release(svn_wc__db_t *db,
3051                          const char *local_abspath,
3052                          apr_pool_t *scratch_pool);
3053
3054/* Checks whether DB currently owns a lock to operate on LOCAL_ABSPATH.
3055   If EXACT is TRUE only lock roots are checked. */
3056svn_error_t *
3057svn_wc__db_wclock_owns_lock(svn_boolean_t *own_lock,
3058                            svn_wc__db_t *db,
3059                            const char *local_abspath,
3060                            svn_boolean_t exact,
3061                            apr_pool_t *scratch_pool);
3062
3063
3064
3065/* @defgroup svn_wc__db_temp Various temporary functions during transition
3066
3067  ### These functions SHOULD be completely removed before 1.7
3068
3069  @{
3070*/
3071
3072/* Removes all references to LOCAL_ABSPATH from DB, while optionally leaving
3073   a not present node.
3074
3075   This operation always recursively removes all nodes at and below
3076   LOCAL_ABSPATH from NODES and ACTUAL.
3077
3078   If NOT_PRESENT_REVISION specifies a valid revision, leave a not_present
3079   BASE node at local_abspath of the specified status and kind.
3080   (Requires an existing BASE node before removing)
3081
3082   If DESTROY_WC is TRUE, this operation *installs* workqueue operations to
3083   update the local filesystem after the database operation. If DESTROY_CHANGES
3084   is FALSE, modified and unversioned files are left after running this
3085   operation (and the WQ). If DESTROY_CHANGES and DESTROY_WC are TRUE,
3086   LOCAL_ABSPATH and everything below it will be removed by the WQ.
3087
3088
3089   Note: Unlike many similar functions it is a valid scenario for this
3090   function to be called on a wcroot! In this case it will just leave the root
3091   record in BASE
3092 */
3093svn_error_t *
3094svn_wc__db_op_remove_node(svn_boolean_t *left_changes,
3095                          svn_wc__db_t *db,
3096                          const char *local_abspath,
3097                          svn_boolean_t destroy_wc,
3098                          svn_boolean_t destroy_changes,
3099                          svn_revnum_t not_present_revision,
3100                          svn_wc__db_status_t not_present_status,
3101                          svn_node_kind_t not_present_kind,
3102                          const svn_skel_t *conflict,
3103                          const svn_skel_t *work_items,
3104                          svn_cancel_func_t cancel_func,
3105                          void *cancel_baton,
3106                          apr_pool_t *scratch_pool);
3107
3108/* Sets the depth of LOCAL_ABSPATH in its working copy to DEPTH using DB.
3109
3110   Returns SVN_ERR_WC_PATH_NOT_FOUND if LOCAL_ABSPATH is not a BASE directory
3111 */
3112svn_error_t *
3113svn_wc__db_op_set_base_depth(svn_wc__db_t *db,
3114                             const char *local_abspath,
3115                             svn_depth_t depth,
3116                             apr_pool_t *scratch_pool);
3117
3118/* ### temp function. return the FORMAT for the directory LOCAL_ABSPATH.  */
3119svn_error_t *
3120svn_wc__db_temp_get_format(int *format,
3121                           svn_wc__db_t *db,
3122                           const char *local_dir_abspath,
3123                           apr_pool_t *scratch_pool);
3124
3125/* ### temp functions to manage/store access batons within the DB.  */
3126svn_wc_adm_access_t *
3127svn_wc__db_temp_get_access(svn_wc__db_t *db,
3128                           const char *local_dir_abspath,
3129                           apr_pool_t *scratch_pool);
3130void
3131svn_wc__db_temp_set_access(svn_wc__db_t *db,
3132                           const char *local_dir_abspath,
3133                           svn_wc_adm_access_t *adm_access,
3134                           apr_pool_t *scratch_pool);
3135svn_error_t *
3136svn_wc__db_temp_close_access(svn_wc__db_t *db,
3137                             const char *local_dir_abspath,
3138                             svn_wc_adm_access_t *adm_access,
3139                             apr_pool_t *scratch_pool);
3140void
3141svn_wc__db_temp_clear_access(svn_wc__db_t *db,
3142                             const char *local_dir_abspath,
3143                             apr_pool_t *scratch_pool);
3144
3145/* ### shallow hash: abspath -> svn_wc_adm_access_t *  */
3146apr_hash_t *
3147svn_wc__db_temp_get_all_access(svn_wc__db_t *db,
3148                               apr_pool_t *result_pool);
3149
3150/* ### temp function to open the sqlite database to the appropriate location,
3151   ### then borrow it for a bit.
3152   ### The *only* reason for this function is because entries.c still
3153   ### manually hacks the sqlite database.
3154
3155   ### No matter how tempted you may be DO NOT USE THIS FUNCTION!
3156   ### (if you do, gstein will hunt you down and burn your knee caps off
3157   ### in the middle of the night)
3158   ### "Bet on it." --gstein
3159*/
3160svn_error_t *
3161svn_wc__db_temp_borrow_sdb(svn_sqlite__db_t **sdb,
3162                           svn_wc__db_t *db,
3163                           const char *local_dir_abspath,
3164                           apr_pool_t *scratch_pool);
3165
3166
3167/* Return a directory in *TEMP_DIR_ABSPATH that is suitable for temporary
3168   files which may need to be moved (atomically and same-device) into the
3169   working copy indicated by WRI_ABSPATH.  */
3170svn_error_t *
3171svn_wc__db_temp_wcroot_tempdir(const char **temp_dir_abspath,
3172                               svn_wc__db_t *db,
3173                               const char *wri_abspath,
3174                               apr_pool_t *result_pool,
3175                               apr_pool_t *scratch_pool);
3176
3177/* Update the BASE_NODE of directory LOCAL_ABSPATH to be NEW_REPOS_RELPATH
3178   at revision NEW_REV with status incomplete. */
3179svn_error_t *
3180svn_wc__db_temp_op_start_directory_update(svn_wc__db_t *db,
3181                                          const char *local_abspath,
3182                                          const char *new_repos_relpath,
3183                                          svn_revnum_t new_rev,
3184                                          apr_pool_t *scratch_pool);
3185
3186/* Marks a directory update started with
3187   svn_wc__db_temp_op_start_directory_update as completed, by removing
3188   the incomplete status */
3189svn_error_t *
3190svn_wc__db_temp_op_end_directory_update(svn_wc__db_t *db,
3191                                        const char *local_dir_abspath,
3192                                        apr_pool_t *scratch_pool);
3193
3194
3195/* Copy the base tree at LOCAL_ABSPATH into the working tree as copy,
3196   leaving any subtree additions and copies as-is.  This allows the
3197   base node tree to be removed. */
3198svn_error_t *
3199svn_wc__db_op_make_copy(svn_wc__db_t *db,
3200                        const char *local_abspath,
3201                        const svn_skel_t *conflicts,
3202                        const svn_skel_t *work_items,
3203                        apr_pool_t *scratch_pool);
3204
3205/* Close the wc root LOCAL_ABSPATH and remove any per-directory
3206   handles associated with it. */
3207svn_error_t *
3208svn_wc__db_drop_root(svn_wc__db_t *db,
3209                     const char *local_abspath,
3210                     apr_pool_t *scratch_pool);
3211
3212/* Return the OP_DEPTH for LOCAL_RELPATH. */
3213int
3214svn_wc__db_op_depth_for_upgrade(const char *local_relpath);
3215
3216/* Set *HAVE_WORK TRUE if there is a working layer below the top layer and
3217   *HAVE_BASE if there is a base layer. Set *STATUS to the status of the
3218   highest layer below WORKING */
3219svn_error_t *
3220svn_wc__db_info_below_working(svn_boolean_t *have_base,
3221                              svn_boolean_t *have_work,
3222                              svn_wc__db_status_t *status,
3223                              svn_wc__db_t *db,
3224                              const char *local_abspath,
3225                              apr_pool_t *scratch_pool);
3226
3227
3228/* Gets an array of const char *local_relpaths of descendants of LOCAL_ABSPATH,
3229 * which itself must be the op root of an addition, copy or move.
3230 * The descendants returned are at the same op_depth, but are to be deleted
3231 * by the commit processing because they are not present in the local copy.
3232 */
3233svn_error_t *
3234svn_wc__db_get_not_present_descendants(const apr_array_header_t **descendants,
3235                                       svn_wc__db_t *db,
3236                                       const char *local_abspath,
3237                                       apr_pool_t *result_pool,
3238                                       apr_pool_t *scratch_pool);
3239
3240/* Gather revision status information about a working copy using DB.
3241 *
3242 * Set *MIN_REVISION and *MAX_REVISION to the lowest and highest revision
3243 * numbers found within LOCAL_ABSPATH.
3244 * Only nodes with op_depth zero and presence 'normal' or 'incomplete'
3245 * are considered, so that added, deleted or excluded nodes do not affect
3246 * the result.  If COMMITTED is TRUE, set *MIN_REVISION and *MAX_REVISION
3247 * to the lowest and highest committed (i.e. "last changed") revision numbers,
3248 * respectively.
3249 *
3250 * Indicate in *IS_SPARSE_CHECKOUT whether any of the nodes within
3251 * LOCAL_ABSPATH is sparse.
3252 * Indicate in *IS_MODIFIED whether the working copy has local modifications.
3253 *
3254 * Indicate in *IS_SWITCHED whether any node beneath LOCAL_ABSPATH
3255 * is switched. If TRAIL_URL is non-NULL, use it to determine if LOCAL_ABSPATH
3256 * itself is switched.  It should be any trailing portion of LOCAL_ABSPATH's
3257 * expected URL, long enough to include any parts that the caller considers
3258 * might be changed by a switch.  If it does not match the end of WC_PATH's
3259 * actual URL, then report a "switched" status.
3260 *
3261 * See also the functions below which provide a subset of this functionality.
3262 */
3263svn_error_t *
3264svn_wc__db_revision_status(svn_revnum_t *min_revision,
3265                           svn_revnum_t *max_revision,
3266                           svn_boolean_t *is_sparse_checkout,
3267                           svn_boolean_t *is_modified,
3268                           svn_boolean_t *is_switched,
3269                           svn_wc__db_t *db,
3270                           const char *local_abspath,
3271                           const char *trail_url,
3272                           svn_boolean_t committed,
3273                           svn_cancel_func_t cancel_func,
3274                           void *cancel_baton,
3275                           apr_pool_t *scratch_pool);
3276
3277/* Set *MIN_REVISION and *MAX_REVISION to the lowest and highest revision
3278 * numbers found within LOCAL_ABSPATH in the working copy using DB.
3279 * Only nodes with op_depth zero and presence 'normal' or 'incomplete'
3280 * are considered, so that added, deleted or excluded nodes do not affect
3281 * the result.  If COMMITTED is TRUE, set *MIN_REVISION and *MAX_REVISION
3282 * to the lowest and highest committed (i.e. "last changed") revision numbers,
3283 * respectively. Use SCRATCH_POOL for temporary allocations.
3284 *
3285 * Either of MIN_REVISION and MAX_REVISION may be passed as NULL if
3286 * the caller doesn't care about that return value.
3287 *
3288 * This function provides a subset of the functionality of
3289 * svn_wc__db_revision_status() and is more efficient if the caller
3290 * doesn't need all information returned by svn_wc__db_revision_status(). */
3291svn_error_t *
3292svn_wc__db_min_max_revisions(svn_revnum_t *min_revision,
3293                             svn_revnum_t *max_revision,
3294                             svn_wc__db_t *db,
3295                             const char *local_abspath,
3296                             svn_boolean_t committed,
3297                             apr_pool_t *scratch_pool);
3298
3299/* Indicate in *IS_SWITCHED whether any node beneath LOCAL_ABSPATH
3300 * is switched, using DB. Use SCRATCH_POOL for temporary allocations.
3301 *
3302 * If TRAIL_URL is non-NULL, use it to determine if LOCAL_ABSPATH itself
3303 * is switched.  It should be any trailing portion of LOCAL_ABSPATH's
3304 * expected URL, long enough to include any parts that the caller considers
3305 * might be changed by a switch.  If it does not match the end of WC_PATH's
3306 * actual URL, then report a "switched" status.
3307 *
3308 * This function provides a subset of the functionality of
3309 * svn_wc__db_revision_status() and is more efficient if the caller
3310 * doesn't need all information returned by svn_wc__db_revision_status(). */
3311svn_error_t *
3312svn_wc__db_has_switched_subtrees(svn_boolean_t *is_switched,
3313                                 svn_wc__db_t *db,
3314                                 const char *local_abspath,
3315                                 const char *trail_url,
3316                                 apr_pool_t *scratch_pool);
3317
3318/* Set @a *excluded_subtrees to a hash mapping <tt>const char *</tt>
3319 * local absolute paths to <tt>const char *</tt> local absolute paths for
3320 * every path under @a local_abspath in @a db which are excluded by
3321 * the server (e.g. due to authz), or user.  If no such paths are found then
3322 * @a *server_excluded_subtrees is set to @c NULL.
3323 * Allocate the hash and all items therein from @a result_pool.
3324 */
3325svn_error_t *
3326svn_wc__db_get_excluded_subtrees(apr_hash_t **server_excluded_subtrees,
3327                                 svn_wc__db_t *db,
3328                                 const char *local_abspath,
3329                                 apr_pool_t *result_pool,
3330                                 apr_pool_t *scratch_pool);
3331
3332/* Indicate in *IS_MODIFIED whether the working copy has local modifications,
3333 * using DB. Use SCRATCH_POOL for temporary allocations.
3334 *
3335 * This function provides a subset of the functionality of
3336 * svn_wc__db_revision_status() and is more efficient if the caller
3337 * doesn't need all information returned by svn_wc__db_revision_status(). */
3338svn_error_t *
3339svn_wc__db_has_local_mods(svn_boolean_t *is_modified,
3340                          svn_wc__db_t *db,
3341                          const char *local_abspath,
3342                          svn_cancel_func_t cancel_func,
3343                          void *cancel_baton,
3344                          apr_pool_t *scratch_pool);
3345
3346
3347/* Verify the consistency of metadata concerning the WC that contains
3348 * WRI_ABSPATH, in DB.  Return an error if any problem is found. */
3349svn_error_t *
3350svn_wc__db_verify(svn_wc__db_t *db,
3351                  const char *wri_abspath,
3352                  apr_pool_t *scratch_pool);
3353
3354
3355/* Possibly need two structures, one with relpaths and with abspaths?
3356 * Only exposed for testing at present. */
3357struct svn_wc__db_moved_to_t {
3358  const char *local_relpath;  /* moved-to destination */
3359  int op_depth;       /* op-root of source */
3360};
3361
3362/* Set *FINAL_ABSPATH to an array of svn_wc__db_moved_to_t for
3363 * LOCAL_ABSPATH after following any and all nested moves.
3364 * Only exposed for testing at present. */
3365svn_error_t *
3366svn_wc__db_follow_moved_to(apr_array_header_t **moved_tos,
3367                           svn_wc__db_t *db,
3368                           const char *local_abspath,
3369                           apr_pool_t *result_pool,
3370                           apr_pool_t *scratch_pool);
3371
3372/* Update a moved-away tree conflict victim at VICTIM_ABSPATH with changes
3373 * brought in by the update operation which flagged the tree conflict. */
3374svn_error_t *
3375svn_wc__db_update_moved_away_conflict_victim(svn_wc__db_t *db,
3376                                             const char *victim_abspath,
3377                                             svn_wc_notify_func2_t notify_func,
3378                                             void *notify_baton,
3379                                             svn_cancel_func_t cancel_func,
3380                                             void *cancel_baton,
3381                                             apr_pool_t *scratch_pool);
3382
3383/* LOCAL_ABSPATH is moved to MOVE_DST_ABSPATH.  MOVE_SRC_ROOT_ABSPATH
3384 * is the root of the move to MOVE_DST_OP_ROOT_ABSPATH.
3385 * MOVE_SRC_OP_ROOT_ABSPATH is the op-root of the move; it's the same
3386 * as MOVE_SRC_ROOT_ABSPATH except for moves inside deletes when it is
3387 * the op-root of the delete. */
3388svn_error_t *
3389svn_wc__db_base_moved_to(const char **move_dst_abspath,
3390                         const char **move_dst_op_root_abspath,
3391                         const char **move_src_root_abspath,
3392                         const char **move_src_op_root_abspath,
3393                         svn_wc__db_t *db,
3394                         const char *local_abspath,
3395                         apr_pool_t *result_pool,
3396                         apr_pool_t *scratch_pool);
3397
3398/* Recover space from the database file for LOCAL_ABSPATH by running
3399 * the "vacuum" command. */
3400svn_error_t *
3401svn_wc__db_vacuum(svn_wc__db_t *db,
3402                  const char *local_abspath,
3403                  apr_pool_t *scratch_pool);
3404
3405/* This raises move-edit tree-conflicts on any moves inside the
3406   delete-edit conflict on LOCAL_ABSPATH. This is experimental: see
3407   comment in resolve_conflict_on_node about combining with another
3408   function. */
3409svn_error_t *
3410svn_wc__db_resolve_delete_raise_moved_away(svn_wc__db_t *db,
3411                                           const char *local_abspath,
3412                                           svn_wc_notify_func2_t notify_func,
3413                                           void *notify_baton,
3414                                           apr_pool_t *scratch_pool);
3415
3416/* Like svn_wc__db_resolve_delete_raise_moved_away this should be
3417   combined.
3418
3419   ### LOCAL_ABSPATH specifies the move origin, but the move origin
3420   ### is not necessary unique enough. This function needs an op_root_abspath
3421   ### argument to differentiate between different origins.
3422
3423   ### See move_tests.py: move_many_update_delete for an example case.
3424   */
3425svn_error_t *
3426svn_wc__db_resolve_break_moved_away(svn_wc__db_t *db,
3427                                    const char *local_abspath,
3428                                    svn_wc_notify_func2_t notify_func,
3429                                    void *notify_baton,
3430                                    apr_pool_t *scratch_pool);
3431
3432/* Break moves for all moved-away children of LOCAL_ABSPATH, within
3433 * a single transaction.
3434 *
3435 * ### Like svn_wc__db_resolve_delete_raise_moved_away this should be
3436 * combined. */
3437svn_error_t *
3438svn_wc__db_resolve_break_moved_away_children(svn_wc__db_t *db,
3439                                             const char *local_abspath,
3440                                             svn_wc_notify_func2_t notify_func,
3441                                             void *notify_baton,
3442                                             apr_pool_t *scratch_pool);
3443
3444/* Set *REQUIRED_ABSPATH to the path that should be locked to ensure
3445 * that the lock covers all paths affected by resolving the conflicts
3446 * in the tree LOCAL_ABSPATH. */
3447svn_error_t *
3448svn_wc__required_lock_for_resolve(const char **required_abspath,
3449                                  svn_wc__db_t *db,
3450                                  const char *local_abspath,
3451                                  apr_pool_t *result_pool,
3452                                  apr_pool_t *scratch_pool);
3453/* @} */
3454
3455
3456#ifdef __cplusplus
3457}
3458#endif /* __cplusplus */
3459
3460#endif /* SVN_WC_DB_H */
3461