1251881Speter/* dag.h : DAG-like interface filesystem, private to libsvn_fs
2251881Speter *
3251881Speter * ====================================================================
4251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
5251881Speter *    or more contributor license agreements.  See the NOTICE file
6251881Speter *    distributed with this work for additional information
7251881Speter *    regarding copyright ownership.  The ASF licenses this file
8251881Speter *    to you under the Apache License, Version 2.0 (the
9251881Speter *    "License"); you may not use this file except in compliance
10251881Speter *    with the License.  You may obtain a copy of the License at
11251881Speter *
12251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
13251881Speter *
14251881Speter *    Unless required by applicable law or agreed to in writing,
15251881Speter *    software distributed under the License is distributed on an
16251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17251881Speter *    KIND, either express or implied.  See the License for the
18251881Speter *    specific language governing permissions and limitations
19251881Speter *    under the License.
20251881Speter * ====================================================================
21251881Speter */
22251881Speter
23251881Speter#ifndef SVN_LIBSVN_FS_DAG_H
24251881Speter#define SVN_LIBSVN_FS_DAG_H
25251881Speter
26251881Speter#include "svn_fs.h"
27251881Speter
28251881Speter#include "trail.h"
29251881Speter
30251881Speter#ifdef __cplusplus
31251881Speterextern "C" {
32251881Speter#endif /* __cplusplus */
33251881Speter
34251881Speter
35251881Speter/* The interface in this file provides all the essential filesystem
36251881Speter   operations, but exposes the filesystem's DAG structure.  This makes
37251881Speter   it simpler to implement than the public interface, since a client
38251881Speter   of this interface has to understand and cope with shared structure
39251881Speter   directly as it appears in the database.  However, it's still a
40251881Speter   self-consistent set of invariants to maintain, making it
41251881Speter   (hopefully) a useful interface boundary.
42251881Speter
43251881Speter   In other words:
44251881Speter
45251881Speter   - The dag_node_t interface exposes the internal DAG structure of
46251881Speter     the filesystem, while the svn_fs.h interface does any cloning
47251881Speter     necessary to make the filesystem look like a tree.
48251881Speter
49251881Speter   - The dag_node_t interface exposes the existence of copy nodes,
50251881Speter     whereas the svn_fs.h handles them transparently.
51251881Speter
52251881Speter   - dag_node_t's must be explicitly cloned, whereas the svn_fs.h
53251881Speter     operations make clones implicitly.
54251881Speter
55251881Speter   - Callers of the dag_node_t interface use Berkeley DB transactions
56251881Speter     to ensure consistency between operations, while callers of the
57251881Speter     svn_fs.h interface use Subversion transactions.  */
58251881Speter
59251881Speter
60251881Speter/* Initializing a filesystem.  */
61251881Speter
62251881Speter
63251881Speter/* Given a filesystem FS, which contains all the necessary tables,
64251881Speter   create the initial revision 0, and the initial root directory.  */
65251881Spetersvn_error_t *svn_fs_base__dag_init_fs(svn_fs_t *fs);
66251881Speter
67251881Speter
68251881Speter
69251881Speter/* Generic DAG node stuff.  */
70251881Speter
71251881Spetertypedef struct dag_node_t dag_node_t;
72251881Speter
73251881Speter
74251881Speter/* Fill *NODE with a dag_node_t representing node revision ID in FS,
75251881Speter   allocating in POOL.  */
76251881Spetersvn_error_t *svn_fs_base__dag_get_node(dag_node_t **node,
77251881Speter                                       svn_fs_t *fs,
78251881Speter                                       const svn_fs_id_t *id,
79251881Speter                                       trail_t *trail,
80251881Speter                                       apr_pool_t *pool);
81251881Speter
82251881Speter
83251881Speter/* Return a new dag_node_t object referring to the same node as NODE,
84251881Speter   allocated in POOL.  */
85251881Speterdag_node_t *svn_fs_base__dag_dup(dag_node_t *node,
86251881Speter                                 apr_pool_t *pool);
87251881Speter
88251881Speter
89251881Speter/* Return the filesystem containing NODE.  */
90251881Spetersvn_fs_t *svn_fs_base__dag_get_fs(dag_node_t *node);
91251881Speter
92251881Speter
93251881Speter/* Set *REV to NODE's revision number, as part of TRAIL.  If NODE has
94251881Speter   never been committed as part of a revision, set *REV to
95251881Speter   SVN_INVALID_REVNUM.  */
96251881Spetersvn_error_t *svn_fs_base__dag_get_revision(svn_revnum_t *rev,
97251881Speter                                           dag_node_t *node,
98251881Speter                                           trail_t *trail,
99251881Speter                                           apr_pool_t *pool);
100251881Speter
101251881Speter
102251881Speter/* Return the node revision ID of NODE.  The value returned is shared
103251881Speter   with NODE, and will be deallocated when NODE is.  */
104251881Speterconst svn_fs_id_t *svn_fs_base__dag_get_id(dag_node_t *node);
105251881Speter
106251881Speter
107251881Speter/* Return the created path of NODE.  The value returned is shared
108251881Speter   with NODE, and will be deallocated when NODE is.  */
109251881Speterconst char *svn_fs_base__dag_get_created_path(dag_node_t *node);
110251881Speter
111251881Speter
112251881Speter/* Set *ID_P to the node revision ID of NODE's immediate predecessor,
113251881Speter   or NULL if NODE has no predecessor, as part of TRAIL.  The returned
114251881Speter   ID will be allocated in POOL.  */
115251881Spetersvn_error_t *svn_fs_base__dag_get_predecessor_id(const svn_fs_id_t **id_p,
116251881Speter                                                 dag_node_t *node,
117251881Speter                                                 trail_t *trail,
118251881Speter                                                 apr_pool_t *pool);
119251881Speter
120251881Speter
121251881Speter/* Set *COUNT to the number of predecessors NODE has (recursively), or
122251881Speter   -1 if not known, as part of TRAIL.  */
123251881Spetersvn_error_t *svn_fs_base__dag_get_predecessor_count(int *count,
124251881Speter                                                    dag_node_t *node,
125251881Speter                                                    trail_t *trail,
126251881Speter                                                    apr_pool_t *pool);
127251881Speter
128251881Speter
129251881Speter/* Return non-zero IFF NODE is currently mutable under Subversion
130251881Speter   transaction TXN_ID.  */
131251881Spetersvn_boolean_t svn_fs_base__dag_check_mutable(dag_node_t *node,
132251881Speter                                             const char *txn_id);
133251881Speter
134251881Speter/* Return the node kind of NODE. */
135251881Spetersvn_node_kind_t svn_fs_base__dag_node_kind(dag_node_t *node);
136251881Speter
137251881Speter/* Set *PROPLIST_P to a PROPLIST hash representing the entire property
138251881Speter   list of NODE, as part of TRAIL.  The hash has const char * names
139251881Speter   (the property names) and svn_string_t * values (the property values).
140251881Speter
141251881Speter   If properties do not exist on NODE, *PROPLIST_P will be set to NULL.
142251881Speter
143251881Speter   The returned property list is allocated in POOL.  */
144251881Spetersvn_error_t *svn_fs_base__dag_get_proplist(apr_hash_t **proplist_p,
145251881Speter                                           dag_node_t *node,
146251881Speter                                           trail_t *trail,
147251881Speter                                           apr_pool_t *pool);
148251881Speter
149251881Speter/* Set the property list of NODE to PROPLIST, as part of TRAIL.  The
150251881Speter   node being changed must be mutable.  TXN_ID is the Subversion
151251881Speter   transaction under which this occurs.  */
152251881Spetersvn_error_t *svn_fs_base__dag_set_proplist(dag_node_t *node,
153251881Speter                                           const apr_hash_t *proplist,
154251881Speter                                           const char *txn_id,
155251881Speter                                           trail_t *trail,
156251881Speter                                           apr_pool_t *pool);
157251881Speter
158251881Speter
159251881Speter
160251881Speter/* Mergeinfo tracking stuff. */
161251881Speter
162251881Speter/* If HAS_MERGEINFO is not null, set *HAS_MERGEINFO to TRUE iff NODE
163251881Speter   records that its property list contains merge tracking information.
164251881Speter
165251881Speter   If COUNT is not null, set *COUNT to the number of nodes --
166251881Speter   including NODE itself -- in the subtree rooted at NODE which claim
167251881Speter   to carry merge tracking information.
168251881Speter
169251881Speter   Do this as part of TRAIL, and use POOL for necessary allocations.
170251881Speter
171251881Speter   NOTE:  No validation against NODE's actual property list is
172251881Speter   performed. */
173251881Spetersvn_error_t *svn_fs_base__dag_get_mergeinfo_stats(svn_boolean_t *has_mergeinfo,
174251881Speter                                                  apr_int64_t *count,
175251881Speter                                                  dag_node_t *node,
176251881Speter                                                  trail_t *trail,
177251881Speter                                                  apr_pool_t *pool);
178251881Speter
179251881Speter/* If HAS_MERGEINFO is set, record on NODE that its property list
180251881Speter   carries merge tracking information.  Otherwise, record on NODE its
181251881Speter   property list does *not* carry merge tracking information.  NODE
182251881Speter   must be mutable under TXN_ID (the Subversion transaction under
183251881Speter   which this operation occurs).  Set *HAD_MERGEINFO to the previous
184251881Speter   state of this record.
185251881Speter
186251881Speter   Update the mergeinfo count on NODE as necessary.
187251881Speter
188251881Speter   Do all of this as part of TRAIL, and use POOL for necessary
189251881Speter   allocations.
190251881Speter
191251881Speter   NOTE:  No validation against NODE's actual property list is
192251881Speter   performed. */
193251881Spetersvn_error_t *svn_fs_base__dag_set_has_mergeinfo(dag_node_t *node,
194251881Speter                                                svn_boolean_t has_mergeinfo,
195251881Speter                                                svn_boolean_t *had_mergeinfo,
196251881Speter                                                const char *txn_id,
197251881Speter                                                trail_t *trail,
198251881Speter                                                apr_pool_t *pool);
199251881Speter
200251881Speter/* Record on NODE a change of COUNT_DELTA nodes -- including NODE
201251881Speter   itself -- in the subtree rooted at NODE claim to carry merge
202251881Speter   tracking information.  That is, add COUNT_DELTA to NODE's current
203251881Speter   mergeinfo count (regardless of whether COUNT_DELTA is a positive or
204251881Speter   negative integer).
205251881Speter
206251881Speter   NODE must be mutable under TXN_ID (the Subversion transaction under
207251881Speter   which this operation occurs).  Do this as part of TRAIL, and use
208251881Speter   POOL for necessary allocations.
209251881Speter
210251881Speter   NOTE:  No validation of these claims is performed. */
211251881Spetersvn_error_t *svn_fs_base__dag_adjust_mergeinfo_count(dag_node_t *node,
212251881Speter                                                     apr_int64_t count_delta,
213251881Speter                                                     const char *txn_id,
214251881Speter                                                     trail_t *trail,
215251881Speter                                                     apr_pool_t *pool);
216251881Speter
217251881Speter
218251881Speter/* Revision and transaction roots.  */
219251881Speter
220251881Speter
221251881Speter/* Open the root of revision REV of filesystem FS, as part of TRAIL.
222251881Speter   Set *NODE_P to the new node.  Allocate the node in POOL.  */
223251881Spetersvn_error_t *svn_fs_base__dag_revision_root(dag_node_t **node_p,
224251881Speter                                            svn_fs_t *fs,
225251881Speter                                            svn_revnum_t rev,
226251881Speter                                            trail_t *trail,
227251881Speter                                            apr_pool_t *pool);
228251881Speter
229251881Speter
230251881Speter/* Set *NODE_P to the root of transaction TXN_ID in FS, as part
231251881Speter   of TRAIL.  Allocate the node in POOL.
232251881Speter
233251881Speter   Note that the root node of TXN_ID is not necessarily mutable.  If no
234251881Speter   changes have been made in the transaction, then it may share its
235251881Speter   root directory with its base revision.  To get a mutable root node
236251881Speter   for a transaction, call svn_fs_base__dag_clone_root.  */
237251881Spetersvn_error_t *svn_fs_base__dag_txn_root(dag_node_t **node_p,
238251881Speter                                       svn_fs_t *fs,
239251881Speter                                       const char *txn_id,
240251881Speter                                       trail_t *trail,
241251881Speter                                       apr_pool_t *pool);
242251881Speter
243251881Speter
244251881Speter/* Set *NODE_P to the base root of transaction TXN_ID in FS, as part
245251881Speter   of TRAIL.  Allocate the node in POOL.  */
246251881Spetersvn_error_t *svn_fs_base__dag_txn_base_root(dag_node_t **node_p,
247251881Speter                                            svn_fs_t *fs,
248251881Speter                                            const char *txn_id,
249251881Speter                                            trail_t *trail,
250251881Speter                                            apr_pool_t *pool);
251251881Speter
252251881Speter
253251881Speter/* Clone the root directory of TXN_ID in FS, and update the
254251881Speter   `transactions' table entry to point to it, unless this has been
255251881Speter   done already.  In either case, set *ROOT_P to a reference to the
256251881Speter   root directory clone.  Do all this as part of TRAIL, and allocate
257251881Speter   *ROOT_P in POOL.  */
258251881Spetersvn_error_t *svn_fs_base__dag_clone_root(dag_node_t **root_p,
259251881Speter                                         svn_fs_t *fs,
260251881Speter                                         const char *txn_id,
261251881Speter                                         trail_t *trail,
262251881Speter                                         apr_pool_t *pool);
263251881Speter
264251881Speter
265251881Speter/* Commit the transaction TXN->id in TXN->FS, as part of TRAIL.  Store the
266251881Speter   new revision number in *NEW_REV.  This entails:
267251881Speter   - marking the tree of mutable nodes at TXN->id's root as immutable,
268251881Speter     and marking all their contents as stable
269251881Speter   - creating a new revision, with TXN->id's root as its root directory
270251881Speter   - promoting TXN->id to a "committed" transaction.
271251881Speter
272251881Speter   Beware!  This does not make sure that TXN->id is based on the very
273251881Speter   latest revision in TXN->FS.  If the caller doesn't take care of this,
274251881Speter   you may lose people's work!
275251881Speter
276251881Speter   Do any necessary temporary allocation in a subpool of POOL.
277251881Speter   Consume temporary space at most proportional to the maximum depth
278251881Speter   of SVN_TXN's tree of mutable nodes.  */
279251881Spetersvn_error_t *svn_fs_base__dag_commit_txn(svn_revnum_t *new_rev,
280251881Speter                                         svn_fs_txn_t *txn,
281251881Speter                                         trail_t *trail,
282251881Speter                                         apr_pool_t *pool);
283251881Speter
284251881Speter
285251881Speter/* Directories.  */
286251881Speter
287251881Speter
288251881Speter/* Open the node named NAME in the directory PARENT, as part of TRAIL.
289251881Speter   Set *CHILD_P to the new node, allocated in POOL.  NAME must be a
290251881Speter   single path component; it cannot be a slash-separated directory
291251881Speter   path.  */
292251881Spetersvn_error_t *svn_fs_base__dag_open(dag_node_t **child_p,
293251881Speter                                   dag_node_t *parent,
294251881Speter                                   const char *name,
295251881Speter                                   trail_t *trail,
296251881Speter                                   apr_pool_t *pool);
297251881Speter
298251881Speter
299251881Speter/* Set *ENTRIES_P to a hash table of NODE's entries, as part of TRAIL,
300251881Speter   or NULL if NODE has no entries.  The keys of the table are entry
301251881Speter   names, and the values are svn_fs_dirent_t's.
302251881Speter
303251881Speter   The returned table is allocated in POOL.
304251881Speter
305251881Speter   NOTE: the 'kind' field of the svn_fs_dirent_t's is set to
306251881Speter   svn_node_unknown by this function -- callers that need in
307251881Speter   interesting value in these slots should fill them in using a new
308251881Speter   TRAIL, since the list of entries can be arbitrarily large.  */
309251881Spetersvn_error_t *svn_fs_base__dag_dir_entries(apr_hash_t **entries_p,
310251881Speter                                          dag_node_t *node,
311251881Speter                                          trail_t *trail,
312251881Speter                                          apr_pool_t *pool);
313251881Speter
314251881Speter
315251881Speter/* Set ENTRY_NAME in NODE to point to ID, as part of TRAIL.  NODE must
316251881Speter   be a mutable directory.  ID can refer to a mutable or immutable
317251881Speter   node.  If ENTRY_NAME does not exist, it will be created.  TXN_ID is
318251881Speter   the Subversion transaction under which this occurs.*/
319251881Spetersvn_error_t *svn_fs_base__dag_set_entry(dag_node_t *node,
320251881Speter                                        const char *entry_name,
321251881Speter                                        const svn_fs_id_t *id,
322251881Speter                                        const char *txn_id,
323251881Speter                                        trail_t *trail,
324251881Speter                                        apr_pool_t *pool);
325251881Speter
326251881Speter
327251881Speter/* Make a new mutable clone of the node named NAME in PARENT, and
328251881Speter   adjust PARENT's directory entry to point to it, as part of TRAIL,
329251881Speter   unless NAME in PARENT already refers to a mutable node.  In either
330251881Speter   case, set *CHILD_P to a reference to the new node, allocated in
331251881Speter   POOL.  PARENT must be mutable.  NAME must be a single path
332251881Speter   component; it cannot be a slash-separated directory path.
333251881Speter   PARENT_PATH must be the canonicalized absolute path of the parent
334251881Speter   directory.
335251881Speter
336251881Speter   COPY_ID, if non-NULL, is a key into the `copies' table, and
337251881Speter   indicates that this new node is being created as the result of a
338251881Speter   copy operation, and specifically which operation that was.
339251881Speter
340251881Speter   PATH is the canonicalized absolute path at which this node is being
341251881Speter   created.
342251881Speter
343251881Speter   TXN_ID is the Subversion transaction under which this occurs.  */
344251881Spetersvn_error_t *svn_fs_base__dag_clone_child(dag_node_t **child_p,
345251881Speter                                          dag_node_t *parent,
346251881Speter                                          const char *parent_path,
347251881Speter                                          const char *name,
348251881Speter                                          const char *copy_id,
349251881Speter                                          const char *txn_id,
350251881Speter                                          trail_t *trail,
351251881Speter                                          apr_pool_t *pool);
352251881Speter
353251881Speter
354251881Speter/* Delete the directory entry named NAME from PARENT, as part of
355251881Speter   TRAIL.  PARENT must be mutable.  NAME must be a single path
356251881Speter   component; it cannot be a slash-separated directory path.  If the
357251881Speter   entry being deleted points to a mutable node revision, also remove
358251881Speter   that node revision and (if it is a directory) all mutable node
359251881Speter   revisions reachable from it.  Also delete the node-origins record
360251881Speter   for each deleted node revision that had no predecessor.
361251881Speter
362251881Speter   TXN_ID is the Subversion transaction under which this occurs.
363251881Speter
364251881Speter   If return SVN_ERR_FS_NO_SUCH_ENTRY, then there is no entry NAME in
365251881Speter   PARENT.  */
366251881Spetersvn_error_t *svn_fs_base__dag_delete(dag_node_t *parent,
367251881Speter                                     const char *name,
368251881Speter                                     const char *txn_id,
369251881Speter                                     trail_t *trail,
370251881Speter                                     apr_pool_t *pool);
371251881Speter
372251881Speter
373251881Speter/* Delete the node revision assigned to node ID from FS's `nodes'
374251881Speter   table, as part of TRAIL.  Also delete any mutable representations
375251881Speter   and strings associated with that node revision.  Also delete the
376251881Speter   node-origins record for this node revision's node id, if this node
377251881Speter   revision had no predecessor.
378251881Speter
379251881Speter   ID may refer to a file or directory, which must be mutable.  TXN_ID
380251881Speter   is the Subversion transaction under which this occurs.
381251881Speter
382251881Speter   NOTE: If ID represents a directory, and that directory has mutable
383251881Speter   children, you risk orphaning those children by leaving them
384251881Speter   dangling, disconnected from all DAG trees.  It is assumed that
385251881Speter   callers of this interface know what in the world they are doing.  */
386251881Spetersvn_error_t *svn_fs_base__dag_remove_node(svn_fs_t *fs,
387251881Speter                                          const svn_fs_id_t *id,
388251881Speter                                          const char *txn_id,
389251881Speter                                          trail_t *trail,
390251881Speter                                          apr_pool_t *pool);
391251881Speter
392251881Speter
393251881Speter/* Delete all mutable node revisions reachable from node ID, including
394251881Speter   ID itself, from FS's `nodes' table, as part of TRAIL.  Also delete
395251881Speter   any mutable representations and strings associated with that node
396251881Speter   revision.  Also delete the node-origins record for each deleted
397251881Speter   node revision that had no predecessor.
398251881Speter
399251881Speter   ID may refer to a file or directory, which may be mutable or
400251881Speter   immutable.  TXN_ID is the Subversion transaction under which this
401251881Speter   occurs.  */
402251881Spetersvn_error_t *svn_fs_base__dag_delete_if_mutable(svn_fs_t *fs,
403251881Speter                                                const svn_fs_id_t *id,
404251881Speter                                                const char *txn_id,
405251881Speter                                                trail_t *trail,
406251881Speter                                                apr_pool_t *pool);
407251881Speter
408251881Speter
409251881Speter/* Create a new mutable directory named NAME in PARENT, as part of
410251881Speter   TRAIL.  Set *CHILD_P to a reference to the new node, allocated in
411251881Speter   POOL.  The new directory has no contents, and no properties.
412251881Speter   PARENT must be mutable.  NAME must be a single path component; it
413251881Speter   cannot be a slash-separated directory path.  PARENT_PATH must be
414251881Speter   the canonicalized absolute path of the parent directory.  PARENT
415251881Speter   must not currently have an entry named NAME.  Do any temporary
416251881Speter   allocation in POOL.  TXN_ID is the Subversion transaction
417251881Speter   under which this occurs.  */
418251881Spetersvn_error_t *svn_fs_base__dag_make_dir(dag_node_t **child_p,
419251881Speter                                       dag_node_t *parent,
420251881Speter                                       const char *parent_path,
421251881Speter                                       const char *name,
422251881Speter                                       const char *txn_id,
423251881Speter                                       trail_t *trail,
424251881Speter                                       apr_pool_t *pool);
425251881Speter
426251881Speter
427251881Speter
428251881Speter/* Files.  */
429251881Speter
430251881Speter
431251881Speter/* Set *CONTENTS to a readable generic stream which yields the
432251881Speter   contents of FILE, as part of TRAIL.  Allocate the stream in POOL.
433251881Speter   If FILE is not a file, return SVN_ERR_FS_NOT_FILE.  */
434251881Spetersvn_error_t *svn_fs_base__dag_get_contents(svn_stream_t **contents,
435251881Speter                                           dag_node_t *file,
436251881Speter                                           trail_t *trail,
437251881Speter                                           apr_pool_t *pool);
438251881Speter
439251881Speter
440251881Speter/* Return a generic writable stream in *CONTENTS with which to set the
441251881Speter   contents of FILE as part of TRAIL.  Allocate the stream in POOL.
442251881Speter   TXN_ID is the Subversion transaction under which this occurs.  Any
443251881Speter   previous edits on the file will be deleted, and a new edit stream
444251881Speter   will be constructed.  */
445251881Spetersvn_error_t *svn_fs_base__dag_get_edit_stream(svn_stream_t **contents,
446251881Speter                                              dag_node_t *file,
447251881Speter                                              const char *txn_id,
448251881Speter                                              trail_t *trail,
449251881Speter                                              apr_pool_t *pool);
450251881Speter
451251881Speter
452251881Speter/* Signify the completion of edits to FILE made using the stream
453251881Speter   returned by svn_fs_base__dag_get_edit_stream, as part of TRAIL.  TXN_ID
454251881Speter   is the Subversion transaction under which this occurs.
455251881Speter
456251881Speter   If CHECKSUM is non-null, it must match the checksum for FILE's
457251881Speter   contents (note: this is not recalculated, the recorded checksum is
458251881Speter   used), else the error SVN_ERR_CHECKSUM_MISMATCH is returned.
459251881Speter
460251881Speter   This operation is a no-op if no edits are present.  */
461251881Spetersvn_error_t *svn_fs_base__dag_finalize_edits(dag_node_t *file,
462251881Speter                                             const svn_checksum_t *checksum,
463251881Speter                                             const char *txn_id,
464251881Speter                                             trail_t *trail,
465251881Speter                                             apr_pool_t *pool);
466251881Speter
467251881Speter
468251881Speter/* Set *LENGTH to the length of the contents of FILE, as part of TRAIL. */
469251881Spetersvn_error_t *svn_fs_base__dag_file_length(svn_filesize_t *length,
470251881Speter                                          dag_node_t *file,
471251881Speter                                          trail_t *trail,
472251881Speter                                          apr_pool_t *pool);
473251881Speter
474251881Speter/* Put the checksum of type CHECKSUM_KIND recorded for FILE into
475251881Speter * CHECKSUM, as part of TRAIL.
476251881Speter *
477251881Speter * If no stored checksum of the requested kind is available, do not
478251881Speter * calculate the checksum, just put NULL into CHECKSUM.
479251881Speter */
480251881Spetersvn_error_t *svn_fs_base__dag_file_checksum(svn_checksum_t **checksum,
481251881Speter                                            svn_checksum_kind_t checksum_kind,
482251881Speter                                            dag_node_t *file,
483251881Speter                                            trail_t *trail,
484251881Speter                                            apr_pool_t *pool);
485251881Speter
486251881Speter/* Create a new mutable file named NAME in PARENT, as part of TRAIL.
487251881Speter   Set *CHILD_P to a reference to the new node, allocated in
488251881Speter   POOL.  The new file's contents are the empty string, and it
489251881Speter   has no properties.  PARENT must be mutable.  NAME must be a single
490251881Speter   path component; it cannot be a slash-separated directory path.
491251881Speter   PARENT_PATH must be the canonicalized absolute path of the parent
492251881Speter   directory.  TXN_ID is the Subversion transaction under which this
493251881Speter   occurs.  */
494251881Spetersvn_error_t *svn_fs_base__dag_make_file(dag_node_t **child_p,
495251881Speter                                        dag_node_t *parent,
496251881Speter                                        const char *parent_path,
497251881Speter                                        const char *name,
498251881Speter                                        const char *txn_id,
499251881Speter                                        trail_t *trail,
500251881Speter                                        apr_pool_t *pool);
501251881Speter
502251881Speter
503251881Speter
504251881Speter/* Copies */
505251881Speter
506251881Speter/* Make ENTRY in TO_NODE be a copy of FROM_NODE, as part of TRAIL.
507251881Speter   TO_NODE must be mutable.  TXN_ID is the Subversion transaction
508251881Speter   under which this occurs.
509251881Speter
510251881Speter   If PRESERVE_HISTORY is true, the new node will record that it was
511251881Speter   copied from FROM_PATH in FROM_REV; therefore, FROM_NODE should be
512251881Speter   the node found at FROM_PATH in FROM_REV, although this is not
513251881Speter   checked.
514251881Speter
515251881Speter   If PRESERVE_HISTORY is false, FROM_PATH and FROM_REV are ignored.  */
516251881Spetersvn_error_t *svn_fs_base__dag_copy(dag_node_t *to_node,
517251881Speter                                   const char *entry,
518251881Speter                                   dag_node_t *from_node,
519251881Speter                                   svn_boolean_t preserve_history,
520251881Speter                                   svn_revnum_t from_rev,
521251881Speter                                   const char *from_path,
522251881Speter                                   const char *txn_id,
523251881Speter                                   trail_t *trail,
524251881Speter                                   apr_pool_t *pool);
525251881Speter
526251881Speter
527251881Speter
528251881Speter/* Deltification */
529251881Speter
530251881Speter/* Change TARGET's representation to be a delta against SOURCE, as
531251881Speter   part of TRAIL.  If TARGET or SOURCE does not exist, do nothing and
532251881Speter   return success.  If PROPS_ONLY is non-zero, only the node property
533251881Speter   portion of TARGET will be deltified.
534251881Speter
535251881Speter   If TXN_ID is non-NULL, it is the transaction ID in which TARGET's
536251881Speter   representation(s) must have been created (otherwise deltification
537251881Speter   is silently not attempted).
538251881Speter
539251881Speter   WARNING WARNING WARNING: Do *NOT* call this with a mutable SOURCE
540251881Speter   node.  Things will go *very* sour if you deltify TARGET against a
541251881Speter   node that might just disappear from the filesystem in the (near)
542251881Speter   future.  */
543251881Spetersvn_error_t *svn_fs_base__dag_deltify(dag_node_t *target,
544251881Speter                                      dag_node_t *source,
545251881Speter                                      svn_boolean_t props_only,
546251881Speter                                      const char *txn_id,
547251881Speter                                      trail_t *trail,
548251881Speter                                      apr_pool_t *pool);
549251881Speter
550251881Speter/* Index NODE's backing data representations by their checksum.  Do
551251881Speter   this as part of TRAIL.  Use POOL for allocations. */
552251881Spetersvn_error_t *svn_fs_base__dag_index_checksums(dag_node_t *node,
553251881Speter                                              trail_t *trail,
554251881Speter                                              apr_pool_t *pool);
555251881Speter
556251881Speter
557251881Speter/* Comparison */
558251881Speter
559251881Speter/* Find out what is the same between two nodes.
560251881Speter
561251881Speter   If PROPS_CHANGED is non-null, set *PROPS_CHANGED to 1 if the two
562251881Speter   nodes have different property lists, or to 0 if same.
563251881Speter
564251881Speter   If CONTENTS_CHANGED is non-null, set *CONTENTS_CHANGED to 1 if the
565251881Speter   two nodes have different contents, or to 0 if same.  For files,
566251881Speter   file contents are compared; for directories, the entries lists are
567251881Speter   compared.  If one is a file and the other is a directory, the one's
568251881Speter   contents will be compared to the other's entries list.  (Not
569251881Speter   terribly useful, I suppose, but that's the caller's business.)
570251881Speter
571251881Speter   ### todo: This function only compares rep keys at the moment.  This
572251881Speter   may leave us with a slight chance of a false positive, though I
573251881Speter   don't really see how that would happen in practice.  Nevertheless,
574251881Speter   it should probably be fixed.  */
575251881Spetersvn_error_t *svn_fs_base__things_different(svn_boolean_t *props_changed,
576251881Speter                                           svn_boolean_t *contents_changed,
577251881Speter                                           dag_node_t *node1,
578251881Speter                                           dag_node_t *node2,
579251881Speter                                           trail_t *trail,
580251881Speter                                           apr_pool_t *pool);
581251881Speter
582251881Speter
583251881Speter#ifdef __cplusplus
584251881Speter}
585251881Speter#endif /* __cplusplus */
586251881Speter
587251881Speter#endif /* SVN_LIBSVN_FS_DAG_H */
588