wc_db.h revision 251886
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 NOT_PRESENT_REVISION specifies a valid revision a not-present
706   node is installed in BASE node with kind NOT_PRESENT_KIND after
707   deleting.
708
709   If CONFLICT and/or WORK_ITEMS are passed they are installed as part
710   of the operation, after the work items inserted by the operation
711   itself.
712*/
713svn_error_t *
714svn_wc__db_base_remove(svn_wc__db_t *db,
715                       const char *local_abspath,
716                       svn_boolean_t keep_as_working,
717                       svn_boolean_t queue_deletes,
718                       svn_revnum_t not_present_revision,
719                       svn_skel_t *conflict,
720                       svn_skel_t *work_items,
721                       apr_pool_t *scratch_pool);
722
723
724/* Retrieve information about a node in the BASE tree.
725
726   For the BASE node implied by LOCAL_ABSPATH from the local filesystem,
727   return information in the provided OUT parameters. Each OUT parameter
728   may be NULL, indicating that specific item is not requested.
729
730   If there is no information about this node, then SVN_ERR_WC_PATH_NOT_FOUND
731   will be returned.
732
733   The OUT parameters, and their "not available" values are:
734     STATUS             n/a (always available)
735     KIND               n/a (always available)
736     REVISION           SVN_INVALID_REVNUM
737     REPOS_RELPATH      NULL (caller should scan up)
738     REPOS_ROOT_URL     NULL (caller should scan up)
739     REPOS_UUID         NULL (caller should scan up)
740     CHANGED_REV        SVN_INVALID_REVNUM
741     CHANGED_DATE       0
742     CHANGED_AUTHOR     NULL
743     DEPTH              svn_depth_unknown
744     CHECKSUM           NULL
745     TARGET             NULL
746     LOCK               NULL
747
748     HAD_PROPS          FALSE
749     PROPS              NULL
750
751     UPDATE_ROOT        FALSE
752
753   If the STATUS is normal, the REPOS_* values will be non-NULL.
754
755   If DEPTH is requested, and the node is NOT a directory, then the
756   value will be set to svn_depth_unknown. If LOCAL_ABSPATH is a link,
757   it's up to the caller to resolve depth for the link's target.
758
759   If CHECKSUM is requested, and the node is NOT a file, then it will
760   be set to NULL.
761
762   If TARGET is requested, and the node is NOT a symlink, then it will
763   be set to NULL.
764
765   *PROPS maps "const char *" names to "const svn_string_t *" values.  If
766   the base node is capable of having properties but has none, set
767   *PROPS to an empty hash.  If its status is such that it cannot have
768   properties, set *PROPS to NULL.
769
770   If UPDATE_ROOT is requested, set it to TRUE if the node should only
771   be updated when it is the root of an update (e.g. file externals).
772
773   All returned data will be allocated in RESULT_POOL. All temporary
774   allocations will be made in SCRATCH_POOL.
775*/
776svn_error_t *
777svn_wc__db_base_get_info(svn_wc__db_status_t *status,
778                         svn_node_kind_t *kind,
779                         svn_revnum_t *revision,
780                         const char **repos_relpath,
781                         const char **repos_root_url,
782                         const char **repos_uuid,
783                         svn_revnum_t *changed_rev,
784                         apr_time_t *changed_date,
785                         const char **changed_author,
786                         svn_depth_t *depth,
787                         const svn_checksum_t **checksum,
788                         const char **target,
789                         svn_wc__db_lock_t **lock,
790                         svn_boolean_t *had_props,
791                         apr_hash_t **props,
792                         svn_boolean_t *update_root,
793                         svn_wc__db_t *db,
794                         const char *local_abspath,
795                         apr_pool_t *result_pool,
796                         apr_pool_t *scratch_pool);
797
798/* Structure returned by svn_wc__db_base_get_children_info.  Only has the
799   fields needed by the adm crawler. */
800struct svn_wc__db_base_info_t {
801  svn_wc__db_status_t status;
802  svn_node_kind_t kind;
803  svn_revnum_t revnum;
804  const char *repos_relpath;
805  const char *repos_root_url;
806  svn_depth_t depth;
807  svn_boolean_t update_root;
808  svn_wc__db_lock_t *lock;
809};
810
811/* Return in *NODES a hash mapping name->struct svn_wc__db_base_info_t for
812   the children of DIR_ABSPATH at op_depth 0.
813 */
814svn_error_t *
815svn_wc__db_base_get_children_info(apr_hash_t **nodes,
816                                  svn_wc__db_t *db,
817                                  const char *dir_abspath,
818                                  apr_pool_t *result_pool,
819                                  apr_pool_t *scratch_pool);
820
821
822/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the BASE tree.
823
824   *PROPS maps "const char *" names to "const svn_string_t *" values.
825   If the node has no properties, set *PROPS to an empty hash.
826   *PROPS will never be set to NULL.
827   If the node is not present in the BASE tree (with presence 'normal'
828   or 'incomplete'), return an error.
829   Allocate *PROPS and its keys and values in RESULT_POOL.
830*/
831svn_error_t *
832svn_wc__db_base_get_props(apr_hash_t **props,
833                          svn_wc__db_t *db,
834                          const char *local_abspath,
835                          apr_pool_t *result_pool,
836                          apr_pool_t *scratch_pool);
837
838
839/* Return a list of the BASE tree node's children's names.
840
841   For the node indicated by LOCAL_ABSPATH, this function will return
842   the names of all of its children in the array CHILDREN. The array
843   elements are const char * values.
844
845   If the node is not a directory, then SVN_ERR_WC_NOT_WORKING_COPY will
846   be returned.
847
848   All returned data will be allocated in RESULT_POOL. All temporary
849   allocations will be made in SCRATCH_POOL.
850*/
851svn_error_t *
852svn_wc__db_base_get_children(const apr_array_header_t **children,
853                             svn_wc__db_t *db,
854                             const char *local_abspath,
855                             apr_pool_t *result_pool,
856                             apr_pool_t *scratch_pool);
857
858
859/* Set the dav cache for LOCAL_ABSPATH to PROPS.  Use SCRATCH_POOL for
860   temporary allocations. */
861svn_error_t *
862svn_wc__db_base_set_dav_cache(svn_wc__db_t *db,
863                              const char *local_abspath,
864                              const apr_hash_t *props,
865                              apr_pool_t *scratch_pool);
866
867
868/* Retrieve the dav cache for LOCAL_ABSPATH into *PROPS, allocated in
869   RESULT_POOL.  Use SCRATCH_POOL for temporary allocations.  Return
870   SVN_ERR_WC_PATH_NOT_FOUND if no dav cache can be located for
871   LOCAL_ABSPATH in DB.  */
872svn_error_t *
873svn_wc__db_base_get_dav_cache(apr_hash_t **props,
874                              svn_wc__db_t *db,
875                              const char *local_abspath,
876                              apr_pool_t *result_pool,
877                              apr_pool_t *scratch_pool);
878
879/* Recursively clear the dav cache for LOCAL_ABSPATH.  Use
880   SCRATCH_POOL for temporary allocations. */
881svn_error_t *
882svn_wc__db_base_clear_dav_cache_recursive(svn_wc__db_t *db,
883                                          const char *local_abspath,
884                                          apr_pool_t *scratch_pool);
885
886/* Set LOCK_TOKENS to a hash mapping const char * full URLs to const char *
887 * lock tokens for every base node at or under LOCAL_ABSPATH in DB which has
888 * such a lock token set on it.
889 * Allocate the hash and all items therein from RESULT_POOL.  */
890svn_error_t *
891svn_wc__db_base_get_lock_tokens_recursive(apr_hash_t **lock_tokens,
892                                          svn_wc__db_t *db,
893                                          const char *local_abspath,
894                                          apr_pool_t *result_pool,
895                                          apr_pool_t *scratch_pool);
896
897/* ### anything else needed for maintaining the BASE tree? */
898
899
900/* @} */
901
902/* @defgroup svn_wc__db_pristine  Pristine ("text base") management
903   @{
904*/
905
906/* Set *PRISTINE_ABSPATH to the path to the pristine text file
907   identified by SHA1_CHECKSUM.  Error if it does not exist.
908
909   ### This is temporary - callers should not be looking at the file
910   directly.
911
912   Allocate the path in RESULT_POOL. */
913svn_error_t *
914svn_wc__db_pristine_get_path(const char **pristine_abspath,
915                             svn_wc__db_t *db,
916                             const char *wri_abspath,
917                             const svn_checksum_t *checksum,
918                             apr_pool_t *result_pool,
919                             apr_pool_t *scratch_pool);
920
921/* Set *PRISTINE_ABSPATH to the path under WCROOT_ABSPATH that will be
922   used by the pristine text identified by SHA1_CHECKSUM.  The file
923   need not exist.
924 */
925svn_error_t *
926svn_wc__db_pristine_get_future_path(const char **pristine_abspath,
927                                    const char *wcroot_abspath,
928                                    const svn_checksum_t *sha1_checksum,
929                                    apr_pool_t *result_pool,
930                                    apr_pool_t *scratch_pool);
931
932
933/* If requested set *CONTENTS to a readable stream that will yield the pristine
934   text identified by SHA1_CHECKSUM (must be a SHA-1 checksum) within the WC
935   identified by WRI_ABSPATH in DB.
936
937   If requested set *SIZE to the size of the pristine stream in bytes,
938
939   Even if the pristine text is removed from the store while it is being
940   read, the stream will remain valid and readable until it is closed.
941
942   Allocate the stream in RESULT_POOL. */
943svn_error_t *
944svn_wc__db_pristine_read(svn_stream_t **contents,
945                         svn_filesize_t *size,
946                         svn_wc__db_t *db,
947                         const char *wri_abspath,
948                         const svn_checksum_t *sha1_checksum,
949                         apr_pool_t *result_pool,
950                         apr_pool_t *scratch_pool);
951
952
953/* Set *TEMP_DIR_ABSPATH to a directory in which the caller should create
954   a uniquely named file for later installation as a pristine text file.
955
956   The directory is guaranteed to be one that svn_wc__db_pristine_install()
957   can use: specifically, one from which it can atomically move the file.
958
959   Allocate *TEMP_DIR_ABSPATH in RESULT_POOL. */
960svn_error_t *
961svn_wc__db_pristine_get_tempdir(const char **temp_dir_abspath,
962                                svn_wc__db_t *db,
963                                const char *wri_abspath,
964                                apr_pool_t *result_pool,
965                                apr_pool_t *scratch_pool);
966
967
968/* Install the file TEMPFILE_ABSPATH (which is sitting in a directory given by
969   svn_wc__db_pristine_get_tempdir()) into the pristine data store, to be
970   identified by the SHA-1 checksum of its contents, SHA1_CHECKSUM, and whose
971   MD-5 checksum is MD5_CHECKSUM. */
972svn_error_t *
973svn_wc__db_pristine_install(svn_wc__db_t *db,
974                            const char *tempfile_abspath,
975                            const svn_checksum_t *sha1_checksum,
976                            const svn_checksum_t *md5_checksum,
977                            apr_pool_t *scratch_pool);
978
979
980/* Set *MD5_CHECKSUM to the MD-5 checksum of a pristine text
981   identified by its SHA-1 checksum SHA1_CHECKSUM. Return an error
982   if the pristine text does not exist or its MD5 checksum is not found.
983
984   Allocate *MD5_CHECKSUM in RESULT_POOL. */
985svn_error_t *
986svn_wc__db_pristine_get_md5(const svn_checksum_t **md5_checksum,
987                            svn_wc__db_t *db,
988                            const char *wri_abspath,
989                            const svn_checksum_t *sha1_checksum,
990                            apr_pool_t *result_pool,
991                            apr_pool_t *scratch_pool);
992
993
994/* Set *SHA1_CHECKSUM to the SHA-1 checksum of a pristine text
995   identified by its MD-5 checksum MD5_CHECKSUM. Return an error
996   if the pristine text does not exist or its SHA-1 checksum is not found.
997
998   Note: The MD-5 checksum is not strictly guaranteed to be unique in the
999   database table, although duplicates are expected to be extremely rare.
1000   ### TODO: The behaviour is currently unspecified if the MD-5 checksum is
1001   not unique. Need to see whether this function is going to stay in use,
1002   and, if so, address this somehow.
1003
1004   Allocate *SHA1_CHECKSUM in RESULT_POOL. */
1005svn_error_t *
1006svn_wc__db_pristine_get_sha1(const svn_checksum_t **sha1_checksum,
1007                             svn_wc__db_t *db,
1008                             const char *wri_abspath,
1009                             const svn_checksum_t *md5_checksum,
1010                             apr_pool_t *result_pool,
1011                             apr_pool_t *scratch_pool);
1012
1013
1014/* If necessary transfers the PRISTINE files of the tree rooted at
1015   SRC_LOCAL_ABSPATH to the working copy identified by DST_WRI_ABSPATH. */
1016svn_error_t *
1017svn_wc__db_pristine_transfer(svn_wc__db_t *db,
1018                             const char *src_local_abspath,
1019                             const char *dst_wri_abspath,
1020                             svn_cancel_func_t cancel_func,
1021                             void *cancel_baton,
1022                             apr_pool_t *scratch_pool);
1023
1024/* Remove the pristine text with SHA-1 checksum SHA1_CHECKSUM from the
1025 * pristine store, iff it is not referenced by any of the (other) WC DB
1026 * tables. */
1027svn_error_t *
1028svn_wc__db_pristine_remove(svn_wc__db_t *db,
1029                           const char *wri_abspath,
1030                           const svn_checksum_t *sha1_checksum,
1031                           apr_pool_t *scratch_pool);
1032
1033
1034/* Remove all unreferenced pristines in the WC of WRI_ABSPATH in DB. */
1035svn_error_t *
1036svn_wc__db_pristine_cleanup(svn_wc__db_t *db,
1037                            const char *wri_abspath,
1038                            apr_pool_t *scratch_pool);
1039
1040
1041/* Set *PRESENT to true if the pristine store for WRI_ABSPATH in DB contains
1042   a pristine text with SHA-1 checksum SHA1_CHECKSUM, and to false otherwise.
1043*/
1044svn_error_t *
1045svn_wc__db_pristine_check(svn_boolean_t *present,
1046                          svn_wc__db_t *db,
1047                          const char *wri_abspath,
1048                          const svn_checksum_t *sha1_checksum,
1049                          apr_pool_t *scratch_pool);
1050
1051/* @defgroup svn_wc__db_external  External management
1052   @{ */
1053
1054/* Adds (or overwrites) a file external LOCAL_ABSPATH to the working copy
1055   identified by WRI_ABSPATH.
1056
1057   It updates both EXTERNALS and NODES in one atomic step.
1058 */
1059svn_error_t *
1060svn_wc__db_external_add_file(svn_wc__db_t *db,
1061                             const char *local_abspath,
1062                             const char *wri_abspath,
1063
1064                             const char *repos_relpath,
1065                             const char *repos_root_url,
1066                             const char *repos_uuid,
1067                             svn_revnum_t revision,
1068
1069                             const apr_hash_t *props,
1070                             apr_array_header_t *iprops,
1071
1072                             svn_revnum_t changed_rev,
1073                             apr_time_t changed_date,
1074                             const char *changed_author,
1075
1076                             const svn_checksum_t *checksum,
1077
1078                             const apr_hash_t *dav_cache,
1079
1080                             const char *record_ancestor_abspath,
1081                             const char *recorded_repos_relpath,
1082                             svn_revnum_t recorded_peg_revision,
1083                             svn_revnum_t recorded_revision,
1084
1085                             svn_boolean_t update_actual_props,
1086                             apr_hash_t *new_actual_props,
1087
1088                             svn_boolean_t keep_recorded_info,
1089                             const svn_skel_t *conflict,
1090                             const svn_skel_t *work_items,
1091                             apr_pool_t *scratch_pool);
1092
1093/* Adds (or overwrites) a symlink external LOCAL_ABSPATH to the working copy
1094   identified by WRI_ABSPATH.
1095 */
1096svn_error_t *
1097svn_wc__db_external_add_symlink(svn_wc__db_t *db,
1098                                const char *local_abspath,
1099                                const char *wri_abspath,
1100
1101                                const char *repos_relpath,
1102                                const char *repos_root_url,
1103                                const char *repos_uuid,
1104                                svn_revnum_t revision,
1105
1106                                const apr_hash_t *props,
1107
1108                                svn_revnum_t changed_rev,
1109                                apr_time_t changed_date,
1110                                const char *changed_author,
1111
1112                                const char *target,
1113
1114                                const apr_hash_t *dav_cache,
1115
1116                                const char *record_ancestor_abspath,
1117                                const char *recorded_repos_relpath,
1118                                svn_revnum_t recorded_peg_revision,
1119                                svn_revnum_t recorded_revision,
1120
1121                                svn_boolean_t update_actual_props,
1122                                apr_hash_t *new_actual_props,
1123
1124                                svn_boolean_t keep_recorded_info,
1125                                const svn_skel_t *work_items,
1126                                apr_pool_t *scratch_pool);
1127
1128/* Adds (or overwrites) a directory external LOCAL_ABSPATH to the working copy
1129   identified by WRI_ABSPATH.
1130
1131  Directory externals are stored in their own working copy, so one should use
1132  the normal svn_wc__db functions to access the normal working copy
1133  information.
1134 */
1135svn_error_t *
1136svn_wc__db_external_add_dir(svn_wc__db_t *db,
1137                            const char *local_abspath,
1138                            const char *wri_abspath,
1139
1140                            const char *repos_root_url,
1141                            const char *repos_uuid,
1142
1143                            const char *record_ancestor_abspath,
1144                            const char *recorded_repos_relpath,
1145                            svn_revnum_t recorded_peg_revision,
1146                            svn_revnum_t recorded_revision,
1147
1148                            const svn_skel_t *work_items,
1149                            apr_pool_t *scratch_pool);
1150
1151/* Remove a registered external LOCAL_ABSPATH from the working copy identified
1152   by WRI_ABSPATH.
1153 */
1154svn_error_t *
1155svn_wc__db_external_remove(svn_wc__db_t *db,
1156                           const char *local_abspath,
1157                           const char *wri_abspath,
1158
1159                           const svn_skel_t *work_items,
1160                           apr_pool_t *scratch_pool);
1161
1162
1163/* Reads information on the external LOCAL_ABSPATH as stored in the working
1164   copy identified with WRI_ABSPATH (If NULL the parent directory of
1165   LOCAL_ABSPATH is taken as WRI_ABSPATH).
1166
1167   Return SVN_ERR_WC_PATH_NOT_FOUND if LOCAL_ABSPATH is not an external in
1168   this working copy.
1169
1170   When STATUS is requested it has one of these values
1171      svn_wc__db_status_normal           The external is available
1172      svn_wc__db_status_excluded         The external is user excluded
1173
1174   When KIND is requested then the value will be set to the kind of external.
1175
1176   If DEFINING_ABSPATH is requested, then the value will be set to the
1177   absolute path of the directory which originally defined the external.
1178   (The path with the svn:externals property)
1179
1180   If REPOS_ROOT_URL is requested, then the value will be set to the
1181   repository root of the external.
1182
1183   If REPOS_UUID is requested, then the value will be set to the
1184   repository uuid of the external.
1185
1186   If RECORDED_REPOS_RELPATH is requested, then the value will be set to the
1187   original repository relative path inside REPOS_ROOT_URL of the external.
1188
1189   If RECORDED_PEG_REVISION is requested, then the value will be set to the
1190   original recorded operational (peg) revision of the external.
1191
1192   If RECORDED_REVISION is requested, then the value will be set to the
1193   original recorded revision of the external.
1194
1195   Allocate the result in RESULT_POOL and perform temporary allocations in
1196   SCRATCH_POOL.
1197 */
1198svn_error_t *
1199svn_wc__db_external_read(svn_wc__db_status_t *status,
1200                         svn_node_kind_t *kind,
1201                         const char **defining_abspath,
1202
1203                         const char **repos_root_url,
1204                         const char **repos_uuid,
1205
1206                         const char **recorded_repos_relpath,
1207                         svn_revnum_t *recorded_peg_revision,
1208                         svn_revnum_t *recorded_revision,
1209
1210                         svn_wc__db_t *db,
1211                         const char *local_abspath,
1212                         const char *wri_abspath,
1213                         apr_pool_t *result_pool,
1214                         apr_pool_t *scratch_pool);
1215
1216/* Return in *EXTERNALS a list of svn_wc__committable_external_info_t *
1217 * containing info on externals defined to be checked out below LOCAL_ABSPATH,
1218 * returning only those externals that are not fixed to a specific revision.
1219 *
1220 * If IMMEDIATES_ONLY is TRUE, only those externals defined to be checked out
1221 * as immediate children of LOCAL_ABSPATH are returned (this is useful for
1222 * treating user requested depth < infinity).
1223 *
1224 * If there are no externals to be returned, set *EXTERNALS to NULL. Otherwise
1225 * set *EXTERNALS to an APR array newly cleated in RESULT_POOL.
1226 *
1227 * NOTE: This only returns the externals known by the immediate WC root for
1228 * LOCAL_ABSPATH; i.e.:
1229 * - If there is a further parent WC "above" the immediate WC root, and if
1230 *   that parent WC defines externals to live somewhere within this WC, these
1231 *   externals will appear to be foreign/unversioned and won't be picked up.
1232 * - Likewise, only the topmost level of externals nestings (externals
1233 *   defined within a checked out external dir) is picked up by this function.
1234 *   (For recursion, see svn_wc__committable_externals_below().)
1235 *
1236 * ###TODO: Add a WRI_ABSPATH (wc root indicator) separate from LOCAL_ABSPATH,
1237 * to allow searching any wc-root for externals under LOCAL_ABSPATH, not only
1238 * LOCAL_ABSPATH's most immediate wc-root. */
1239svn_error_t *
1240svn_wc__db_committable_externals_below(apr_array_header_t **externals,
1241                                       svn_wc__db_t *db,
1242                                       const char *local_abspath,
1243                                       svn_boolean_t immediates_only,
1244                                       apr_pool_t *result_pool,
1245                                       apr_pool_t *scratch_pool);
1246
1247/* Gets a mapping from const char * local abspaths of externals to the const
1248   char * local abspath of where they are defined for all externals defined
1249   at or below LOCAL_ABSPATH.
1250
1251   ### Returns NULL in *EXTERNALS until we bumped to format 29.
1252
1253   Allocate the result in RESULT_POOL and perform temporary allocations in
1254   SCRATCH_POOL. */
1255svn_error_t *
1256svn_wc__db_externals_defined_below(apr_hash_t **externals,
1257                                   svn_wc__db_t *db,
1258                                   const char *local_abspath,
1259                                   apr_pool_t *result_pool,
1260                                   apr_pool_t *scratch_pool);
1261
1262/* Gather all svn:externals property values from the actual properties on
1263   directories below LOCAL_ABSPATH as a mapping of const char *local_abspath
1264   to const char * property values.
1265
1266   If DEPTHS is not NULL, set *depths to an apr_hash_t* mapping the same
1267   local_abspaths to the const char * ambient depth of the node.
1268
1269   Allocate the result in RESULT_POOL and perform temporary allocations in
1270   SCRATCH_POOL. */
1271svn_error_t *
1272svn_wc__db_externals_gather_definitions(apr_hash_t **externals,
1273                                        apr_hash_t **depths,
1274                                        svn_wc__db_t *db,
1275                                        const char *local_abspath,
1276                                        apr_pool_t *result_pool,
1277                                        apr_pool_t *scratch_pool);
1278
1279/* @} */
1280
1281/* @defgroup svn_wc__db_op  Operations on WORKING tree
1282   @{
1283*/
1284
1285/* Copy the node at SRC_ABSPATH (in NODES and ACTUAL_NODE tables) to
1286 * DST_ABSPATH, both in DB but not necessarily in the same WC.  The parent
1287 * of DST_ABSPATH must be a versioned directory.
1288 *
1289 * This copy is NOT recursive. It simply establishes this one node, plus
1290 * incomplete nodes for the children.
1291 *
1292 * If IS_MOVE is TRUE, mark this copy operation as the copy-half of
1293 * a move. The delete-half of the move needs to be created separately
1294 * with svn_wc__db_op_delete().
1295 *
1296 * Add WORK_ITEMS to the work queue. */
1297svn_error_t *
1298svn_wc__db_op_copy(svn_wc__db_t *db,
1299                   const char *src_abspath,
1300                   const char *dst_abspath,
1301                   const char *dst_op_root_abspath,
1302                   svn_boolean_t is_move,
1303                   const svn_skel_t *work_items,
1304                   apr_pool_t *scratch_pool);
1305
1306/* Checks if LOCAL_ABSPATH represents a move back to its original location,
1307 * and if it is reverts the move while keeping local changes after it has been
1308 * moved from MOVED_FROM_ABSPATH.
1309 *
1310 * If MOVED_BACK is not NULL, set *MOVED_BACK to TRUE when a move was reverted,
1311 * otherwise to FALSE.
1312 */
1313svn_error_t *
1314svn_wc__db_op_handle_move_back(svn_boolean_t *moved_back,
1315                               svn_wc__db_t *db,
1316                               const char *local_abspath,
1317                               const char *moved_from_abspath,
1318                               const svn_skel_t *work_items,
1319                               apr_pool_t *scratch_pool);
1320
1321
1322/* Copy the leaves of the op_depth layer directly shadowed by the operation
1323 * of SRC_ABSPATH (so SRC_ABSPATH must be an op_root) to dst_abspaths
1324 * parents layer.
1325 *
1326 * This operation is recursive. It copies all the descendants at the lower
1327 * layer and adds base-deleted nodes on dst_abspath layer to mark these nodes
1328 * properly deleted.
1329 *
1330 * Usually this operation is directly followed by a call to svn_wc__db_op_copy
1331 * which performs the real copy from src_abspath to dst_abspath.
1332 */
1333svn_error_t *
1334svn_wc__db_op_copy_shadowed_layer(svn_wc__db_t *db,
1335                                  const char *src_abspath,
1336                                  const char *dst_abspath,
1337                                  svn_boolean_t is_move,
1338                                  apr_pool_t *scratch_pool);
1339
1340
1341/* Record a copy at LOCAL_ABSPATH from a repository directory.
1342
1343   This copy is NOT recursive. It simply establishes this one node.
1344   CHILDREN must be provided, and incomplete nodes will be constructed
1345   for them.
1346
1347   ### arguments docco.  */
1348svn_error_t *
1349svn_wc__db_op_copy_dir(svn_wc__db_t *db,
1350                       const char *local_abspath,
1351                       const apr_hash_t *props,
1352                       svn_revnum_t changed_rev,
1353                       apr_time_t changed_date,
1354                       const char *changed_author,
1355                       const char *original_repos_relpath,
1356                       const char *original_root_url,
1357                       const char *original_uuid,
1358                       svn_revnum_t original_revision,
1359                       const apr_array_header_t *children,
1360                       svn_boolean_t is_move,
1361                       svn_depth_t depth,
1362                       const svn_skel_t *conflict,
1363                       const svn_skel_t *work_items,
1364                       apr_pool_t *scratch_pool);
1365
1366
1367/* Record a copy at LOCAL_ABSPATH from a repository file.
1368
1369   ### arguments docco.  */
1370svn_error_t *
1371svn_wc__db_op_copy_file(svn_wc__db_t *db,
1372                        const char *local_abspath,
1373                        const apr_hash_t *props,
1374                        svn_revnum_t changed_rev,
1375                        apr_time_t changed_date,
1376                        const char *changed_author,
1377                        const char *original_repos_relpath,
1378                        const char *original_root_url,
1379                        const char *original_uuid,
1380                        svn_revnum_t original_revision,
1381                        const svn_checksum_t *checksum,
1382                        svn_boolean_t update_actual_props,
1383                        const apr_hash_t *new_actual_props,
1384                        svn_boolean_t is_move,
1385                        const svn_skel_t *conflict,
1386                        const svn_skel_t *work_items,
1387                        apr_pool_t *scratch_pool);
1388
1389
1390svn_error_t *
1391svn_wc__db_op_copy_symlink(svn_wc__db_t *db,
1392                           const char *local_abspath,
1393                           const apr_hash_t *props,
1394                           svn_revnum_t changed_rev,
1395                           apr_time_t changed_date,
1396                           const char *changed_author,
1397                           const char *original_repos_relpath,
1398                           const char *original_root_url,
1399                           const char *original_uuid,
1400                           svn_revnum_t original_revision,
1401                           const char *target,
1402                           const svn_skel_t *conflict,
1403                           const svn_skel_t *work_items,
1404                           apr_pool_t *scratch_pool);
1405
1406
1407/* ### do we need svn_wc__db_op_copy_server_excluded() ??  */
1408
1409
1410/* ### add a new versioned directory. a list of children is NOT passed
1411   ### since they are added in future, distinct calls to db_op_add_*.
1412   PROPS gives the properties; empty or NULL means none. */
1413/* ### do we need a CONFLICTS param?  */
1414svn_error_t *
1415svn_wc__db_op_add_directory(svn_wc__db_t *db,
1416                            const char *local_abspath,
1417                            const apr_hash_t *props,
1418                            const svn_skel_t *work_items,
1419                            apr_pool_t *scratch_pool);
1420
1421
1422/* Add a file.
1423   PROPS gives the properties; empty or NULL means none.
1424   ### this file has no "pristine"
1425   ### contents, so a checksum [reference] is not required.  */
1426/* ### do we need a CONFLICTS param?  */
1427svn_error_t *
1428svn_wc__db_op_add_file(svn_wc__db_t *db,
1429                       const char *local_abspath,
1430                       const apr_hash_t *props,
1431                       const svn_skel_t *work_items,
1432                       apr_pool_t *scratch_pool);
1433
1434
1435/* Add a symlink.
1436   PROPS gives the properties; empty or NULL means none. */
1437/* ### do we need a CONFLICTS param?  */
1438svn_error_t *
1439svn_wc__db_op_add_symlink(svn_wc__db_t *db,
1440                          const char *local_abspath,
1441                          const char *target,
1442                          const apr_hash_t *props,
1443                          const svn_skel_t *work_items,
1444                          apr_pool_t *scratch_pool);
1445
1446
1447/* Set the properties of the node LOCAL_ABSPATH in the ACTUAL tree to
1448   PROPS.
1449
1450   PROPS maps "const char *" names to "const svn_string_t *" values.
1451   To specify no properties, PROPS must be an empty hash, not NULL.
1452   If the node is not present, return an error.
1453
1454   If PROPS is NULL, set the properties to be the same as the pristine
1455   properties.
1456
1457   If CONFLICT is not NULL, it is used to register a conflict on this
1458   node at the same time the properties are changed.
1459
1460   WORK_ITEMS are inserted into the work queue, as additional things that
1461   need to be completed before the working copy is stable.
1462
1463
1464   If CLEAR_RECORDED_INFO is true, the recorded information for the node
1465   is cleared. (commonly used when updating svn:* magic properties).
1466
1467   NOTE: This will overwrite ALL working properties the node currently
1468   has. There is no db_op_set_prop() function. Callers must read all the
1469   properties, change one, and write all the properties.
1470   ### ugh. this has poor transaction semantics...
1471
1472
1473   NOTE: This will create an entry in the ACTUAL table for the node if it
1474   does not yet have one.
1475*/
1476svn_error_t *
1477svn_wc__db_op_set_props(svn_wc__db_t *db,
1478                        const char *local_abspath,
1479                        apr_hash_t *props,
1480                        svn_boolean_t clear_recorded_info,
1481                        const svn_skel_t *conflict,
1482                        const svn_skel_t *work_items,
1483                        apr_pool_t *scratch_pool);
1484
1485/* Mark LOCAL_ABSPATH, and all children, for deletion.
1486 *
1487 * This function removes the file externals (and if DELETE_DIR_EXTERNALS is
1488 * TRUE also the directory externals) registered below LOCAL_ABSPATH.
1489 * (DELETE_DIR_EXTERNALS should be true if also removing unversioned nodes)
1490 *
1491 * If MOVED_TO_ABSPATH is not NULL, mark the deletion of LOCAL_ABSPATH
1492 * as the delete-half of a move from LOCAL_ABSPATH to MOVED_TO_ABSPATH.
1493 *
1494 * If NOTIFY_FUNC is not NULL, then it will be called (with NOTIFY_BATON)
1495 * for each node deleted. While this processing occurs, if CANCEL_FUNC is
1496 * not NULL, then it will be called (with CANCEL_BATON) to detect cancellation
1497 * during the processing.
1498 *
1499 * Note: the notification (and cancellation) occur outside of a SQLite
1500 * transaction.
1501 */
1502svn_error_t *
1503svn_wc__db_op_delete(svn_wc__db_t *db,
1504                     const char *local_abspath,
1505                     const char *moved_to_abspath,
1506                     svn_boolean_t delete_dir_externals,
1507                     svn_skel_t *conflict,
1508                     svn_skel_t *work_items,
1509                     svn_cancel_func_t cancel_func,
1510                     void *cancel_baton,
1511                     svn_wc_notify_func2_t notify_func,
1512                     void *notify_baton,
1513                     apr_pool_t *scratch_pool);
1514
1515
1516/* Mark all LOCAL_ABSPATH in the TARGETS array, and all of their children,
1517 * for deletion.
1518 *
1519 * This function is more efficient than svn_wc__db_op_delete() because
1520 * only one sqlite transaction is used for all targets.
1521 * It currently lacks support for moves (though this could be changed,
1522 * at which point svn_wc__db_op_delete() becomes redundant).
1523 *
1524 * This function removes the file externals (and if DELETE_DIR_EXTERNALS is
1525 * TRUE also the directory externals) registered below the targets.
1526 * (DELETE_DIR_EXTERNALS should be true if also removing unversioned nodes)
1527 *
1528 * If NOTIFY_FUNC is not NULL, then it will be called (with NOTIFY_BATON)
1529 * for each node deleted. While this processing occurs, if CANCEL_FUNC is
1530 * not NULL, then it will be called (with CANCEL_BATON) to detect cancellation
1531 * during the processing.
1532 *
1533 * Note: the notification (and cancellation) occur outside of a SQLite
1534 * transaction.
1535 */
1536svn_error_t *
1537svn_wc__db_op_delete_many(svn_wc__db_t *db,
1538                          apr_array_header_t *targets,
1539                          svn_boolean_t delete_dir_externals,
1540                          const svn_skel_t *conflict,
1541                          svn_cancel_func_t cancel_func,
1542                          void *cancel_baton,
1543                          svn_wc_notify_func2_t notify_func,
1544                          void *notify_baton,
1545                          apr_pool_t *scratch_pool);
1546
1547
1548/* ### mark PATH as (possibly) modified. "svn edit" ... right API here? */
1549svn_error_t *
1550svn_wc__db_op_modified(svn_wc__db_t *db,
1551                       const char *local_abspath,
1552                       apr_pool_t *scratch_pool);
1553
1554
1555/* ### use NULL to remove from a changelist.
1556
1557   ### NOTE: only depth=svn_depth_empty is supported right now.
1558 */
1559svn_error_t *
1560svn_wc__db_op_set_changelist(svn_wc__db_t *db,
1561                             const char *local_abspath,
1562                             const char *new_changelist,
1563                             const apr_array_header_t *changelist_filter,
1564                             svn_depth_t depth,
1565                             /* ### flip to CANCEL, then NOTIFY. precedent.  */
1566                             svn_wc_notify_func2_t notify_func,
1567                             void *notify_baton,
1568                             svn_cancel_func_t cancel_func,
1569                             void *cancel_baton,
1570                             apr_pool_t *scratch_pool);
1571
1572/* Record CONFLICT on LOCAL_ABSPATH, potentially replacing other conflicts
1573   recorded on LOCAL_ABSPATH.
1574
1575   Users should in most cases pass CONFLICT to another WC_DB call instead of
1576   calling svn_wc__db_op_mark_conflict() directly outside a transaction, to
1577   allow recording atomically with the operation involved.
1578
1579   Any work items that are necessary as part of marking this node conflicted
1580   can be passed in WORK_ITEMS.
1581 */
1582svn_error_t *
1583svn_wc__db_op_mark_conflict(svn_wc__db_t *db,
1584                            const char *local_abspath,
1585                            const svn_skel_t *conflict,
1586                            const svn_skel_t *work_items,
1587                            apr_pool_t *scratch_pool);
1588
1589
1590/* ### caller maintains ACTUAL, and how the resolution occurred. we're just
1591   ### recording state.
1592   ###
1593   ### I'm not sure that these three values are the best way to do this,
1594   ### but they're handy for now.  */
1595svn_error_t *
1596svn_wc__db_op_mark_resolved(svn_wc__db_t *db,
1597                            const char *local_abspath,
1598                            svn_boolean_t resolved_text,
1599                            svn_boolean_t resolved_props,
1600                            svn_boolean_t resolved_tree,
1601                            const svn_skel_t *work_items,
1602                            apr_pool_t *scratch_pool);
1603
1604
1605/* Revert all local changes which are being maintained in the database,
1606 * including conflict storage, properties and text modification status.
1607 *
1608 * Returns SVN_ERR_WC_INVALID_OPERATION_DEPTH if the revert is not
1609 * possible, e.g. copy/delete but not a root, or a copy root with
1610 * children.
1611 *
1612 * At present only depth=empty and depth=infinity are supported.
1613 *
1614 * This function populates the revert list that can be queried to
1615 * determine what was reverted.
1616 */
1617svn_error_t *
1618svn_wc__db_op_revert(svn_wc__db_t *db,
1619                     const char *local_abspath,
1620                     svn_depth_t depth,
1621                     apr_pool_t *result_pool,
1622                     apr_pool_t *scratch_pool);
1623
1624/* Query the revert list for LOCAL_ABSPATH and set *REVERTED if the
1625 * path was reverted.  Set *MARKER_FILES to a const char *list of
1626 * marker files if any were recorded on LOCAL_ABSPATH.
1627 *
1628 * Set *COPIED_HERE if the reverted node was copied here and is the
1629 * operation root of the copy.
1630 * Set *KIND to the node kind of the reverted node.
1631 *
1632 * Removes the row for LOCAL_ABSPATH from the revert list.
1633 */
1634svn_error_t *
1635svn_wc__db_revert_list_read(svn_boolean_t *reverted,
1636                            const apr_array_header_t **marker_files,
1637                            svn_boolean_t *copied_here,
1638                            svn_node_kind_t *kind,
1639                            svn_wc__db_t *db,
1640                            const char *local_abspath,
1641                            apr_pool_t *result_pool,
1642                            apr_pool_t *scratch_pool);
1643
1644/* The type of elements in the array returned by
1645 * svn_wc__db_revert_list_read_copied_children(). */
1646typedef struct svn_wc__db_revert_list_copied_child_info_t {
1647  const char *abspath;
1648  svn_node_kind_t kind;
1649} svn_wc__db_revert_list_copied_child_info_t ;
1650
1651/* Return in *CHILDREN a list of reverted copied nodes at or within
1652 * LOCAL_ABSPATH (which is a reverted file or a reverted directory).
1653 * Allocate *COPIED_CHILDREN and its elements in RESULT_POOL.
1654 * The elements are of type svn_wc__db_revert_list_copied_child_info_t. */
1655svn_error_t *
1656svn_wc__db_revert_list_read_copied_children(const apr_array_header_t **children,
1657                                            svn_wc__db_t *db,
1658                                            const char *local_abspath,
1659                                            apr_pool_t *result_pool,
1660                                            apr_pool_t *scratch_pool);
1661
1662
1663/* Make revert notifications for all paths in the revert list that are
1664 * equal to LOCAL_ABSPATH or below LOCAL_ABSPATH.
1665 *
1666 * Removes all the corresponding rows from the revert list.
1667 *
1668 * ### Pass in cancel_func?
1669 */
1670svn_error_t *
1671svn_wc__db_revert_list_notify(svn_wc_notify_func2_t notify_func,
1672                              void *notify_baton,
1673                              svn_wc__db_t *db,
1674                              const char *local_abspath,
1675                              apr_pool_t *scratch_pool);
1676
1677/* Clean up after svn_wc__db_op_revert by removing the revert list.
1678 */
1679svn_error_t *
1680svn_wc__db_revert_list_done(svn_wc__db_t *db,
1681                            const char *local_abspath,
1682                            apr_pool_t *scratch_pool);
1683
1684/* ### status */
1685
1686
1687/* @} */
1688
1689/* @defgroup svn_wc__db_read  Read operations on the BASE/WORKING tree
1690   @{
1691
1692   These functions query information about nodes in ACTUAL, and returns
1693   the requested information from the appropriate ACTUAL, WORKING, or
1694   BASE tree.
1695
1696   For example, asking for the checksum of the pristine version will
1697   return the one recorded in WORKING, or if no WORKING node exists, then
1698   the checksum comes from BASE.
1699*/
1700
1701/* Retrieve information about a node.
1702
1703   For the node implied by LOCAL_ABSPATH from the local filesystem, return
1704   information in the provided OUT parameters. Each OUT parameter may be
1705   NULL, indicating that specific item is not requested.
1706
1707   The information returned comes from the BASE tree, as possibly modified
1708   by the WORKING and ACTUAL trees.
1709
1710   If there is no information about the node, then SVN_ERR_WC_PATH_NOT_FOUND
1711   will be returned.
1712
1713   The OUT parameters, and their "not available" values are:
1714     STATUS                  n/a (always available)
1715     KIND                    svn_node_unknown   (For ACTUAL only nodes)
1716     REVISION                SVN_INVALID_REVNUM
1717     REPOS_RELPATH           NULL
1718     REPOS_ROOT_URL          NULL
1719     REPOS_UUID              NULL
1720     CHANGED_REV             SVN_INVALID_REVNUM
1721     CHANGED_DATE            0
1722     CHANGED_AUTHOR          NULL
1723     DEPTH                   svn_depth_unknown
1724     CHECKSUM                NULL
1725     TARGET                  NULL
1726
1727     ORIGINAL_REPOS_RELPATH  NULL
1728     ORIGINAL_ROOT_URL       NULL
1729     ORIGINAL_UUID           NULL
1730     ORIGINAL_REVISION       SVN_INVALID_REVNUM
1731
1732     LOCK                    NULL
1733
1734     RECORDED_SIZE           SVN_INVALID_FILESIZE
1735     RECORDED_TIME       0
1736
1737     CHANGELIST              NULL
1738     CONFLICTED              FALSE
1739
1740     OP_ROOT                 FALSE
1741     HAD_PROPS               FALSE
1742     PROPS_MOD               FALSE
1743
1744     HAVE_BASE               FALSE
1745     HAVE_MORE_WORK          FALSE
1746     HAVE_WORK               FALSE
1747
1748   When STATUS is requested, then it will be one of these values:
1749
1750     svn_wc__db_status_normal
1751       A plain BASE node, with no local changes.
1752
1753     svn_wc__db_status_added
1754       A node has been added/copied/moved to here. See HAVE_BASE to see
1755       if this change overwrites a BASE node. Use scan_addition() to resolve
1756       whether this has been added, copied, or moved, and the details of the
1757       operation (this function only looks at LOCAL_ABSPATH, but resolving
1758       the details requires scanning one or more ancestor nodes).
1759
1760     svn_wc__db_status_deleted
1761       This node has been deleted or moved away. It may be a delete/move of
1762       a BASE node, or a child node of a subtree that was copied/moved to
1763       an ancestor location. Call scan_deletion() to determine the full
1764       details of the operations upon this node.
1765
1766     svn_wc__db_status_server_excluded
1767       The node is versioned/known by the server, but the server has
1768       decided not to provide further information about the node. This
1769       is a BASE node (since changes are not allowed to this node).
1770
1771     svn_wc__db_status_excluded
1772       The node has been excluded from the working copy tree. This may
1773       be an exclusion from the BASE tree, or an exclusion in the
1774       WORKING tree for a child node of a copied/moved parent.
1775
1776     svn_wc__db_status_not_present
1777       This is a node from the BASE tree, has been marked as "not-present"
1778       within this mixed-revision working copy. This node is at a revision
1779       that is not in the tree, contrary to its inclusion in the parent
1780       node's revision.
1781
1782     svn_wc__db_status_incomplete
1783       The BASE is incomplete due to an interrupted operation.  An
1784       incomplete WORKING node will be svn_wc__db_status_added.
1785
1786   If REVISION is requested, it will be set to the revision of the
1787   unmodified (BASE) node, or to SVN_INVALID_REVNUM if any structural
1788   changes have been made to that node (that is, if the node has a row in
1789   the WORKING table).
1790
1791   If DEPTH is requested, and the node is NOT a directory, then
1792   the value will be set to svn_depth_unknown.
1793
1794   If CHECKSUM is requested, and the node is NOT a file, then it will
1795   be set to NULL.
1796
1797   If TARGET is requested, and the node is NOT a symlink, then it will
1798   be set to NULL.
1799
1800   If TRANSLATED_SIZE is requested, and the node is NOT a file, then
1801   it will be set to SVN_INVALID_FILESIZE.
1802
1803   If HAVE_WORK is TRUE, the returned information is from the highest WORKING
1804   layer. In that case HAVE_MORE_WORK and HAVE_BASE provide information about
1805   what other layers exist for this node.
1806
1807   If HAVE_WORK is FALSE and HAVE_BASE is TRUE then the information is from
1808   the BASE tree.
1809
1810   If HAVE_WORK and HAVE_BASE are both FALSE and when retrieving CONFLICTED,
1811   then the node doesn't exist at all.
1812
1813   If OP_ROOT is requested and the node has a WORKING layer, OP_ROOT will be
1814   set to true if this node is the op_root for this layer.
1815
1816   If HAD_PROPS is requested and the node has pristine props, the value will
1817   be set to TRUE.
1818
1819   If PROPS_MOD is requested and the node has property modification the value
1820   will be set to TRUE.
1821
1822   ### add information about the need to scan upwards to get a complete
1823   ### picture of the state of this node.
1824
1825   ### add some documentation about OUT parameter values based on STATUS ??
1826
1827   ### the TEXT_MOD may become an enumerated value at some point to
1828   ### indicate different states of knowledge about text modifications.
1829   ### for example, an "svn edit" command in the future might set a
1830   ### flag indicating administratively-defined modification. and/or we
1831   ### might have a status indicating that we saw it was modified while
1832   ### performing a filesystem traversal.
1833
1834   All returned data will be allocated in RESULT_POOL. All temporary
1835   allocations will be made in SCRATCH_POOL.
1836*/
1837/* ### old docco. needs to be incorporated as appropriate. there is
1838   ### some pending, potential changes to the definition of this API,
1839   ### so not worrying about it just yet.
1840
1841   ### if the node has not been committed (after adding):
1842   ###   revision will be SVN_INVALID_REVNUM
1843   ###   repos_* will be NULL
1844   ###   changed_rev will be SVN_INVALID_REVNUM
1845   ###   changed_date will be 0
1846   ###   changed_author will be NULL
1847   ###   status will be svn_wc__db_status_added
1848   ###   text_mod will be TRUE
1849   ###   prop_mod will be TRUE if any props have been set
1850   ###   base_shadowed will be FALSE
1851
1852   ### if the node is not a copy, or a move destination:
1853   ###   original_repos_path will be NULL
1854   ###   original_root_url will be NULL
1855   ###   original_uuid will be NULL
1856   ###   original_revision will be SVN_INVALID_REVNUM
1857
1858   ### note that @a base_shadowed can be derived. if the status specifies
1859   ### an add/copy/move *and* there is a corresponding node in BASE, then
1860   ### the BASE has been deleted to open the way for this node.
1861*/
1862svn_error_t *
1863svn_wc__db_read_info(svn_wc__db_status_t *status,  /* ### derived */
1864                     svn_node_kind_t *kind,
1865                     svn_revnum_t *revision,
1866                     const char **repos_relpath,
1867                     const char **repos_root_url,
1868                     const char **repos_uuid,
1869                     svn_revnum_t *changed_rev,
1870                     apr_time_t *changed_date,
1871                     const char **changed_author,
1872                     svn_depth_t *depth,  /* dirs only */
1873                     const svn_checksum_t **checksum, /* files only */
1874                     const char **target, /* symlinks only */
1875
1876                     /* ### the following fields if copied/moved (history) */
1877                     const char **original_repos_relpath,
1878                     const char **original_root_url,
1879                     const char **original_uuid,
1880                     svn_revnum_t *original_revision,
1881
1882                     /* For BASE nodes */
1883                     svn_wc__db_lock_t **lock,
1884
1885                     /* Recorded for files present in the working copy */
1886                     svn_filesize_t *recorded_size,
1887                     apr_time_t *recorded_time,
1888
1889                     /* From ACTUAL */
1890                     const char **changelist,
1891                     svn_boolean_t *conflicted,
1892
1893                     /* ### the followed are derived fields */
1894                     svn_boolean_t *op_root,
1895
1896                     svn_boolean_t *had_props,
1897                     svn_boolean_t *props_mod,
1898
1899                     svn_boolean_t *have_base,
1900                     svn_boolean_t *have_more_work,
1901                     svn_boolean_t *have_work,
1902
1903                     svn_wc__db_t *db,
1904                     const char *local_abspath,
1905                     apr_pool_t *result_pool,
1906                     apr_pool_t *scratch_pool);
1907
1908/* Structure returned by svn_wc__db_read_children_info.  Only has the
1909   fields needed by status. */
1910struct svn_wc__db_info_t {
1911  svn_wc__db_status_t status;
1912  svn_node_kind_t kind;
1913  svn_revnum_t revnum;
1914  const char *repos_relpath;
1915  const char *repos_root_url;
1916  const char *repos_uuid;
1917  svn_revnum_t changed_rev;
1918  const char *changed_author;
1919  apr_time_t changed_date;
1920  svn_depth_t depth;
1921
1922  svn_filesize_t recorded_size;
1923  apr_time_t recorded_time;
1924
1925  const char *changelist;
1926  svn_boolean_t conflicted;
1927#ifdef HAVE_SYMLINK
1928  svn_boolean_t special;
1929#endif
1930  svn_boolean_t op_root;
1931
1932  svn_boolean_t has_checksum;
1933  svn_boolean_t copied;
1934  svn_boolean_t had_props;
1935  svn_boolean_t props_mod;
1936
1937  svn_boolean_t have_base;
1938  svn_boolean_t have_more_work;
1939
1940  svn_boolean_t locked;     /* WC directory lock */
1941  svn_wc__db_lock_t *lock;  /* Repository file lock */
1942  svn_boolean_t incomplete; /* TRUE if a working node is incomplete */
1943
1944  const char *moved_to_abspath; /* Only on op-roots. See svn_wc_status3_t. */
1945  svn_boolean_t moved_here;     /* Only on op-roots. */
1946
1947  svn_boolean_t file_external;
1948};
1949
1950/* Return in *NODES a hash mapping name->struct svn_wc__db_info_t for
1951   the children of DIR_ABSPATH, and in *CONFLICTS a hash of names in
1952   conflict.
1953
1954   The results include any path that was a child of a deleted directory that
1955   existed at LOCAL_ABSPATH, even if that directory is now scheduled to be
1956   replaced by the working node at LOCAL_ABSPATH.
1957 */
1958svn_error_t *
1959svn_wc__db_read_children_info(apr_hash_t **nodes,
1960                              apr_hash_t **conflicts,
1961                              svn_wc__db_t *db,
1962                              const char *dir_abspath,
1963                              apr_pool_t *result_pool,
1964                              apr_pool_t *scratch_pool);
1965
1966
1967/* Structure returned by svn_wc__db_read_walker_info.  Only has the
1968   fields needed by svn_wc__internal_walk_children(). */
1969struct svn_wc__db_walker_info_t {
1970  svn_wc__db_status_t status;
1971  svn_node_kind_t kind;
1972};
1973
1974/* When a node is deleted in WORKING, some of its information is no longer
1975   available. But in some cases it might still be relevant to obtain this
1976   information even when the information isn't stored in the BASE tree.
1977
1978   This function allows access to that specific information.
1979
1980   When a node is not deleted, this node returns the same information
1981   as svn_wc__db_read_info().
1982
1983   All output arguments are optional and behave in the same way as when
1984   calling svn_wc__db_read_info().
1985
1986   (All other information (like original_*) can be obtained via other apis).
1987
1988   *PROPS maps "const char *" names to "const svn_string_t *" values.  If
1989   the pristine node is capable of having properties but has none, set
1990   *PROPS to an empty hash.  If its status is such that it cannot have
1991   properties, set *PROPS to NULL.
1992 */
1993svn_error_t *
1994svn_wc__db_read_pristine_info(svn_wc__db_status_t *status,
1995                              svn_node_kind_t *kind,
1996                              svn_revnum_t *changed_rev,
1997                              apr_time_t *changed_date,
1998                              const char **changed_author,
1999                              svn_depth_t *depth,  /* dirs only */
2000                              const svn_checksum_t **checksum, /* files only */
2001                              const char **target, /* symlinks only */
2002                              svn_boolean_t *had_props,
2003                              apr_hash_t **props,
2004                              svn_wc__db_t *db,
2005                              const char *local_abspath,
2006                              apr_pool_t *result_pool,
2007                              apr_pool_t *scratch_pool);
2008
2009/* Gets the information required to install a pristine file to the working copy
2010
2011   Set WCROOT_ABSPATH to the working copy root, SHA1_CHECKSUM to the
2012   checksum of the node (a valid reference into the pristine store)
2013   and PRISTINE_PROPS to the node's pristine properties (to use for
2014   installing the file).
2015
2016   If WRI_ABSPATH is not NULL, check for information in the working copy
2017   identified by WRI_ABSPATH.
2018   */
2019svn_error_t *
2020svn_wc__db_read_node_install_info(const char **wcroot_abspath,
2021                                  const svn_checksum_t **sha1_checksum,
2022                                  apr_hash_t **pristine_props,
2023                                  apr_time_t *changed_date,
2024                                  svn_wc__db_t *db,
2025                                  const char *local_abspath,
2026                                  const char *wri_abspath,
2027                                  apr_pool_t *result_pool,
2028                                  apr_pool_t *scratch_pool);
2029
2030/* Return in *NODES a hash mapping name->struct svn_wc__db_walker_info_t for
2031   the children of DIR_ABSPATH. "name" is the child's name relative to
2032   DIR_ABSPATH, not an absolute path. */
2033svn_error_t *
2034svn_wc__db_read_children_walker_info(apr_hash_t **nodes,
2035                                     svn_wc__db_t *db,
2036                                     const char *dir_abspath,
2037                                     apr_pool_t *result_pool,
2038                                     apr_pool_t *scratch_pool);
2039
2040
2041/**
2042 * Set *URL to the corresponding url for LOCAL_ABSPATH.
2043 * If the node is added, return the url it will have in the repository.
2044 */
2045svn_error_t *
2046svn_wc__db_read_url(const char **url,
2047                    svn_wc__db_t *db,
2048                    const char *local_abspath,
2049                    apr_pool_t *result_pool,
2050                    apr_pool_t *scratch_pool);
2051
2052
2053/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the ACTUAL
2054   tree (looking through to the WORKING or BASE tree as required).
2055
2056   ### *PROPS will be set to NULL in the following situations:
2057   ### ... tbd
2058
2059   PROPS maps "const char *" names to "const svn_string_t *" values.
2060   If the node has no properties, set *PROPS to an empty hash.
2061   If the node is not present, return an error.
2062   Allocate *PROPS and its keys and values in RESULT_POOL.
2063*/
2064svn_error_t *
2065svn_wc__db_read_props(apr_hash_t **props,
2066                      svn_wc__db_t *db,
2067                      const char *local_abspath,
2068                      apr_pool_t *result_pool,
2069                      apr_pool_t *scratch_pool);
2070
2071/* Call RECEIVER_FUNC, passing RECEIVER_BATON, an absolute path, and
2072 * a hash table mapping <tt>char *</tt> names onto svn_string_t *
2073 * values for any properties of child nodes of LOCAL_ABSPATH (up to DEPTH).
2074 *
2075 * If PRISTINE is FALSE, read the properties from the WORKING layer (highest
2076 * op_depth); if PRISTINE is FALSE, local modifications will be visible.
2077 */
2078svn_error_t *
2079svn_wc__db_read_props_streamily(svn_wc__db_t *db,
2080                                const char *local_abspath,
2081                                svn_depth_t depth,
2082                                svn_boolean_t pristine,
2083                                const apr_array_header_t *changelists,
2084                                svn_wc__proplist_receiver_t receiver_func,
2085                                void *receiver_baton,
2086                                svn_cancel_func_t cancel_func,
2087                                void *cancel_baton,
2088                                apr_pool_t *scratch_pool);
2089
2090
2091/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the WORKING
2092   tree (looking through to the BASE tree as required).
2093
2094   ### *PROPS will set set to NULL in the following situations:
2095   ### ... tbd.  see props.c:svn_wc__get_pristine_props()
2096
2097   *PROPS maps "const char *" names to "const svn_string_t *" values.
2098   If the node has no properties, set *PROPS to an empty hash.
2099   If the node is not present, return an error.
2100   Allocate *PROPS and its keys and values in RESULT_POOL.
2101*/
2102svn_error_t *
2103svn_wc__db_read_pristine_props(apr_hash_t **props,
2104                               svn_wc__db_t *db,
2105                               const char *local_abspath,
2106                               apr_pool_t *result_pool,
2107                               apr_pool_t *scratch_pool);
2108
2109
2110/**
2111 * Set @a *iprops to a depth-first ordered array of
2112 * #svn_prop_inherited_item_t * structures representing the properties
2113 * inherited by @a local_abspath from the ACTUAL tree above
2114 * @a local_abspath (looking through to the WORKING or BASE tree as
2115 * required), up to and including the root of the working copy and
2116 * any cached inherited properties inherited by the root.
2117 *
2118 * The #svn_prop_inherited_item_t->path_or_url members of the
2119 * #svn_prop_inherited_item_t * structures in @a *iprops are
2120 * paths relative to the repository root URL for cached inherited
2121 * properties and absolute working copy paths otherwise.
2122 *
2123 * If ACTUAL_PROPS is not NULL, then set *ACTUAL_PROPS to the actual
2124 * properties stored on LOCAL_ABSPATH.
2125 *
2126 * Allocate @a *iprops in @a result_pool.  Use @a scratch_pool
2127 * for temporary allocations.
2128 */
2129svn_error_t *
2130svn_wc__db_read_inherited_props(apr_array_header_t **iprops,
2131                                apr_hash_t **actual_props,
2132                                svn_wc__db_t *db,
2133                                const char *local_abspath,
2134                                const char *propname,
2135                                apr_pool_t *result_pool,
2136                                apr_pool_t *scratch_pool);
2137
2138/* Read a BASE node's inherited property information.
2139
2140   Set *IPROPS to to a depth-first ordered array of
2141   svn_prop_inherited_item_t * structures representing the cached
2142   inherited properties for the BASE node at LOCAL_ABSPATH.
2143
2144   If no cached properties are found, then set *IPROPS to NULL.
2145   If LOCAL_ABSPATH represents the root of the repository, then set
2146   *IPROPS to an empty array.
2147
2148   Allocate *IPROPS in RESULT_POOL, use SCRATCH_POOL for temporary
2149   allocations. */
2150svn_error_t *
2151svn_wc__db_read_cached_iprops(apr_array_header_t **iprops,
2152                              svn_wc__db_t *db,
2153                              const char *local_abspath,
2154                              apr_pool_t *result_pool,
2155                              apr_pool_t *scratch_pool);
2156
2157/* Find BASE nodes with cached inherited properties.
2158
2159   Set *IPROPS_PATHS to a hash mapping const char * absolute working copy
2160   paths to the repos_relpath of the path for each path in the working copy
2161   at or below LOCAL_ABSPATH, limited by DEPTH, that has cached inherited
2162   properties for the BASE node of the path.
2163
2164   Allocate *IPROP_PATHS in RESULT_POOL.
2165   Use SCRATCH_POOL for temporary allocations. */
2166svn_error_t *
2167svn_wc__db_get_children_with_cached_iprops(apr_hash_t **iprop_paths,
2168                                           svn_depth_t depth,
2169                                           const char *local_abspath,
2170                                           svn_wc__db_t *db,
2171                                           apr_pool_t *result_pool,
2172                                           apr_pool_t *scratch_pool);
2173
2174/** Obtain a mapping of const char * local_abspaths to const svn_string_t*
2175 * property values in *VALUES, of all PROPNAME properties on LOCAL_ABSPATH
2176 * and its descendants.
2177 *
2178 * Allocate the result in RESULT_POOL, and perform temporary allocations in
2179 * SCRATCH_POOL.
2180 */
2181svn_error_t *
2182svn_wc__db_prop_retrieve_recursive(apr_hash_t **values,
2183                                   svn_wc__db_t *db,
2184                                   const char *local_abspath,
2185                                   const char *propname,
2186                                   apr_pool_t *result_pool,
2187                                   apr_pool_t *scratch_pool);
2188
2189/* Set *CHILDREN to a new array of the (const char *) basenames of the
2190   immediate children of the working node at LOCAL_ABSPATH in DB.
2191
2192   Return every path that refers to a child of the working node at
2193   LOCAL_ABSPATH.  Do not include a path just because it was a child of a
2194   deleted directory that existed at LOCAL_ABSPATH if that directory is now
2195   scheduled to be replaced by the working node at LOCAL_ABSPATH.
2196
2197   Allocate *CHILDREN in RESULT_POOL and do temporary allocations in
2198   SCRATCH_POOL.
2199
2200   ### return some basic info for each child? e.g. kind.
2201   ### maybe the data in _read_get_info should be a structure, and this
2202   ### can return a struct for each one.
2203   ### however: _read_get_info can say "not interested", which isn't the
2204   ###   case with a struct. thus, a struct requires fetching and/or
2205   ###   computing all info.
2206*/
2207svn_error_t *
2208svn_wc__db_read_children_of_working_node(const apr_array_header_t **children,
2209                                         svn_wc__db_t *db,
2210                                         const char *local_abspath,
2211                                         apr_pool_t *result_pool,
2212                                         apr_pool_t *scratch_pool);
2213
2214/* Like svn_wc__db_read_children_of_working_node(), except also include any
2215   path that was a child of a deleted directory that existed at
2216   LOCAL_ABSPATH, even if that directory is now scheduled to be replaced by
2217   the working node at LOCAL_ABSPATH.
2218*/
2219svn_error_t *
2220svn_wc__db_read_children(const apr_array_header_t **children,
2221                         svn_wc__db_t *db,
2222                         const char *local_abspath,
2223                         apr_pool_t *result_pool,
2224                         apr_pool_t *scratch_pool);
2225
2226/* Read into *VICTIMS the basenames of the immediate children of
2227   LOCAL_ABSPATH in DB that are conflicted.
2228
2229   In case of tree conflicts a victim doesn't have to be in the
2230   working copy.
2231
2232   Allocate *VICTIMS in RESULT_POOL and do temporary allocations in
2233   SCRATCH_POOL */
2234/* ### This function will probably be removed. */
2235svn_error_t *
2236svn_wc__db_read_conflict_victims(const apr_array_header_t **victims,
2237                                 svn_wc__db_t *db,
2238                                 const char *local_abspath,
2239                                 apr_pool_t *result_pool,
2240                                 apr_pool_t *scratch_pool);
2241
2242/* Read into *MARKER_FILES the absolute paths of the marker files
2243   of conflicts stored on LOCAL_ABSPATH and its immediate children in DB.
2244   The on-disk files may have been deleted by the user.
2245
2246   Allocate *MARKER_FILES in RESULT_POOL and do temporary allocations
2247   in SCRATCH_POOL */
2248svn_error_t *
2249svn_wc__db_get_conflict_marker_files(apr_hash_t **markers,
2250                                     svn_wc__db_t *db,
2251                                     const char *local_abspath,
2252                                     apr_pool_t *result_pool,
2253                                     apr_pool_t *scratch_pool);
2254
2255/* Read the conflict information recorded on LOCAL_ABSPATH in *CONFLICT,
2256   an editable conflict skel.
2257
2258   If the node exists, but does not have a conflict set *CONFLICT to NULL,
2259   otherwise return a SVN_ERR_WC_PATH_NOT_FOUND error.
2260
2261   Allocate *CONFLICTS in RESULT_POOL and do temporary allocations in
2262   SCRATCH_POOL */
2263svn_error_t *
2264svn_wc__db_read_conflict(svn_skel_t **conflict,
2265                         svn_wc__db_t *db,
2266                         const char *local_abspath,
2267                         apr_pool_t *result_pool,
2268                         apr_pool_t *scratch_pool);
2269
2270
2271/* Return the kind of the node in DB at LOCAL_ABSPATH. The WORKING tree will
2272   be examined first, then the BASE tree. If the node is not present in either
2273   tree and ALLOW_MISSING is TRUE, then svn_node_unknown is returned.
2274   If the node is missing and ALLOW_MISSING is FALSE, then it will return
2275   SVN_ERR_WC_PATH_NOT_FOUND.
2276
2277   The SHOW_HIDDEN and SHOW_DELETED flags report certain states as kind none.
2278
2279   When nodes have certain statee they are only reported when:
2280      svn_wc__db_status_not_present         when show_hidden && show_deleted
2281
2282      svn_wc__db_status_excluded            when show_hidden
2283      svn_wc__db_status_server_excluded     when show_hidden
2284
2285      svn_wc__db_status_deleted             when show_deleted
2286
2287   In other cases these nodes are reported with *KIND as svn_node_none.
2288   (See also svn_wc_read_kind2()'s documentation)
2289
2290   Uses SCRATCH_POOL for temporary allocations.  */
2291svn_error_t *
2292svn_wc__db_read_kind(svn_node_kind_t *kind,
2293                     svn_wc__db_t *db,
2294                     const char *local_abspath,
2295                     svn_boolean_t allow_missing,
2296                     svn_boolean_t show_deleted,
2297                     svn_boolean_t show_hidden,
2298                     apr_pool_t *scratch_pool);
2299
2300
2301/* An analog to svn_wc__entry_is_hidden().  Set *HIDDEN to TRUE if
2302   LOCAL_ABSPATH in DB "is not present, and I haven't scheduled something
2303   over the top of it." */
2304svn_error_t *
2305svn_wc__db_node_hidden(svn_boolean_t *hidden,
2306                       svn_wc__db_t *db,
2307                       const char *local_abspath,
2308                       apr_pool_t *scratch_pool);
2309
2310/* Checks if a node replaces a node in a different layer. Also check if it
2311   replaces a BASE (op_depth 0) node or just a node in a higher layer (a copy).
2312   Finally check if this is the root of the replacement, or if the replacement
2313   is initiated by the parent node.
2314
2315   IS_REPLACE_ROOT (if not NULL) is set to TRUE if the node is the root of a
2316   replacement; otherwise to FALSE.
2317
2318   BASE_REPLACE (if not NULL) is set to TRUE if the node directly or indirectly
2319   replaces a node in the BASE tree; otherwise to FALSE.
2320
2321   IS_REPLACE (if not NULL) is set to TRUE if the node directly replaces a node
2322   in a lower layer; otherwise to FALSE.
2323 */
2324svn_error_t *
2325svn_wc__db_node_check_replace(svn_boolean_t *is_replace_root,
2326                              svn_boolean_t *base_replace,
2327                              svn_boolean_t *is_replace,
2328                              svn_wc__db_t *db,
2329                              const char *local_abspath,
2330                              apr_pool_t *scratch_pool);
2331
2332/* ### changelists. return an array, or an iterator interface? how big
2333   ### are these things? are we okay with an in-memory array? examine other
2334   ### changelist usage -- we may already assume the list fits in memory.
2335*/
2336
2337/* The DB-private version of svn_wc__is_wcroot(), which see.
2338 */
2339svn_error_t *
2340svn_wc__db_is_wcroot(svn_boolean_t *is_wcroot,
2341                     svn_wc__db_t *db,
2342                     const char *local_abspath,
2343                     apr_pool_t *scratch_pool);
2344
2345/* Check whether a node is a working copy root and/or switched.
2346
2347   If LOCAL_ABSPATH is the root of a working copy, set *IS_WC_ROOT to TRUE,
2348   otherwise to FALSE.
2349
2350   If LOCAL_ABSPATH is switched against its parent in the same working copy
2351   set *IS_SWITCHED to TRUE, otherwise to FALSE.
2352
2353   If KIND is not null, set *KIND to the node type of LOCAL_ABSPATH.
2354
2355   Any of the output arguments can be null to specify that the result is not
2356   interesting to the caller.
2357
2358   Use SCRATCH_POOL for temporary allocations.
2359 */
2360svn_error_t *
2361svn_wc__db_is_switched(svn_boolean_t *is_wcroot,
2362                       svn_boolean_t *is_switched,
2363                       svn_node_kind_t *kind,
2364                       svn_wc__db_t *db,
2365                       const char *local_abspath,
2366                       apr_pool_t *scratch_pool);
2367
2368
2369/* @} */
2370
2371
2372/* @defgroup svn_wc__db_global  Operations that alter multiple trees
2373   @{
2374*/
2375
2376/* Associate LOCAL_DIR_ABSPATH, and all its children with the repository at
2377   at REPOS_ROOT_URL.  The relative path to the repos root will not change,
2378   just the repository root.  The repos uuid will also remain the same.
2379   This also updates any locks which may exist for the node, as well as any
2380   copyfrom repository information.  Finally, the DAV cache (aka
2381   "wcprops") will be reset for affected entries.
2382
2383   Use SCRATCH_POOL for any temporary allocations.
2384
2385   ### local_dir_abspath "should be" the wcroot or a switch root. all URLs
2386   ### under this directory (depth=infinity) will be rewritten.
2387
2388   ### This API had a depth parameter, which was removed, should it be
2389   ### resurrected?  What's the purpose if we claim relocate is infinitely
2390   ### recursive?
2391
2392   ### Assuming the future ability to copy across repositories, should we
2393   ### refrain from resetting the copyfrom information in this operation?
2394*/
2395svn_error_t *
2396svn_wc__db_global_relocate(svn_wc__db_t *db,
2397                           const char *local_dir_abspath,
2398                           const char *repos_root_url,
2399                           apr_pool_t *scratch_pool);
2400
2401
2402/* ### docco
2403
2404   ### collapse the WORKING and ACTUAL tree changes down into BASE, called
2405       for each committed node.
2406
2407   NEW_REVISION must be the revision number of the revision created by
2408   the commit. It will become the BASE node's 'revnum' and 'changed_rev'
2409   values in the BASE_NODE table.
2410
2411   CHANGED_REVISION is the new 'last changed' revision. If the node is
2412   modified its value is equivalent to NEW_REVISION, but in case of a
2413   descendant of a copy/move it can be an older revision.
2414
2415   CHANGED_DATE is the (server-side) date of CHANGED_REVISION. It may be 0 if
2416   the revprop is missing on the revision.
2417
2418   CHANGED_AUTHOR is the (server-side) author of CHANGED_REVISION. It may be
2419   NULL if the revprop is missing on the revision.
2420
2421   One or both of NEW_CHECKSUM and NEW_CHILDREN should be NULL. For new:
2422     files: NEW_CHILDREN should be NULL
2423     dirs: NEW_CHECKSUM should be NULL
2424     symlinks: both should be NULL
2425
2426   WORK_ITEMS will be place into the work queue.
2427*/
2428svn_error_t *
2429svn_wc__db_global_commit(svn_wc__db_t *db,
2430                         const char *local_abspath,
2431                         svn_revnum_t new_revision,
2432                         svn_revnum_t changed_revision,
2433                         apr_time_t changed_date,
2434                         const char *changed_author,
2435                         const svn_checksum_t *new_checksum,
2436                         const apr_array_header_t *new_children,
2437                         apr_hash_t *new_dav_cache,
2438                         svn_boolean_t keep_changelist,
2439                         svn_boolean_t no_unlock,
2440                         const svn_skel_t *work_items,
2441                         apr_pool_t *scratch_pool);
2442
2443
2444/* ### docco
2445
2446   Perform an "update" operation at this node. It will create/modify a BASE
2447   node, and possibly update the ACTUAL tree's node (e.g put the node into
2448   a conflicted state).
2449
2450   ### there may be cases where we need to tweak an existing WORKING node
2451
2452   ### this operations on a single node, but may affect children
2453
2454   ### the repository cannot be changed with this function, but a "switch"
2455   ### (aka changing repos_relpath) is possible
2456
2457   ### one of NEW_CHILDREN, NEW_CHECKSUM, or NEW_TARGET must be provided.
2458   ### the other two values must be NULL.
2459   ### should this be broken out into an update_(directory|file|symlink) ?
2460
2461   ### how does this differ from base_add_*? just the CONFLICT param.
2462   ### the WORK_ITEMS param is new here, but the base_add_* functions
2463   ### should probably grow that. should we instead just (re)use base_add
2464   ### rather than grow a new function?
2465
2466   ### this does not allow a change of depth
2467
2468   ### we do not update a file's TRANSLATED_SIZE here. at some future point,
2469   ### when the file is installed, then a TRANSLATED_SIZE will be set.
2470*/
2471svn_error_t *
2472svn_wc__db_global_update(svn_wc__db_t *db,
2473                         const char *local_abspath,
2474                         svn_node_kind_t new_kind,
2475                         const char *new_repos_relpath,
2476                         svn_revnum_t new_revision,
2477                         const apr_hash_t *new_props,
2478                         svn_revnum_t new_changed_rev,
2479                         apr_time_t new_changed_date,
2480                         const char *new_changed_author,
2481                         const apr_array_header_t *new_children,
2482                         const svn_checksum_t *new_checksum,
2483                         const char *new_target,
2484                         const apr_hash_t *new_dav_cache,
2485                         const svn_skel_t *conflict,
2486                         const svn_skel_t *work_items,
2487                         apr_pool_t *scratch_pool);
2488
2489
2490/* Modify the entry of working copy LOCAL_ABSPATH, presumably after an update
2491   of depth DEPTH completes.  If LOCAL_ABSPATH doesn't exist, this routine
2492   does nothing.
2493
2494   Set the node's repository relpath, repository root, repository uuid and
2495   revision to NEW_REPOS_RELPATH, NEW_REPOS_ROOT and NEW_REPOS_UUID.  If
2496   NEW_REPOS_RELPATH is null, the repository location is untouched; if
2497   NEW_REVISION in invalid, the working revision field is untouched.
2498   The modifications are mutually exclusive.  If NEW_REPOS_ROOT is non-NULL,
2499   set the repository root of the entry to NEW_REPOS_ROOT.
2500
2501   If LOCAL_ABSPATH is a directory, then, walk entries below LOCAL_ABSPATH
2502   according to DEPTH thusly:
2503
2504   If DEPTH is svn_depth_infinity, perform the following actions on
2505   every entry below PATH; if svn_depth_immediates, svn_depth_files,
2506   or svn_depth_empty, perform them only on LOCAL_ABSPATH.
2507
2508   If NEW_REVISION is valid, then tweak every entry to have this new
2509   working revision (excluding files that are scheduled for addition
2510   or replacement).  Likewise, if BASE_URL is non-null, then rewrite
2511   all urls to be "telescoping" children of the base_url.
2512
2513   EXCLUDE_RELPATHS is a hash containing const char *local_relpath.  Nodes
2514   for pathnames contained in EXCLUDE_RELPATHS are not touched by this
2515   function.  These pathnames should be paths relative to the wcroot.
2516
2517   If WCROOT_IPROPS is not NULL it is a hash mapping const char * absolute
2518   working copy paths to depth-first ordered arrays of
2519   svn_prop_inherited_item_t * structures.  If LOCAL_ABSPATH exists in
2520   WCROOT_IPROPS, then set the hashed value as the node's inherited
2521   properties.
2522*/
2523svn_error_t *
2524svn_wc__db_op_bump_revisions_post_update(svn_wc__db_t *db,
2525                                         const char *local_abspath,
2526                                         svn_depth_t depth,
2527                                         const char *new_repos_relpath,
2528                                         const char *new_repos_root_url,
2529                                         const char *new_repos_uuid,
2530                                         svn_revnum_t new_revision,
2531                                         apr_hash_t *exclude_relpaths,
2532                                         apr_hash_t *wcroot_iprops,
2533                                         svn_wc_notify_func2_t notify_func,
2534                                         void *notify_baton,
2535                                         apr_pool_t *scratch_pool);
2536
2537
2538/* Record the RECORDED_SIZE and RECORDED_TIME for a versioned node.
2539
2540   This function will record the information within the WORKING node,
2541   if present, or within the BASE tree. If neither node is present, then
2542   SVN_ERR_WC_PATH_NOT_FOUND will be returned.
2543
2544   RECORDED_SIZE may be SVN_INVALID_FILESIZE, which will be recorded
2545   as such, implying "unknown size".
2546
2547   RECORDED_TIME may be 0, which will be recorded as such, implying
2548   "unknown last mod time".
2549*/
2550svn_error_t *
2551svn_wc__db_global_record_fileinfo(svn_wc__db_t *db,
2552                                  const char *local_abspath,
2553                                  svn_filesize_t recorded_size,
2554                                  apr_time_t recorded_time,
2555                                  apr_pool_t *scratch_pool);
2556
2557
2558/* ### post-commit handling.
2559   ### maybe multiple phases?
2560   ### 1) mark a changelist as being-committed
2561   ### 2) collect ACTUAL content, store for future use as TEXTBASE
2562   ### 3) caller performs commit
2563   ### 4) post-commit, integrate changelist into BASE
2564*/
2565
2566
2567/* @} */
2568
2569
2570/* @defgroup svn_wc__db_lock  Function to manage the LOCKS table.
2571   @{
2572*/
2573
2574/* Add or replace LOCK for LOCAL_ABSPATH to DB.  */
2575svn_error_t *
2576svn_wc__db_lock_add(svn_wc__db_t *db,
2577                    const char *local_abspath,
2578                    const svn_wc__db_lock_t *lock,
2579                    apr_pool_t *scratch_pool);
2580
2581
2582/* Remove any lock for LOCAL_ABSPATH in DB.  */
2583svn_error_t *
2584svn_wc__db_lock_remove(svn_wc__db_t *db,
2585                       const char *local_abspath,
2586                       apr_pool_t *scratch_pool);
2587
2588
2589/* @} */
2590
2591
2592/* @defgroup svn_wc__db_scan  Functions to scan up a tree for further data.
2593   @{
2594*/
2595
2596/* Read a BASE node's repository information.
2597
2598   For the BASE node implied by LOCAL_ABSPATH, its location in the repository
2599   returned in *REPOS_ROOT_URL and *REPOS_UUID will be returned in
2600   *REPOS_RELPATH. Any of the OUT parameters may be NULL, indicating no
2601   interest in that piece of information.
2602
2603   All returned data will be allocated in RESULT_POOL. All temporary
2604   allocations will be made in SCRATCH_POOL.
2605
2606   ### Either delete this function and use _base_get_info instead, or
2607   ### add a 'revision' output to make a complete repository node location
2608   ### and rename to not say 'scan', because it doesn't.
2609*/
2610svn_error_t *
2611svn_wc__db_scan_base_repos(const char **repos_relpath,
2612                           const char **repos_root_url,
2613                           const char **repos_uuid,
2614                           svn_wc__db_t *db,
2615                           const char *local_abspath,
2616                           apr_pool_t *result_pool,
2617                           apr_pool_t *scratch_pool);
2618
2619
2620/* Scan upwards for information about a known addition to the WORKING tree.
2621
2622   IFF a node's status as returned by svn_wc__db_read_info() is
2623   svn_wc__db_status_added (NOT obstructed_add!), then this function
2624   returns a refined status in *STATUS, which is one of:
2625
2626     svn_wc__db_status_added -- this NODE is a simple add without history.
2627       OP_ROOT_ABSPATH will be set to the topmost node in the added subtree
2628       (implying its parent will be an unshadowed BASE node). The REPOS_*
2629       values will be implied by that ancestor BASE node and this node's
2630       position in the added subtree. ORIGINAL_* will be set to their
2631       NULL values (and SVN_INVALID_REVNUM for ORIGINAL_REVISION).
2632
2633     svn_wc__db_status_copied -- this NODE is the root or child of a copy.
2634       The root of the copy will be stored in OP_ROOT_ABSPATH. Note that
2635       the parent of the operation root could be another WORKING node (from
2636       an add, copy, or move). The REPOS_* values will be implied by the
2637       ancestor unshadowed BASE node. ORIGINAL_* will indicate the source
2638       of the copy.
2639
2640     svn_wc__db_status_incomplete -- this NODE is copied but incomplete.
2641
2642     svn_wc__db_status_moved_here -- this NODE arrived as a result of a move.
2643       The root of the moved nodes will be stored in OP_ROOT_ABSPATH.
2644       Similar to the copied state, its parent may be a WORKING node or a
2645       BASE node. And again, the REPOS_* values are implied by this node's
2646       position in the subtree under the ancestor unshadowed BASE node.
2647       ORIGINAL_* will indicate the source of the move.
2648
2649   All OUT parameters may be NULL to indicate a lack of interest in
2650   that piece of information.
2651
2652   STATUS, OP_ROOT_ABSPATH, and REPOS_* will always be assigned a value
2653   if that information is requested (and assuming a successful return).
2654
2655   ORIGINAL_REPOS_RELPATH will refer to the *root* of the operation. It
2656   does *not* correspond to the node given by LOCAL_ABSPATH. The caller
2657   can use the suffix on LOCAL_ABSPATH (relative to OP_ROOT_ABSPATH) in
2658   order to compute the source node which corresponds to LOCAL_ABSPATH.
2659
2660   If the node given by LOCAL_ABSPATH does not have changes recorded in
2661   the WORKING tree, then SVN_ERR_WC_PATH_NOT_FOUND is returned. If it
2662   doesn't have an "added" status, then SVN_ERR_WC_PATH_UNEXPECTED_STATUS
2663   will be returned.
2664
2665   All returned data will be allocated in RESULT_POOL. All temporary
2666   allocations will be made in SCRATCH_POOL.
2667*/
2668svn_error_t *
2669svn_wc__db_scan_addition(svn_wc__db_status_t *status,
2670                         const char **op_root_abspath,
2671                         const char **repos_relpath,
2672                         const char **repos_root_url,
2673                         const char **repos_uuid,
2674                         const char **original_repos_relpath,
2675                         const char **original_root_url,
2676                         const char **original_uuid,
2677                         svn_revnum_t *original_revision,
2678                         svn_wc__db_t *db,
2679                         const char *local_abspath,
2680                         apr_pool_t *result_pool,
2681                         apr_pool_t *scratch_pool);
2682
2683/* Scan the working copy for move information of the node LOCAL_ABSPATH.
2684 * If LOCAL_ABSPATH return a SVN_ERR_WC_PATH_UNEXPECTED_STATUS error.
2685 *
2686 * If not NULL *MOVED_FROM_ABSPATH will be set to the previous location
2687 * of LOCAL_ABSPATH, before it or an ancestror was moved.
2688 *
2689 * If not NULL *OP_ROOT_ABSPATH will be set to the new location of the
2690 * path that was actually moved
2691 *
2692 * If not NULL *OP_ROOT_MOVED_FROM_ABSPATH will be set to the old location
2693 * of the path that was actually moved.
2694 *
2695 * If not NULL *MOVED_FROM_DELETE_ABSPATH will be set to the ancestor of the
2696 * moved from location that deletes the original location
2697 *
2698 * Given a working copy
2699 * A/B/C
2700 * svn mv A/B D
2701 * svn rm A
2702 *
2703 * You can call this function on D and D/C. When called on D/C all output
2704 *              MOVED_FROM_ABSPATH will be A/B/C
2705 *              OP_ROOT_ABSPATH will be D
2706 *              OP_ROOT_MOVED_FROM_ABSPATH will be A/B
2707 *              MOVED_FROM_DELETE_ABSPATH will be A
2708 */
2709svn_error_t *
2710svn_wc__db_scan_moved(const char **moved_from_abspath,
2711                      const char **op_root_abspath,
2712                      const char **op_root_moved_from_abspath,
2713                      const char **moved_from_delete_abspath,
2714                      svn_wc__db_t *db,
2715                      const char *local_abspath,
2716                      apr_pool_t *result_pool,
2717                      apr_pool_t *scratch_pool);
2718
2719/* Scan upwards for additional information about a deleted node.
2720
2721   When a deleted node is discovered in the WORKING tree, the situation
2722   may be quite complex. This function will provide the information to
2723   resolve the circumstances of the deletion.
2724
2725   For discussion purposes, we will start with the most complex example
2726   and then demonstrate simplified examples. Consider node B/W/D/N has been
2727   found as deleted. B is an unmodified directory (thus, only in BASE). W is
2728   "replacement" content that exists in WORKING, shadowing a similar B/W
2729   directory in BASE. D is a deleted subtree in the WORKING tree, and N is
2730   the deleted node.
2731
2732   In this example, BASE_DEL_ABSPATH will bet set to B/W. That is the root of
2733   the BASE tree (implicitly) deleted by the replacement. WORK_DEL_ABSPATH
2734   will be set to the subtree deleted within the replacement; in this case,
2735   B/W/D. No move-away took place, so MOVED_TO_ABSPATH is set to NULL.
2736
2737   In another scenario, B/W was moved-away before W was put into the WORKING
2738   tree through an add/copy/move-here. MOVED_TO_ABSPATH will indicate where
2739   B/W was moved to. Note that further operations may have been performed
2740   post-move, but that is not known or reported by this function.
2741
2742   If BASE does not have a B/W, then the WORKING B/W is not a replacement,
2743   but a simple add/copy/move-here. BASE_DEL_ABSPATH will be set to NULL.
2744
2745   If B/W/D does not exist in the WORKING tree (we're only talking about a
2746   deletion of nodes of the BASE tree), then deleting B/W/D would have marked
2747   the subtree for deletion. BASE_DEL_ABSPATH will refer to B/W/D,
2748   MOVED_TO_ABSPATH will be NULL, and WORK_DEL_ABSPATH will be NULL.
2749
2750   If the BASE node B/W/D was moved instead of deleted, then MOVED_TO_ABSPATH
2751   would indicate the target location (and other OUT values as above).
2752
2753   When the user deletes B/W/D from the WORKING tree, there are a few
2754   additional considerations. If B/W is a simple addition (not a copy or
2755   a move-here), then the deletion will simply remove the nodes from WORKING
2756   and possibly leave behind "base-delete" markers in the WORKING tree.
2757   If the source is a copy/moved-here, then the nodes are replaced with
2758   deletion markers.
2759
2760   If the user moves-away B/W/D from the WORKING tree, then behavior is
2761   again dependent upon the origination of B/W. For a plain add, the nodes
2762   simply move to the destination; this means that B/W/D ceases to be a
2763   node and so cannot be scanned. For a copy, a deletion is made at B/W/D,
2764   and a new copy (of a subtree of the original source) is made at the
2765   destination. For a move-here, a deletion is made, and a copy is made at
2766   the destination (we do not track multiple moves; the source is moved to
2767   B/W, then B/W/D is deleted; then a copy is made at the destination;
2768   however, note the double-move could have been performed by moving the
2769   subtree first, then moving the source to B/W).
2770
2771   There are three further considerations when resolving a deleted node:
2772
2773     If the BASE B/W/D was deleted explicitly *and* B/W is a replacement,
2774     then the explicit deletion is subsumed by the implicit deletion that
2775     occurred with the B/W replacement. Thus, BASE_DEL_ABSPATH will point
2776     to B/W as the root of the BASE deletion. IOW, we can detect the
2777     explicit move-away, but not an explicit deletion.
2778
2779     If B/W/D/N refers to a node present in the BASE tree, and B/W was
2780     replaced by a shallow subtree, then it is possible for N to be
2781     reported as deleted (from BASE) yet no deletions occurred in the
2782     WORKING tree above N. Thus, WORK_DEL_ABSPATH will be set to NULL.
2783
2784
2785   Summary of OUT parameters:
2786
2787   BASE_DEL_ABSPATH will specify the nearest ancestor of the explicit or
2788   implicit deletion (if any) that applies to the BASE tree.
2789
2790   WORK_DEL_ABSPATH will specify the root of a deleted subtree within
2791   the WORKING tree (note there is no concept of layered delete operations
2792   in WORKING, so there is only one deletion root in the ancestry).
2793
2794   MOVED_TO_ABSPATH will specify the path where this node was moved to
2795   if the node has moved-away.
2796
2797   If the node was moved-away, MOVED_TO_OP_ROOT_ABSPATH will specify the
2798   target path of the root of the move operation.  If LOCAL_ABSPATH itself
2799   is the source path of the root of the move operation, then
2800   MOVED_TO_OP_ROOT_ABSPATH equals MOVED_TO_ABSPATH.
2801
2802   All OUT parameters may be set to NULL to indicate a lack of interest in
2803   that piece of information.
2804
2805   If the node given by LOCAL_ABSPATH does not exist, then
2806   SVN_ERR_WC_PATH_NOT_FOUND is returned. If it doesn't have a "deleted"
2807   status, then SVN_ERR_WC_PATH_UNEXPECTED_STATUS will be returned.
2808
2809   All returned data will be allocated in RESULT_POOL. All temporary
2810   allocations will be made in SCRATCH_POOL.
2811*/
2812svn_error_t *
2813svn_wc__db_scan_deletion(const char **base_del_abspath,
2814                         const char **moved_to_abspath,
2815                         const char **work_del_abspath,
2816                         const char **moved_to_op_root_abspath,
2817                         svn_wc__db_t *db,
2818                         const char *local_abspath,
2819                         apr_pool_t *result_pool,
2820                         apr_pool_t *scratch_pool);
2821
2822
2823/* @} */
2824
2825
2826/* @defgroup svn_wc__db_upgrade  Functions for upgrading a working copy.
2827   @{
2828*/
2829
2830/* Create a new wc.db file for LOCAL_DIR_ABSPATH, which is going to be a
2831   working copy for the repository REPOS_ROOT_URL with uuid REPOS_UUID.
2832   Return the raw sqlite handle, repository id and working copy id
2833   and store the database in WC_DB.
2834
2835   Perform temporary allocations in SCRATCH_POOL. */
2836svn_error_t *
2837svn_wc__db_upgrade_begin(svn_sqlite__db_t **sdb,
2838                         apr_int64_t *repos_id,
2839                         apr_int64_t *wc_id,
2840                         svn_wc__db_t *wc_db,
2841                         const char *local_dir_abspath,
2842                         const char *repos_root_url,
2843                         const char *repos_uuid,
2844                         apr_pool_t *scratch_pool);
2845
2846
2847svn_error_t *
2848svn_wc__db_upgrade_apply_dav_cache(svn_sqlite__db_t *sdb,
2849                                   const char *dir_relpath,
2850                                   apr_hash_t *cache_values,
2851                                   apr_pool_t *scratch_pool);
2852
2853
2854/* ### need much more docco
2855
2856   ### this function should be called within a sqlite transaction. it makes
2857   ### assumptions around this fact.
2858
2859   Apply the various sets of properties to the database nodes based on
2860   their existence/presence, the current state of the node, and the original
2861   format of the working copy which provided these property sets.
2862*/
2863svn_error_t *
2864svn_wc__db_upgrade_apply_props(svn_sqlite__db_t *sdb,
2865                               const char *dir_abspath,
2866                               const char *local_relpath,
2867                               apr_hash_t *base_props,
2868                               apr_hash_t *revert_props,
2869                               apr_hash_t *working_props,
2870                               int original_format,
2871                               apr_int64_t wc_id,
2872                               apr_pool_t *scratch_pool);
2873
2874/* Simply insert (or replace) one row in the EXTERNALS table. */
2875svn_error_t *
2876svn_wc__db_upgrade_insert_external(svn_wc__db_t *db,
2877                                   const char *local_abspath,
2878                                   svn_node_kind_t kind,
2879                                   const char *parent_abspath,
2880                                   const char *def_local_abspath,
2881                                   const char *repos_relpath,
2882                                   const char *repos_root_url,
2883                                   const char *repos_uuid,
2884                                   svn_revnum_t def_peg_revision,
2885                                   svn_revnum_t def_revision,
2886                                   apr_pool_t *scratch_pool);
2887
2888/* Get the repository identifier corresponding to REPOS_ROOT_URL from the
2889   database in SDB. The value is returned in *REPOS_ID. All allocations
2890   are allocated in SCRATCH_POOL.
2891
2892   NOTE: the row in REPOSITORY must exist. If not, then SVN_ERR_WC_DB_ERROR
2893   is returned.
2894
2895   ### unclear on whether/how this interface will stay/evolve.  */
2896svn_error_t *
2897svn_wc__db_upgrade_get_repos_id(apr_int64_t *repos_id,
2898                                svn_sqlite__db_t *sdb,
2899                                const char *repos_root_url,
2900                                apr_pool_t *scratch_pool);
2901
2902/* Upgrade the metadata concerning the WC at WCROOT_ABSPATH, in DB,
2903 * to the SVN_WC__VERSION format.
2904 *
2905 * This function is used for upgrading wc-ng working copies to a newer
2906 * wc-ng format. If a pre-1.7 working copy is found, this function
2907 * returns SVN_ERR_WC_UPGRADE_REQUIRED.
2908 *
2909 * Upgrading subdirectories of a working copy is not supported.
2910 * If WCROOT_ABSPATH is not a working copy root SVN_ERR_WC_INVALID_OP_ON_CWD
2911 * is returned.
2912 */
2913svn_error_t *
2914svn_wc__db_bump_format(int *result_format,
2915                       const char *wcroot_abspath,
2916                       svn_wc__db_t *db,
2917                       apr_pool_t *scratch_pool);
2918
2919/* @} */
2920
2921
2922/* @defgroup svn_wc__db_wq  Work queue manipulation. see workqueue.h
2923   @{
2924*/
2925
2926/* In the WCROOT associated with DB and WRI_ABSPATH, add WORK_ITEM to the
2927   wcroot's work queue. Use SCRATCH_POOL for all temporary allocations.  */
2928svn_error_t *
2929svn_wc__db_wq_add(svn_wc__db_t *db,
2930                  const char *wri_abspath,
2931                  const svn_skel_t *work_item,
2932                  apr_pool_t *scratch_pool);
2933
2934
2935/* In the WCROOT associated with DB and WRI_ABSPATH, fetch a work item that
2936   needs to be completed. Its identifier is returned in ID, and the data in
2937   WORK_ITEM.
2938
2939   Items are returned in the same order they were queued. This allows for
2940   (say) queueing work on a parent node to be handled before that of its
2941   children.
2942
2943   If there are no work items to be completed, then ID will be set to zero,
2944   and WORK_ITEM to NULL.
2945
2946   If COMPLETED_ID is not 0, the wq item COMPLETED_ID will be marked as
2947   completed before returning the next item.
2948
2949   RESULT_POOL will be used to allocate WORK_ITEM, and SCRATCH_POOL
2950   will be used for all temporary allocations.  */
2951svn_error_t *
2952svn_wc__db_wq_fetch_next(apr_uint64_t *id,
2953                         svn_skel_t **work_item,
2954                         svn_wc__db_t *db,
2955                         const char *wri_abspath,
2956                         apr_uint64_t completed_id,
2957                         apr_pool_t *result_pool,
2958                         apr_pool_t *scratch_pool);
2959
2960/* Special variant of svn_wc__db_wq_fetch_next(), which in the same transaction
2961   also records timestamps and sizes for one or more nodes */
2962svn_error_t *
2963svn_wc__db_wq_record_and_fetch_next(apr_uint64_t *id,
2964                                    svn_skel_t **work_item,
2965                                    svn_wc__db_t *db,
2966                                    const char *wri_abspath,
2967                                    apr_uint64_t completed_id,
2968                                    apr_hash_t *record_map,
2969                                    apr_pool_t *result_pool,
2970                                    apr_pool_t *scratch_pool);
2971
2972
2973/* @} */
2974
2975
2976/* Note: LEVELS_TO_LOCK is here strictly for backward compat.  The access
2977   batons still have the notion of 'levels to lock' and we need to ensure
2978   that they still function correctly, even in the new world.  'levels to
2979   lock' should not be exposed through the wc-ng APIs at all: users either
2980   get to lock the entire tree (rooted at some subdir, of course), or none.
2981
2982   An infinite depth lock is obtained with LEVELS_TO_LOCK set to -1, but until
2983   we move to a single DB only depth 0 is supported.
2984*/
2985svn_error_t *
2986svn_wc__db_wclock_obtain(svn_wc__db_t *db,
2987                         const char *local_abspath,
2988                         int levels_to_lock,
2989                         svn_boolean_t steal_lock,
2990                         apr_pool_t *scratch_pool);
2991
2992/* Set LOCK_ABSPATH to the path of the the directory that owns the
2993   lock on LOCAL_ABSPATH, or NULL, if LOCAL_ABSPATH is not locked. */
2994svn_error_t*
2995svn_wc__db_wclock_find_root(const char **lock_abspath,
2996                            svn_wc__db_t *db,
2997                            const char *local_abspath,
2998                            apr_pool_t *result_pool,
2999                            apr_pool_t *scratch_pool);
3000
3001/* Check if somebody has a wclock on LOCAL_ABSPATH */
3002svn_error_t *
3003svn_wc__db_wclocked(svn_boolean_t *locked,
3004                    svn_wc__db_t *db,
3005                    const char *local_abspath,
3006                    apr_pool_t *scratch_pool);
3007
3008/* Release the previously obtained lock on LOCAL_ABSPATH */
3009svn_error_t *
3010svn_wc__db_wclock_release(svn_wc__db_t *db,
3011                          const char *local_abspath,
3012                          apr_pool_t *scratch_pool);
3013
3014/* Checks whether DB currently owns a lock to operate on LOCAL_ABSPATH.
3015   If EXACT is TRUE only lock roots are checked. */
3016svn_error_t *
3017svn_wc__db_wclock_owns_lock(svn_boolean_t *own_lock,
3018                            svn_wc__db_t *db,
3019                            const char *local_abspath,
3020                            svn_boolean_t exact,
3021                            apr_pool_t *scratch_pool);
3022
3023
3024
3025/* @defgroup svn_wc__db_temp Various temporary functions during transition
3026
3027  ### These functions SHOULD be completely removed before 1.7
3028
3029  @{
3030*/
3031
3032/* Removes all references to LOCAL_ABSPATH from DB, while optionally leaving
3033   a not present node.
3034
3035   This operation always recursively removes all nodes at and below
3036   LOCAL_ABSPATH from NODES and ACTUAL.
3037
3038   If NOT_PRESENT_REVISION specifies a valid revision, leave a not_present
3039   BASE node at local_abspath of the specified status and kind.
3040   (Requires an existing BASE node before removing)
3041
3042   If DESTROY_WC is TRUE, this operation *installs* workqueue operations to
3043   update the local filesystem after the database operation. If DESTROY_CHANGES
3044   is FALSE, modified and unversioned files are left after running this
3045   operation (and the WQ). If DESTROY_CHANGES and DESTROY_WC are TRUE,
3046   LOCAL_ABSPATH and everything below it will be removed by the WQ.
3047
3048
3049   Note: Unlike many similar functions it is a valid scenario for this
3050   function to be called on a wcroot! In this case it will just leave the root
3051   record in BASE
3052 */
3053svn_error_t *
3054svn_wc__db_op_remove_node(svn_boolean_t *left_changes,
3055                          svn_wc__db_t *db,
3056                          const char *local_abspath,
3057                          svn_boolean_t destroy_wc,
3058                          svn_boolean_t destroy_changes,
3059                          svn_revnum_t not_present_revision,
3060                          svn_wc__db_status_t not_present_status,
3061                          svn_node_kind_t not_present_kind,
3062                          const svn_skel_t *conflict,
3063                          const svn_skel_t *work_items,
3064                          svn_cancel_func_t cancel_func,
3065                          void *cancel_baton,
3066                          apr_pool_t *scratch_pool);
3067
3068/* Sets the depth of LOCAL_ABSPATH in its working copy to DEPTH using DB.
3069
3070   Returns SVN_ERR_WC_PATH_NOT_FOUND if LOCAL_ABSPATH is not a BASE directory
3071 */
3072svn_error_t *
3073svn_wc__db_op_set_base_depth(svn_wc__db_t *db,
3074                             const char *local_abspath,
3075                             svn_depth_t depth,
3076                             apr_pool_t *scratch_pool);
3077
3078/* ### temp function. return the FORMAT for the directory LOCAL_ABSPATH.  */
3079svn_error_t *
3080svn_wc__db_temp_get_format(int *format,
3081                           svn_wc__db_t *db,
3082                           const char *local_dir_abspath,
3083                           apr_pool_t *scratch_pool);
3084
3085/* ### temp functions to manage/store access batons within the DB.  */
3086svn_wc_adm_access_t *
3087svn_wc__db_temp_get_access(svn_wc__db_t *db,
3088                           const char *local_dir_abspath,
3089                           apr_pool_t *scratch_pool);
3090void
3091svn_wc__db_temp_set_access(svn_wc__db_t *db,
3092                           const char *local_dir_abspath,
3093                           svn_wc_adm_access_t *adm_access,
3094                           apr_pool_t *scratch_pool);
3095svn_error_t *
3096svn_wc__db_temp_close_access(svn_wc__db_t *db,
3097                             const char *local_dir_abspath,
3098                             svn_wc_adm_access_t *adm_access,
3099                             apr_pool_t *scratch_pool);
3100void
3101svn_wc__db_temp_clear_access(svn_wc__db_t *db,
3102                             const char *local_dir_abspath,
3103                             apr_pool_t *scratch_pool);
3104
3105/* ### shallow hash: abspath -> svn_wc_adm_access_t *  */
3106apr_hash_t *
3107svn_wc__db_temp_get_all_access(svn_wc__db_t *db,
3108                               apr_pool_t *result_pool);
3109
3110/* ### temp function to open the sqlite database to the appropriate location,
3111   ### then borrow it for a bit.
3112   ### The *only* reason for this function is because entries.c still
3113   ### manually hacks the sqlite database.
3114
3115   ### No matter how tempted you may be DO NOT USE THIS FUNCTION!
3116   ### (if you do, gstein will hunt you down and burn your knee caps off
3117   ### in the middle of the night)
3118   ### "Bet on it." --gstein
3119*/
3120svn_error_t *
3121svn_wc__db_temp_borrow_sdb(svn_sqlite__db_t **sdb,
3122                           svn_wc__db_t *db,
3123                           const char *local_dir_abspath,
3124                           apr_pool_t *scratch_pool);
3125
3126
3127/* Return a directory in *TEMP_DIR_ABSPATH that is suitable for temporary
3128   files which may need to be moved (atomically and same-device) into the
3129   working copy indicated by WRI_ABSPATH.  */
3130svn_error_t *
3131svn_wc__db_temp_wcroot_tempdir(const char **temp_dir_abspath,
3132                               svn_wc__db_t *db,
3133                               const char *wri_abspath,
3134                               apr_pool_t *result_pool,
3135                               apr_pool_t *scratch_pool);
3136
3137/* Update the BASE_NODE of directory LOCAL_ABSPATH to be NEW_REPOS_RELPATH
3138   at revision NEW_REV with status incomplete. */
3139svn_error_t *
3140svn_wc__db_temp_op_start_directory_update(svn_wc__db_t *db,
3141                                          const char *local_abspath,
3142                                          const char *new_repos_relpath,
3143                                          svn_revnum_t new_rev,
3144                                          apr_pool_t *scratch_pool);
3145
3146/* Marks a directory update started with
3147   svn_wc__db_temp_op_start_directory_update as completed, by removing
3148   the incomplete status */
3149svn_error_t *
3150svn_wc__db_temp_op_end_directory_update(svn_wc__db_t *db,
3151                                        const char *local_dir_abspath,
3152                                        apr_pool_t *scratch_pool);
3153
3154
3155/* Copy the base tree at LOCAL_ABSPATH into the working tree as copy,
3156   leaving any subtree additions and copies as-is.  This allows the
3157   base node tree to be removed. */
3158svn_error_t *
3159svn_wc__db_op_make_copy(svn_wc__db_t *db,
3160                        const char *local_abspath,
3161                        const svn_skel_t *conflicts,
3162                        const svn_skel_t *work_items,
3163                        apr_pool_t *scratch_pool);
3164
3165/* Close the wc root LOCAL_ABSPATH and remove any per-directory
3166   handles associated with it. */
3167svn_error_t *
3168svn_wc__db_drop_root(svn_wc__db_t *db,
3169                     const char *local_abspath,
3170                     apr_pool_t *scratch_pool);
3171
3172/* Return the OP_DEPTH for LOCAL_RELPATH. */
3173int
3174svn_wc__db_op_depth_for_upgrade(const char *local_relpath);
3175
3176/* Set *HAVE_WORK TRUE if there is a working layer below the top layer and
3177   *HAVE_BASE if there is a base layer. Set *STATUS to the status of the
3178   highest layer below WORKING */
3179svn_error_t *
3180svn_wc__db_info_below_working(svn_boolean_t *have_base,
3181                              svn_boolean_t *have_work,
3182                              svn_wc__db_status_t *status,
3183                              svn_wc__db_t *db,
3184                              const char *local_abspath,
3185                              apr_pool_t *scratch_pool);
3186
3187
3188/* Gets an array of const char *local_relpaths of descendants of LOCAL_ABSPATH,
3189 * which itself must be the op root of an addition, copy or move.
3190 * The descendants returned are at the same op_depth, but are to be deleted
3191 * by the commit processing because they are not present in the local copy.
3192 */
3193svn_error_t *
3194svn_wc__db_get_not_present_descendants(const apr_array_header_t **descendants,
3195                                       svn_wc__db_t *db,
3196                                       const char *local_abspath,
3197                                       apr_pool_t *result_pool,
3198                                       apr_pool_t *scratch_pool);
3199
3200/* Gather revision status information about a working copy using DB.
3201 *
3202 * Set *MIN_REVISION and *MAX_REVISION to the lowest and highest revision
3203 * numbers found within LOCAL_ABSPATH.
3204 * Only nodes with op_depth zero and presence 'normal' or 'incomplete'
3205 * are considered, so that added, deleted or excluded nodes do not affect
3206 * the result.  If COMMITTED is TRUE, set *MIN_REVISION and *MAX_REVISION
3207 * to the lowest and highest committed (i.e. "last changed") revision numbers,
3208 * respectively.
3209 *
3210 * Indicate in *IS_SPARSE_CHECKOUT whether any of the nodes within
3211 * LOCAL_ABSPATH is sparse.
3212 * Indicate in *IS_MODIFIED whether the working copy has local modifications.
3213 *
3214 * Indicate in *IS_SWITCHED whether any node beneath LOCAL_ABSPATH
3215 * is switched. If TRAIL_URL is non-NULL, use it to determine if LOCAL_ABSPATH
3216 * itself is switched.  It should be any trailing portion of LOCAL_ABSPATH's
3217 * expected URL, long enough to include any parts that the caller considers
3218 * might be changed by a switch.  If it does not match the end of WC_PATH's
3219 * actual URL, then report a "switched" status.
3220 *
3221 * See also the functions below which provide a subset of this functionality.
3222 */
3223svn_error_t *
3224svn_wc__db_revision_status(svn_revnum_t *min_revision,
3225                           svn_revnum_t *max_revision,
3226                           svn_boolean_t *is_sparse_checkout,
3227                           svn_boolean_t *is_modified,
3228                           svn_boolean_t *is_switched,
3229                           svn_wc__db_t *db,
3230                           const char *local_abspath,
3231                           const char *trail_url,
3232                           svn_boolean_t committed,
3233                           svn_cancel_func_t cancel_func,
3234                           void *cancel_baton,
3235                           apr_pool_t *scratch_pool);
3236
3237/* Set *MIN_REVISION and *MAX_REVISION to the lowest and highest revision
3238 * numbers found within LOCAL_ABSPATH in the working copy using DB.
3239 * Only nodes with op_depth zero and presence 'normal' or 'incomplete'
3240 * are considered, so that added, deleted or excluded nodes do not affect
3241 * the result.  If COMMITTED is TRUE, set *MIN_REVISION and *MAX_REVISION
3242 * to the lowest and highest committed (i.e. "last changed") revision numbers,
3243 * respectively. Use SCRATCH_POOL for temporary allocations.
3244 *
3245 * Either of MIN_REVISION and MAX_REVISION may be passed as NULL if
3246 * the caller doesn't care about that return value.
3247 *
3248 * This function provides a subset of the functionality of
3249 * svn_wc__db_revision_status() and is more efficient if the caller
3250 * doesn't need all information returned by svn_wc__db_revision_status(). */
3251svn_error_t *
3252svn_wc__db_min_max_revisions(svn_revnum_t *min_revision,
3253                             svn_revnum_t *max_revision,
3254                             svn_wc__db_t *db,
3255                             const char *local_abspath,
3256                             svn_boolean_t committed,
3257                             apr_pool_t *scratch_pool);
3258
3259/* Indicate in *IS_SWITCHED whether any node beneath LOCAL_ABSPATH
3260 * is switched, using DB. Use SCRATCH_POOL for temporary allocations.
3261 *
3262 * If TRAIL_URL is non-NULL, use it to determine if LOCAL_ABSPATH itself
3263 * is switched.  It should be any trailing portion of LOCAL_ABSPATH's
3264 * expected URL, long enough to include any parts that the caller considers
3265 * might be changed by a switch.  If it does not match the end of WC_PATH's
3266 * actual URL, then report a "switched" status.
3267 *
3268 * This function provides a subset of the functionality of
3269 * svn_wc__db_revision_status() and is more efficient if the caller
3270 * doesn't need all information returned by svn_wc__db_revision_status(). */
3271svn_error_t *
3272svn_wc__db_has_switched_subtrees(svn_boolean_t *is_switched,
3273                                 svn_wc__db_t *db,
3274                                 const char *local_abspath,
3275                                 const char *trail_url,
3276                                 apr_pool_t *scratch_pool);
3277
3278/* Set @a *excluded_subtrees to a hash mapping <tt>const char *</tt>
3279 * local absolute paths to <tt>const char *</tt> local absolute paths for
3280 * every path under @a local_abspath in @a db which are excluded by
3281 * the server (e.g. due to authz), or user.  If no such paths are found then
3282 * @a *server_excluded_subtrees is set to @c NULL.
3283 * Allocate the hash and all items therein from @a result_pool.
3284 */
3285svn_error_t *
3286svn_wc__db_get_excluded_subtrees(apr_hash_t **server_excluded_subtrees,
3287                                 svn_wc__db_t *db,
3288                                 const char *local_abspath,
3289                                 apr_pool_t *result_pool,
3290                                 apr_pool_t *scratch_pool);
3291
3292/* Indicate in *IS_MODIFIED whether the working copy has local modifications,
3293 * using DB. Use SCRATCH_POOL for temporary allocations.
3294 *
3295 * This function provides a subset of the functionality of
3296 * svn_wc__db_revision_status() and is more efficient if the caller
3297 * doesn't need all information returned by svn_wc__db_revision_status(). */
3298svn_error_t *
3299svn_wc__db_has_local_mods(svn_boolean_t *is_modified,
3300                          svn_wc__db_t *db,
3301                          const char *local_abspath,
3302                          svn_cancel_func_t cancel_func,
3303                          void *cancel_baton,
3304                          apr_pool_t *scratch_pool);
3305
3306
3307/* Verify the consistency of metadata concerning the WC that contains
3308 * WRI_ABSPATH, in DB.  Return an error if any problem is found. */
3309svn_error_t *
3310svn_wc__db_verify(svn_wc__db_t *db,
3311                  const char *wri_abspath,
3312                  apr_pool_t *scratch_pool);
3313
3314
3315/* Possibly need two structures, one with relpaths and with abspaths?
3316 * Only exposed for testing at present. */
3317struct svn_wc__db_moved_to_t {
3318  const char *local_relpath;  /* moved-to destination */
3319  int op_depth;       /* op-root of source */
3320};
3321
3322/* Set *FINAL_ABSPATH to an array of svn_wc__db_moved_to_t for
3323 * LOCAL_ABSPATH after following any and all nested moves.
3324 * Only exposed for testing at present. */
3325svn_error_t *
3326svn_wc__db_follow_moved_to(apr_array_header_t **moved_tos,
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/* Update a moved-away tree conflict victim at VICTIM_ABSPATH with changes
3333 * brought in by the update operation which flagged the tree conflict. */
3334svn_error_t *
3335svn_wc__db_update_moved_away_conflict_victim(svn_wc__db_t *db,
3336                                             const char *victim_abspath,
3337                                             svn_wc_notify_func2_t notify_func,
3338                                             void *notify_baton,
3339                                             svn_cancel_func_t cancel_func,
3340                                             void *cancel_baton,
3341                                             apr_pool_t *scratch_pool);
3342
3343/* LOCAL_ABSPATH is moved to MOVE_DST_ABSPATH.  MOVE_SRC_ROOT_ABSPATH
3344 * is the root of the move to MOVE_DST_OP_ROOT_ABSPATH.
3345 * MOVE_SRC_OP_ROOT_ABSPATH is the op-root of the move; it's the same
3346 * as MOVE_SRC_ROOT_ABSPATH except for moves inside deletes when it is
3347 * the op-root of the delete. */
3348svn_error_t *
3349svn_wc__db_base_moved_to(const char **move_dst_abspath,
3350                         const char **move_dst_op_root_abspath,
3351                         const char **move_src_root_abspath,
3352                         const char **move_src_op_root_abspath,
3353                         svn_wc__db_t *db,
3354                         const char *local_abspath,
3355                         apr_pool_t *result_pool,
3356                         apr_pool_t *scratch_pool);
3357
3358/* Recover space from the database file for LOCAL_ABSPATH by running
3359 * the "vacuum" command. */
3360svn_error_t *
3361svn_wc__db_vacuum(svn_wc__db_t *db,
3362                  const char *local_abspath,
3363                  apr_pool_t *scratch_pool);
3364
3365/* This raises move-edit tree-conflicts on any moves inside the
3366   delete-edit conflict on LOCAL_ABSPATH. This is experimental: see
3367   comment in resolve_conflict_on_node about combining with another
3368   function. */
3369svn_error_t *
3370svn_wc__db_resolve_delete_raise_moved_away(svn_wc__db_t *db,
3371                                           const char *local_abspath,
3372                                           svn_wc_notify_func2_t notify_func,
3373                                           void *notify_baton,
3374                                           apr_pool_t *scratch_pool);
3375
3376/* Like svn_wc__db_resolve_delete_raise_moved_away this should be
3377   combined. */
3378svn_error_t *
3379svn_wc__db_resolve_break_moved_away(svn_wc__db_t *db,
3380                                    const char *local_abspath,
3381                                    svn_wc_notify_func2_t notify_func,
3382                                    void *notify_baton,
3383                                    apr_pool_t *scratch_pool);
3384
3385/* Break moves for all moved-away children of LOCAL_ABSPATH, within
3386 * a single transaction.
3387 *
3388 * ### Like svn_wc__db_resolve_delete_raise_moved_away this should be
3389 * combined. */
3390svn_error_t *
3391svn_wc__db_resolve_break_moved_away_children(svn_wc__db_t *db,
3392                                             const char *local_abspath,
3393                                             svn_wc_notify_func2_t notify_func,
3394                                             void *notify_baton,
3395                                             apr_pool_t *scratch_pool);
3396
3397/* Set *REQUIRED_ABSPATH to the path that should be locked to ensure
3398 * that the lock covers all paths affected by resolving the conflicts
3399 * in the tree LOCAL_ABSPATH. */
3400svn_error_t *
3401svn_wc__required_lock_for_resolve(const char **required_abspath,
3402                                  svn_wc__db_t *db,
3403                                  const char *local_abspath,
3404                                  apr_pool_t *result_pool,
3405                                  apr_pool_t *scratch_pool);
3406/* @} */
3407
3408
3409#ifdef __cplusplus
3410}
3411#endif /* __cplusplus */
3412
3413#endif /* SVN_WC_DB_H */
3414