Subversion
Loading...
Searching...
No Matches
svn_delta.h
Go to the documentation of this file.
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_delta.h
24 * @brief Delta-parsing
25 */
26
27/* ==================================================================== */
28
29
30␌
31#ifndef SVN_DELTA_H
32#define SVN_DELTA_H
33
34#include <apr.h>
35#include <apr_pools.h>
36#include <apr_hash.h>
37#include <apr_tables.h>
38#include <apr_file_io.h> /* for apr_file_t */
39
40#include "svn_types.h"
41#include "svn_string.h"
42#include "svn_io.h"
43#include "svn_checksum.h"
44
45#ifdef __cplusplus
46extern "C" {
47#endif /* __cplusplus */
48
49
50␌
51/** This compression level effectively disables data compression.
52 * However, the data pre-processing costs may still not be zero.
53 *
54 * @since New in 1.7.
55 */
56#define SVN_DELTA_COMPRESSION_LEVEL_NONE 0
57
58/** This is the maximum compression level we can pass to zlib.
59 *
60 * @since New in 1.7.
61 */
62#define SVN_DELTA_COMPRESSION_LEVEL_MAX 9
63
64/** This is the default compression level we pass to zlib. It
65 * should be between 0 and 9, with higher numbers resulting in
66 * better compression rates but slower operation.
67 *
68 * @since New in 1.7.
69 */
70#define SVN_DELTA_COMPRESSION_LEVEL_DEFAULT 5
71
72/**
73 * Get libsvn_delta version information.
74 *
75 * @since New in 1.1.
76 */
77const svn_version_t *
79
80/**
81 * @defgroup delta_support Delta generation and handling
82 *
83 * @{
84 */
85
86/** Text deltas.
87 *
88 * A text delta represents the difference between two strings of
89 * bytes, the `source' string and the `target' string. Given a source
90 * string and a target string, we can compute a text delta; given a
91 * source string and a delta, we can reconstruct the target string.
92 * However, note that deltas are not reversible: you cannot always
93 * reconstruct the source string given the target string and delta.
94 *
95 * Since text deltas can be very large, the interface here allows us
96 * to produce and consume them in pieces. Each piece, represented by
97 * an #svn_txdelta_window_t structure, describes how to produce the
98 * next section of the target string.
99 *
100 * To compute a new text delta:
101 *
102 * - We call svn_txdelta() on the streams we want to compare. That
103 * returns us an #svn_txdelta_stream_t object.
104 *
105 * - We then call svn_txdelta_next_window() on the stream object
106 * repeatedly. Each call returns a new #svn_txdelta_window_t
107 * object, which describes the next portion of the target string.
108 * When svn_txdelta_next_window() returns zero, we are done building
109 * the target string.
110 *
111 * @defgroup svn_delta_txt_delta Text deltas
112 * @{
113 */
114
115/** Action codes for text delta instructions. */
117 /* Note: The svndiff implementation relies on the values assigned in
118 * this enumeration matching the instruction encoding values. */
119
120 /** Append the @a length bytes at @a offset in the source view to the
121 * target.
122 *
123 * It must be the case that 0 <= @a offset < @a offset +
124 * @a length <= size of source view.
125 */
127
128 /** Append the @a length bytes at @a offset in the target view, to the
129 * target.
130 *
131 * It must be the case that 0 <= @a offset < current position in the
132 * target view.
133 *
134 * However! @a offset + @a length may be *beyond* the end of the existing
135 * target data. "Where the heck does the text come from, then?"
136 * If you start at @a offset, and append @a length bytes one at a time,
137 * it'll work out --- you're adding new bytes to the end at the
138 * same rate you're reading them from the middle. Thus, if your
139 * current target text is "abcdefgh", and you get an #svn_txdelta_target
140 * instruction whose @a offset is 6 and whose @a length is 7,
141 * the resulting string is "abcdefghghghghg". This trick is actually
142 * useful in encoding long runs of consecutive characters, long runs
143 * of CR/LF pairs, etc.
144 */
146
147 /** Append the @a length bytes at @a offset in the window's @a new string
148 * to the target.
149 *
150 * It must be the case that 0 <= @a offset < @a offset +
151 * @a length <= length of @a new. Windows MUST use new data in ascending
152 * order with no overlap at the moment; svn_txdelta_to_svndiff()
153 * depends on this.
154 */
156};
157
158/** A single text delta instruction. */
159typedef struct svn_txdelta_op_t
160{
161 /** Action code of delta instruction */
163 /** Offset of delta, see #svn_delta_action for more details. */
164 apr_size_t offset;
165 /** Number of bytes of delta, see #svn_delta_action for more details. */
166 apr_size_t length;
168
169
170/** An #svn_txdelta_window_t object describes how to reconstruct a
171 * contiguous section of the target string (the "target view") using a
172 * specified contiguous region of the source string (the "source
173 * view"). It contains a series of instructions which assemble the
174 * new target string text by pulling together substrings from:
175 *
176 * - the source view,
177 *
178 * - the previously constructed portion of the target view,
179 *
180 * - a string of new data contained within the window structure
181 *
182 * The source view must always slide forward from one window to the
183 * next; that is, neither the beginning nor the end of the source view
184 * may move to the left as we read from a window stream. This
185 * property allows us to apply deltas to non-seekable source streams
186 * without making a full copy of the source stream.
187 */
189{
190
191 /** The offset of the source view for this window. */
193
194 /** The length of the source view for this window. */
195 apr_size_t sview_len;
196
197 /** The length of the target view for this window, i.e. the number of
198 * bytes which will be reconstructed by the instruction stream. */
199 apr_size_t tview_len;
200
201 /** The number of instructions in this window. */
203
204 /** The number of svn_txdelta_source instructions in this window. If
205 * this number is 0, we don't need to read the source in order to
206 * reconstruct the target view.
207 */
209
210 /** The instructions for this window. */
212
213 /** New data, for use by any `svn_txdelta_new' instructions. */
214 const svn_string_t *new_data;
215
217
218/**
219 * Return a deep copy of @a window, allocated in @a pool.
220 *
221 * @since New in 1.3.
222 */
225 apr_pool_t *pool);
226
227/**
228 * Compose two delta windows, yielding a third, allocated in @a pool.
229 *
230 * @since New in 1.4
231 *
232 */
235 const svn_txdelta_window_t *window_B,
236 apr_pool_t *pool);
237
238/**
239 * Apply the instructions from @a window to a source view @a sbuf to
240 * produce a target view @a tbuf.
241 *
242 * @a sbuf is assumed to have @a window->sview_len bytes of data and
243 * @a tbuf is assumed to have room for @a tlen bytes of output. @a
244 * tlen may be more than @a window->tview_len, so return the actual
245 * number of bytes written. @a sbuf is not touched and may be NULL if
246 * @a window contains no source-copy operations. This is purely a
247 * memory operation; nothing can go wrong as long as we have a valid
248 * window.
249 *
250 * @since New in 1.4
251 *
252 * @since Since 1.9, @a tbuf may be NULL if @a *tlen is 0.
253 */
254void
256 const char *sbuf, char *tbuf,
257 apr_size_t *tlen);
258
259/** A typedef for functions that consume a series of delta windows, for
260 * use in caller-pushes interfaces. Such functions will typically
261 * apply the delta windows to produce some file, or save the windows
262 * somewhere. At the end of the delta window stream, you must call
263 * this function passing zero for the @a window argument.
264 */
265typedef svn_error_t *(*svn_txdelta_window_handler_t)(
266 svn_txdelta_window_t *window, void *baton);
267
268
269/** This function will generate delta windows that turn @a source into
270 * @a target, and pushing these windows into the @a handler window handler
271 * callback (passing @a handler_baton to each invocation).
272 *
273 * If @a checksum is not NULL, then a checksum (of kind @a checksum_kind)
274 * will be computed for the target stream, and placed into *checksum.
275 *
276 * If @a cancel_func is not NULL, then it should refer to a cancellation
277 * function (along with @a cancel_baton).
278 *
279 * Results (the checksum) will be allocated from @a result_pool, and all
280 * temporary allocations will be performed in @a scratch_pool.
281 *
282 * Note: this function replaces the combination of svn_txdelta() and
283 * svn_txdelta_send_txstream().
284 *
285 * @since New in 1.6.
286 */
289 svn_stream_t *target,
291 void *handler_baton,
292 svn_checksum_kind_t checksum_kind,
293 svn_checksum_t **checksum,
294 svn_cancel_func_t cancel_func,
295 void *cancel_baton,
296 apr_pool_t *result_pool,
297 apr_pool_t *scratch_pool);
298
299
300/** A delta stream --- this is the hat from which we pull a series of
301 * svn_txdelta_window_t objects, which, taken in order, describe the
302 * entire target string. This type is defined within libsvn_delta, and
303 * opaque outside that library.
304 */
306
307
308/** A typedef for a function that will set @a *window to the next
309 * window from a #svn_txdelta_stream_t object. If there are no more
310 * delta windows, NULL will be used. The returned window, if any,
311 * will be allocated in @a pool. @a baton is the baton specified
312 * when the stream was created.
313 *
314 * @since New in 1.4.
315 */
316typedef svn_error_t *
317(*svn_txdelta_next_window_fn_t)(svn_txdelta_window_t **window,
318 void *baton,
319 apr_pool_t *pool);
320
321/** A typedef for a function that will return the md5 checksum of the
322 * fulltext deltified by a #svn_txdelta_stream_t object. Will
323 * return NULL if the final null window hasn't yet been returned by
324 * the stream. The returned value will be allocated in the same pool
325 * as the stream. @a baton is the baton specified when the stream was
326 * created.
327 *
328 * @since New in 1.4.
329 */
330typedef const unsigned char *
331(*svn_txdelta_md5_digest_fn_t)(void *baton);
332
333/** A typedef for a function that opens an #svn_txdelta_stream_t object,
334 * allocated in @a result_pool. @a baton is provided by the caller.
335 * Any temporary allocations may be performed in @a scratch_pool.
336 *
337 * @since New in 1.10.
338 */
339typedef svn_error_t *
340(*svn_txdelta_stream_open_func_t)(svn_txdelta_stream_t **txdelta_stream,
341 void *baton,
342 apr_pool_t *result_pool,
343 apr_pool_t *scratch_pool);
344
345/** Create and return a generic text delta stream with @a baton, @a
346 * next_window and @a md5_digest. Allocate the new stream in @a
347 * pool.
348 *
349 * @since New in 1.4.
350 */
355 apr_pool_t *pool);
356
357/** Set @a *window to a pointer to the next window from the delta stream
358 * @a stream. When we have completely reconstructed the target string,
359 * set @a *window to zero.
360 *
361 * The window will be allocated in @a pool.
362 */
365 svn_txdelta_stream_t *stream,
366 apr_pool_t *pool);
367
368
369/** Return the md5 digest for the complete fulltext deltified by
370 * @a stream, or @c NULL if @a stream has not yet returned its final
371 * @c NULL window. The digest is allocated in the same memory as @a
372 * STREAM.
373 */
374const unsigned char *
376
377/** Set @a *stream to a pointer to a delta stream that will turn the byte
378 * string from @a source into the byte stream from @a target.
379 *
380 * @a source and @a target are both readable generic streams. When we call
381 * svn_txdelta_next_window() on @a *stream, it will read from @a source and
382 * @a target to gather as much data as it needs. If @a calculate_checksum
383 * is set, you may call svn_txdelta_md5_digest() to get an MD5 checksum
384 * for @a target.
385 *
386 * Do any necessary allocation in a sub-pool of @a pool.
387 *
388 * @since New in 1.8.
389 */
390void
392 svn_stream_t *source,
393 svn_stream_t *target,
394 svn_boolean_t calculate_checksum,
395 apr_pool_t *pool);
396
397/** Similar to svn_txdelta2 but always calculating the target checksum.
398 *
399 * @deprecated Provided for backward compatibility with the 1.7 API.
400 */
402void
404 svn_stream_t *source,
405 svn_stream_t *target,
406 apr_pool_t *pool);
407
408
409/**
410 * Return a writable stream which, when fed target data, will send
411 * delta windows to @a handler/@a handler_baton which transform the
412 * data in @a source to the target data. As usual, the window handler
413 * will receive a NULL window to signify the end of the window stream.
414 * The stream handler functions will read data from @a source as
415 * necessary.
416 *
417 * @since New in 1.1.
418 */
421 void *handler_baton,
422 svn_stream_t *source,
423 apr_pool_t *pool);
424
425
426/** Send the contents of @a string to window-handler @a handler/@a baton.
427 * This is effectively a 'copy' operation, resulting in delta windows that
428 * make the target equivalent to the value of @a string.
429 *
430 * All temporary allocation is performed in @a pool.
431 */
435 void *handler_baton,
436 apr_pool_t *pool);
437
438/** Send the contents of @a stream to window-handler @a handler/@a baton.
439 * This is effectively a 'copy' operation, resulting in delta windows that
440 * make the target equivalent to the stream.
441 *
442 * If @a digest is non-NULL, populate it with the md5 checksum for the
443 * fulltext that was deltified (@a digest must be at least
444 * @c APR_MD5_DIGESTSIZE bytes long).
445 *
446 * All temporary allocation is performed in @a pool.
447 */
451 void *handler_baton,
452 unsigned char *digest,
453 apr_pool_t *pool);
454
455/** Send the contents of @a txstream to window-handler @a handler/@a baton.
456 * Windows will be extracted from the stream and delivered to the handler.
457 *
458 * All temporary allocation is performed in @a pool.
459 */
463 void *handler_baton,
464 apr_pool_t *pool);
465
466
467/** Send the @a contents of length @a len as a txdelta against an empty
468 * source directly to window-handler @a handler/@a handler_baton.
469 *
470 * All temporary allocation is performed in @a pool.
471 *
472 * @since New in 1.8.
473 */
475svn_txdelta_send_contents(const unsigned char *contents,
476 apr_size_t len,
478 void *handler_baton,
479 apr_pool_t *pool);
480
481/** Prepare to apply a text delta. @a source is a readable generic stream
482 * yielding the source data, @a target is a writable generic stream to
483 * write target data to, and allocation takes place in a sub-pool of
484 * @a pool. On return, @a *handler is set to a window handler function and
485 * @a *handler_baton is set to the value to pass as the @a baton argument to
486 * @a *handler.
487 *
488 * If @a result_digest is non-NULL, it points to APR_MD5_DIGESTSIZE bytes
489 * of storage, and the final call to @a handler populates it with the
490 * MD5 digest of the resulting fulltext.
491 *
492 * If @a error_info is non-NULL, it is inserted parenthetically into
493 * the error string for any error returned by svn_txdelta_apply2() or
494 * @a *handler. (It is normally used to provide path information,
495 * since there's nothing else in the delta application's context to
496 * supply a path for error messages.)
497 *
498 * @note both @a source and @a target will be closed when the window
499 * handler is given a null window to signal the end of the delta.
500 * If the closure is not desired, then you can use svn_stream_disown()
501 * to protect either or both of the streams from being closed.
502 *
503 * @note To avoid lifetime issues, @a error_info is copied into
504 * @a pool or a subpool thereof.
505 *
506 * @since New in 1.15.
507 */
508void
510 svn_stream_t *target,
511 unsigned char *result_digest,
512 const char *error_info,
513 apr_pool_t *pool,
515 void **handler_baton);
516
517/** Similar to svn_txdelta_apply2(), but the @a source stream is NOT closed.
518 * The @a target stream will be closed when the window handler is given
519 * a null window to signal the end of the delta.
520 *
521 * @deprecated Provided for backward compatibility with the 1.14 API.
522 */
524void
526 svn_stream_t *target,
527 unsigned char *result_digest,
528 const char *error_info,
529 apr_pool_t *pool,
531 void **handler_baton);
532
533
534␌
535
536/*** Producing and consuming svndiff-format text deltas. ***/
537
538/** Prepare to produce an svndiff-format diff from text delta windows.
539 * @a output is a writable generic stream to write the svndiff data to.
540 * Allocation takes place in a sub-pool of @a pool. On return, @a *handler
541 * is set to a window handler function and @a *handler_baton is set to
542 * the value to pass as the @a baton argument to @a *handler. The svndiff
543 * version is @a svndiff_version. @a compression_level is the zlib
544 * compression level from 0 (no compression) and 9 (maximum compression).
545 *
546 * @since New in 1.7. Since 1.10, @a svndiff_version can be 2 for the
547 * svndiff2 format. @a compression_level is currently ignored if
548 * @a svndiff_version is set to 2.
549 */
550void
552 void **handler_baton,
553 svn_stream_t *output,
554 int svndiff_version,
555 int compression_level,
556 apr_pool_t *pool);
557
558/** Similar to svn_txdelta_to_svndiff3(), but always using the SVN default
559 * compression level (#SVN_DELTA_COMPRESSION_LEVEL_DEFAULT).
560 *
561 * @since New in 1.4.
562 * @deprecated Provided for backward compatibility with the 1.6 API.
563 */
565void
567 void **handler_baton,
568 svn_stream_t *output,
569 int svndiff_version,
570 apr_pool_t *pool);
571
572/** Similar to svn_txdelta_to_svndiff2, but always using svndiff
573 * version 0.
574 *
575 * @deprecated Provided for backward compatibility with the 1.3 API.
576 */
578void
580 apr_pool_t *pool,
582 void **handler_baton);
583
584/** Return a readable generic stream which will produce svndiff-encoded
585 * text delta from the delta stream @a txstream. @a svndiff_version and
586 * @a compression_level are same as in svn_txdelta_to_svndiff3().
587 *
588 * Allocate the stream in @a pool.
589 *
590 * @since New in 1.10.
591 */
594 int svndiff_version,
595 int compression_level,
596 apr_pool_t *pool);
597
598/** Return a writable generic stream which will parse svndiff-format
599 * data into a text delta, invoking @a handler with @a handler_baton
600 * whenever a new window is ready.
601 *
602 * When the caller closes this stream, this will signal completion to
603 * the window handler by invoking @a handler once more, passing zero for
604 * the @c window argument.
605 *
606 * If @a error_on_early_close is @c TRUE, then attempt to avoid
607 * signaling completion to the window handler if the delta was
608 * incomplete. Specifically, attempting to close the stream will be
609 * successful only if the data written to the stream consisted of one or
610 * more complete windows of svndiff data and no extra bytes. Otherwise,
611 * closing the stream will not signal completion to the window handler,
612 * and will return a #SVN_ERR_SVNDIFF_UNEXPECTED_END error. Note that if
613 * no data at all was written, the delta is considered incomplete.
614 *
615 * If @a error_on_early_close is @c FALSE, closing the stream will
616 * signal completion to the window handler, regardless of how much data
617 * was written, and discard any pending incomplete data.
618 *
619 * Allocate the stream in @a pool.
620 */
623 void *handler_baton,
624 svn_boolean_t error_on_early_close,
625 apr_pool_t *pool);
626
627/**
628 * Read and parse one delta window in svndiff format from the
629 * readable stream @a stream and place it in @a *window, allocating
630 * the result in @a pool. The caller must take responsibility for
631 * stripping off the four-byte 'SVN@<ver@>' header at the beginning of
632 * the svndiff document before reading the first window, and must
633 * provide the version number (the value of the fourth byte) to each
634 * invocation of this routine with the @a svndiff_version argument.
635 *
636 * @since New in 1.1.
637 */
640 svn_stream_t *stream,
641 int svndiff_version,
642 apr_pool_t *pool);
643
644/**
645 * Read and skip one delta window in svndiff format from the
646 * file @a file. @a pool is used for temporary allocations. The
647 * caller must take responsibility for stripping off the four-byte
648 * 'SVN@<ver@>' header at the beginning of the svndiff document before
649 * reading or skipping the first window, and must provide the version
650 * number (the value of the fourth byte) to each invocation of this
651 * routine with the @a svndiff_version argument.
652 *
653 * @since New in 1.1.
654 */
657 int svndiff_version,
658 apr_pool_t *pool);
659
660/** @} */
661
662␌
663/** Traversing tree deltas.
664 *
665 * In Subversion, we've got various producers and consumers of tree
666 * deltas.
667 *
668 * In processing a `commit' command:
669 * - The client examines its working copy data, and produces a tree
670 * delta describing the changes to be committed.
671 * - The client networking library consumes that delta, and sends them
672 * across the wire as an equivalent series of network requests (for
673 * example, to svnserve as an ra_svn protocol stream, or to an
674 * Apache httpd server as WebDAV commands)
675 * - The server receives those requests and produces a tree delta ---
676 * hopefully equivalent to the one the client produced above.
677 * - The Subversion server module consumes that delta and commits an
678 * appropriate transaction to the filesystem.
679 *
680 * In processing an `update' command, the process is reversed:
681 * - The Subversion server module talks to the filesystem and produces
682 * a tree delta describing the changes necessary to bring the
683 * client's working copy up to date.
684 * - The server consumes this delta, and assembles a reply
685 * representing the appropriate changes.
686 * - The client networking library receives that reply, and produces a
687 * tree delta --- hopefully equivalent to the one the Subversion
688 * server produced above.
689 * - The working copy library consumes that delta, and makes the
690 * appropriate changes to the working copy.
691 *
692 * The simplest approach would be to represent tree deltas using the
693 * obvious data structure. To do an update, the server would
694 * construct a delta structure, and the working copy library would
695 * apply that structure to the working copy; the network layer's job
696 * would simply be to get the structure across the net intact.
697 *
698 * However, we expect that these deltas will occasionally be too large
699 * to fit in a typical workstation's swap area. For example, in
700 * checking out a 200Mb source tree, the entire source tree is
701 * represented by a single tree delta. So it's important to handle
702 * deltas that are too large to fit in swap all at once.
703 *
704 * So instead of representing the tree delta explicitly, we define a
705 * standard way for a consumer to process each piece of a tree delta
706 * as soon as the producer creates it. The #svn_delta_editor_t
707 * structure is a set of callback functions to be defined by a delta
708 * consumer, and invoked by a delta producer. Each invocation of a
709 * callback function describes a piece of the delta --- a file's
710 * contents changing, something being renamed, etc.
711 *
712 * @defgroup svn_delta_tree_deltas Tree deltas
713 * @{
714 */
715
716/** A structure full of callback functions the delta source will invoke
717 * as it produces the delta.
718 *
719 * @note Don't try to allocate one of these yourself. Instead, always
720 * use svn_delta_default_editor() or some other constructor, to avoid
721 * backwards compatibility problems if the structure is extended in
722 * future releases and to ensure that unused slots are filled in with
723 * no-op functions.
724 *
725 * <h3>Function Usage</h3>
726 *
727 * Here's how to use these functions to express a tree delta.
728 *
729 * The delta consumer implements the callback functions described in
730 * this structure, and the delta producer invokes them. So the
731 * caller (producer) is pushing tree delta data at the callee
732 * (consumer).
733 *
734 * At the start of traversal, the consumer provides @a edit_baton, a
735 * baton global to the entire delta edit. If there is a target
736 * revision that needs to be set for this operation, the producer
737 * should call the @c set_target_revision function at this point.
738 *
739 * Next, if there are any tree deltas to express, the producer should
740 * pass the @a edit_baton to the @c open_root function, to get a baton
741 * representing root of the tree being edited.
742 *
743 * Most of the callbacks work in the obvious way:
744 *
745 * @c delete_entry
746 * @c add_file
747 * @c add_directory
748 * @c open_file
749 * @c open_directory
750 *
751 * Each of these takes a directory baton, indicating the directory
752 * in which the change takes place, and a @a path argument, giving the
753 * path of the file, subdirectory, or directory entry to change.
754 *
755 * The @a path argument to each of the callbacks is relative to the
756 * root of the edit. Editors will usually want to join this relative
757 * path with some base stored in the edit baton (e.g. a URL, or a
758 * location in the OS filesystem).
759 *
760 * Since every call requires a parent directory baton, including
761 * @c add_directory and @c open_directory, where do we ever get our
762 * initial directory baton, to get things started? The @c open_root
763 * function returns a baton for the top directory of the change. In
764 * general, the producer needs to invoke the editor's @c open_root
765 * function before it can get anything of interest done.
766 *
767 * While @c open_root provides a directory baton for the root of
768 * the tree being changed, the @c add_directory and @c open_directory
769 * callbacks provide batons for other directories. Like the
770 * callbacks above, they take a @a parent_baton and a relative path
771 * @a path, and then return a new baton for the subdirectory being
772 * created / modified --- @a child_baton. The producer can then use
773 * @a child_baton to make further changes in that subdirectory.
774 *
775 * So, if we already have subdirectories named `foo' and `foo/bar',
776 * then the producer can create a new file named `foo/bar/baz.c' by
777 * calling:
778 *
779 * - @c open_root () --- yielding a baton @a root for the top directory
780 *
781 * - @c open_directory (@a root, "foo") --- yielding a baton @a f for `foo'
782 *
783 * - @c open_directory (@a f, "foo/bar") --- yielding a baton @a b for
784 * `foo/bar'
785 *
786 * - @c add_file (@a b, "foo/bar/baz.c")
787 *
788 * When the producer is finished making changes to a directory, it
789 * should call @c close_directory. This lets the consumer do any
790 * necessary cleanup, and free the baton's storage.
791 *
792 * The @c add_file and @c open_file callbacks each return a baton
793 * for the file being created or changed. This baton can then be
794 * passed to @c apply_textdelta or @c apply_textdelta_stream to change
795 * the file's contents, or @c change_file_prop to change the file's
796 * properties. When the producer is finished making changes to a
797 * file, it should call @c close_file, to let the consumer clean up
798 * and free the baton.
799 *
800 * The @c add_file and @c add_directory functions each take arguments
801 * @a copyfrom_path and @a copyfrom_revision. If @a copyfrom_path is
802 * non-@c NULL, then @a copyfrom_path and @a copyfrom_revision indicate where
803 * the file or directory should be copied from (to create the file
804 * or directory being added). In that case, @a copyfrom_path must be
805 * either a path relative to the root of the edit, or a URI from the
806 * repository being edited. If @a copyfrom_path is @c NULL, then @a
807 * copyfrom_revision must be #SVN_INVALID_REVNUM; it is invalid to
808 * pass a mix of valid and invalid copyfrom arguments.
809 *
810 *
811 * <h3>Function Call Ordering</h3>
812 *
813 * There are six restrictions on the order in which the producer
814 * may use the batons:
815 *
816 * 1. The producer may call @c open_directory, @c add_directory,
817 * @c open_file, @c add_file at most once on any given directory
818 * entry. @c delete_entry may be called at most once on any given
819 * directory entry and may later be followed by @c add_directory or
820 * @c add_file on the same directory entry. @c delete_entry may
821 * not be called on any directory entry after @c open_directory,
822 * @c add_directory, @c open_file or @c add_file has been called on
823 * that directory entry.
824 *
825 * 2. The producer may not close a directory baton until it has
826 * closed all batons for its subdirectories.
827 *
828 * 3. When a producer calls @c open_directory or @c add_directory,
829 * it must specify the most recently opened of the currently open
830 * directory batons. Put another way, the producer cannot have
831 * two sibling directory batons open at the same time.
832 *
833 * 4. A producer must call @c change_dir_prop on a directory either
834 * before opening any of the directory's subdirs or after closing
835 * them, but not in the middle.
836 *
837 * 5. When the producer calls @c open_file or @c add_file, either:
838 *
839 * (a) The producer must follow with any changes to the file
840 * (@c change_file_prop and/or @c apply_textdelta /
841 * @c apply_textdelta_stream, as applicable), followed by
842 * a @c close_file call, before issuing any other file or
843 * directory calls, or
844 *
845 * (b) The producer must follow with a @c change_file_prop call if
846 * it is applicable, before issuing any other file or directory
847 * calls; later, after all directory batons including the root
848 * have been closed, the producer must issue @c apply_textdelta /
849 * @c apply_textdelta_stream and @c close_file calls.
850 *
851 * 6. When the producer calls @c apply_textdelta, it must make all of
852 * the window handler calls (including the @c NULL window at the
853 * end) before issuing any other #svn_delta_editor_t calls.
854 *
855 * So, the producer needs to use directory and file batons as if it
856 * is doing a single depth-first traversal of the tree, with the
857 * exception that the producer may keep file batons open in order to
858 * make @c apply_textdelta / @c apply_textdelta_stream calls at the end.
859 *
860 *
861 * <h3>Pool Usage</h3>
862 *
863 * Many editor functions are invoked multiple times, in a sequence
864 * determined by the editor "driver". The driver is responsible for
865 * creating a pool for use on each iteration of the editor function,
866 * and clearing that pool between each iteration. The driver passes
867 * the appropriate pool on each function invocation.
868 *
869 * Based on the requirement of calling the editor functions in a
870 * depth-first style, it is usually customary for the driver to similarly
871 * nest the pools. However, this is only a safety feature to ensure
872 * that pools associated with deeper items are always cleared when the
873 * top-level items are also cleared. The interface does not assume, nor
874 * require, any particular organization of the pools passed to these
875 * functions. In fact, if "postfix deltas" are used for files, the file
876 * pools definitely need to live outside the scope of their parent
877 * directories' pools.
878 *
879 * Note that close_directory can be called *before* a file in that
880 * directory has been closed. That is, the directory's baton is
881 * closed before the file's baton. The implication is that
882 * @c apply_textdelta / @c apply_textdelta_stream and @c close_file
883 * should not refer to a parent directory baton UNLESS the editor has
884 * taken precautions to allocate it in a pool of the appropriate
885 * lifetime (the @a result_pool passed to @c open_directory and
886 * @c add_directory definitely does not have the proper lifetime).
887 * In general, it is recommended to simply avoid keeping a parent
888 * directory baton in a file baton.
889 *
890 *
891 * <h3>Errors</h3>
892 *
893 * At least one implementation of the editor interface is
894 * asynchronous; an error from one operation may be detected some
895 * number of operations later. As a result, an editor driver must not
896 * assume that an error from an editing function resulted from the
897 * particular operation being detected. Moreover, once an editing
898 * function (including @c close_edit) returns an error, the edit is
899 * dead; the only further operation which may be called on the editor
900 * is @c abort_edit.
901 */
902typedef struct svn_delta_editor_t
903{
904 /** Set the target revision for this edit to @a target_revision. This
905 * call, if used, should precede all other editor calls.
906 *
907 * @note This is typically used only for server->client update-type
908 * operations. It doesn't really make much sense for commit-type
909 * operations, because the revision of a commit isn't known until
910 * the commit is finalized.
911 *
912 * Any temporary allocations may be performed in @a scratch_pool.
913 */
914 svn_error_t *(*set_target_revision)(void *edit_baton,
915 svn_revnum_t target_revision,
916 apr_pool_t *scratch_pool);
917
918 /** Set @a *root_baton to a baton for the top directory of the change.
919 * (This is the top of the subtree being changed, not necessarily
920 * the root of the filesystem.) As with any other directory baton, the
921 * producer should call @c close_directory on @a root_baton when done.
922 * And as with other @c open_* calls, the @a base_revision here is the
923 * current revision of the directory (before getting bumped up to the
924 * new target revision set with @c set_target_revision).
925 *
926 * Allocations for the returned @a root_baton should be performed in
927 * @a result_pool. It is also typical to (possibly) save this pool for
928 * later usage by @c close_directory.
929 */
930 svn_error_t *(*open_root)(void *edit_baton,
931 svn_revnum_t base_revision,
932 apr_pool_t *result_pool,
933 void **root_baton);
934
935
936 /** Remove the directory entry at @a path, a child of the directory
937 * represented by @a parent_baton. If @a revision is a valid
938 * revision number, it is used as a sanity check to ensure that you
939 * are really removing the revision of @a path that you think you are.
940 *
941 * Any temporary allocations may be performed in @a scratch_pool.
942 *
943 * @note The @a revision parameter is typically used only for
944 * client->server commit-type operations, allowing the server to
945 * verify that it is deleting what the client thinks it should be
946 * deleting. It only really makes sense in the opposite direction
947 * (during server->client update-type operations) when the trees
948 * whose delta is being described are ancestrally related (that is,
949 * one tree is an ancestor of the other).
950 */
951 svn_error_t *(*delete_entry)(const char *path,
953 void *parent_baton,
954 apr_pool_t *scratch_pool);
955
956
957 /** We are going to add a new subdirectory at @a path, a child of
958 * the directory represented by @a parent_baton. We will use
959 * the value this callback stores in @a *child_baton as the
960 * parent baton for further changes in the new subdirectory.
961 *
962 * If @a copyfrom_path is non-@c NULL, this add has history (i.e., is a
963 * copy), and the origin of the copy may be recorded as
964 * @a copyfrom_path under @a copyfrom_revision.
965 *
966 * Allocations for the returned @a child_baton should be performed in
967 * @a result_pool. It is also typical to (possibly) save this pool for
968 * later usage by @c close_directory.
969 */
970 svn_error_t *(*add_directory)(const char *path,
971 void *parent_baton,
972 const char *copyfrom_path,
973 svn_revnum_t copyfrom_revision,
974 apr_pool_t *result_pool,
975 void **child_baton);
976
977 /** We are going to make changes in the subdirectory at @a path, a
978 * child of the directory represented by @a parent_baton.
979 * The callback must store a value in @a *child_baton that
980 * should be used as the parent baton for subsequent changes in this
981 * subdirectory. If a valid revnum, @a base_revision is the current
982 * revision of the subdirectory.
983 *
984 * Allocations for the returned @a child_baton should be performed in
985 * @a result_pool. It is also typical to (possibly) save this pool for
986 * later usage by @c close_directory.
987 */
988 svn_error_t *(*open_directory)(const char *path,
989 void *parent_baton,
990 svn_revnum_t base_revision,
991 apr_pool_t *result_pool,
992 void **child_baton);
993
994 /** Change the value of a directory's property.
995 * - @a dir_baton specifies the directory whose property should change.
996 * - @a name is the name of the property to change.
997 * - @a value is the new (final) value of the property, or @c NULL if the
998 * property should be removed altogether.
999 *
1000 * The callback is guaranteed to be called exactly once for each property
1001 * whose value differs between the start and the end of the edit.
1002 *
1003 * Any temporary allocations may be performed in @a scratch_pool.
1004 */
1005 svn_error_t *(*change_dir_prop)(void *dir_baton,
1006 const char *name,
1007 const svn_string_t *value,
1008 apr_pool_t *scratch_pool);
1009
1010 /** We are done processing a subdirectory, whose baton is @a dir_baton
1011 * (set by @c add_directory or @c open_directory). We won't be using
1012 * the baton any more, so whatever resources it refers to may now be
1013 * freed.
1014 *
1015 * Any temporary allocations may be performed in @a scratch_pool.
1016 */
1017 svn_error_t *(*close_directory)(void *dir_baton,
1018 apr_pool_t *scratch_pool);
1019
1020
1021 /** In the directory represented by @a parent_baton, indicate that
1022 * @a path is present as a subdirectory in the edit source, but
1023 * cannot be conveyed to the edit consumer. Currently, this would
1024 * only occur because of authorization restrictions, but may change
1025 * in the future.
1026 *
1027 * Any temporary allocations may be performed in @a scratch_pool.
1028 */
1029 svn_error_t *(*absent_directory)(const char *path,
1030 void *parent_baton,
1031 apr_pool_t *scratch_pool);
1032
1033 /** We are going to add a new file at @a path, a child of the
1034 * directory represented by @a parent_baton. The callback can
1035 * store a baton for this new file in @a **file_baton; whatever value
1036 * it stores there should be passed through to @c apply_textdelta or
1037 * @c apply_textdelta_stream.
1038 *
1039 * If @a copyfrom_path is non-@c NULL, this add has history (i.e., is a
1040 * copy), and the origin of the copy may be recorded as
1041 * @a copyfrom_path under @a copyfrom_revision.
1042 *
1043 * Allocations for the returned @a file_baton should be performed in
1044 * @a result_pool. It is also typical to save this pool for later usage
1045 * by @c apply_textdelta and possibly @c close_file.
1046 *
1047 * @note Because the editor driver could be employing the "postfix
1048 * deltas" paradigm, @a result_pool could potentially be relatively
1049 * long-lived. Every file baton created by the editor for a given
1050 * editor drive might be resident in memory similtaneously. Editor
1051 * implementations should ideally keep their file batons as
1052 * conservative (memory-usage-wise) as possible, and use @a result_pool
1053 * only for those batons. (Consider using a subpool of @a result_pool
1054 * for scratch work, destroying the subpool before exiting this
1055 * function's implementation.)
1056 */
1057 svn_error_t *(*add_file)(const char *path,
1058 void *parent_baton,
1059 const char *copyfrom_path,
1060 svn_revnum_t copyfrom_revision,
1061 apr_pool_t *result_pool,
1062 void **file_baton);
1063
1064 /** We are going to make changes to a file at @a path, a child of the
1065 * directory represented by @a parent_baton.
1066 *
1067 * The callback can store a baton for this new file in @a **file_baton;
1068 * whatever value it stores there should be passed through to
1069 * @c apply_textdelta or @c apply_textdelta_stream. If a valid revnum,
1070 * @a base_revision is the current revision of the file.
1071 *
1072 * Allocations for the returned @a file_baton should be performed in
1073 * @a result_pool. It is also typical to save this pool for later usage
1074 * by @c apply_textdelta and possibly @c close_file.
1075 *
1076 * @note See note about memory usage on @a add_file, which also
1077 * applies here.
1078 */
1079 svn_error_t *(*open_file)(const char *path,
1080 void *parent_baton,
1081 svn_revnum_t base_revision,
1082 apr_pool_t *result_pool,
1083 void **file_baton);
1084
1085 /** Apply a text delta, yielding the new revision of a file.
1086 *
1087 * @a file_baton indicates the file we're creating or updating, and the
1088 * ancestor file on which it is based; it is the baton set by some
1089 * prior @c add_file or @c open_file callback.
1090 *
1091 * The callback should set @a *handler to a text delta window
1092 * handler; we will then call @a *handler on successive text
1093 * delta windows as we receive them. The callback should set
1094 * @a *handler_baton to the value we should pass as the @a baton
1095 * argument to @a *handler. These values should be allocated within
1096 * @a result_pool.
1097 *
1098 * @a base_checksum is the hex MD5 digest for the base text against
1099 * which the delta is being applied; it is ignored if NULL, and may
1100 * be ignored even if not NULL. If it is not ignored, it must match
1101 * the checksum of the base text against which svndiff data is being
1102 * applied; if it does not, @c apply_textdelta or the @a *handler call
1103 * which detects the mismatch will return the error
1104 * SVN_ERR_CHECKSUM_MISMATCH (if there is no base text, there may
1105 * still be an error if @a base_checksum is neither NULL nor the hex
1106 * MD5 checksum of the empty string).
1107 */
1108 svn_error_t *(*apply_textdelta)(void *file_baton,
1109 const char *base_checksum,
1110 apr_pool_t *result_pool,
1112 void **handler_baton);
1113
1114 /** Change the value of a file's property.
1115 * - @a file_baton specifies the file whose property should change.
1116 * - @a name is the name of the property to change.
1117 * - @a value is the new (final) value of the property, or @c NULL if the
1118 * property should be removed altogether.
1119 *
1120 * The callback is guaranteed to be called exactly once for each property
1121 * whose value differs between the start and the end of the edit.
1122 *
1123 * Any temporary allocations may be performed in @a scratch_pool.
1124 */
1125 svn_error_t *(*change_file_prop)(void *file_baton,
1126 const char *name,
1127 const svn_string_t *value,
1128 apr_pool_t *scratch_pool);
1129
1130 /** We are done processing a file, whose baton is @a file_baton (set by
1131 * @c add_file or @c open_file). We won't be using the baton any
1132 * more, so whatever resources it refers to may now be freed.
1133 *
1134 * @a text_checksum is the hex MD5 digest for the fulltext that
1135 * resulted from a delta application, see @c apply_textdelta and
1136 * @c apply_textdelta_stream. The checksum is ignored if NULL.
1137 * If not null, it is compared to the checksum of the new fulltext,
1138 * and the error SVN_ERR_CHECKSUM_MISMATCH is returned if they do
1139 * not match. If there is no new fulltext, @a text_checksum is ignored.
1140 *
1141 * Any temporary allocations may be performed in @a scratch_pool.
1142 */
1143 svn_error_t *(*close_file)(void *file_baton,
1144 const char *text_checksum,
1145 apr_pool_t *scratch_pool);
1146
1147 /** In the directory represented by @a parent_baton, indicate that
1148 * @a path is present as a file in the edit source, but cannot be
1149 * cannot be conveyed to the edit consumer. Currently, this would
1150 * only occur because of authorization restrictions, but may change
1151 * in the future.
1152 *
1153 * Any temporary allocations may be performed in @a scratch_pool.
1154 */
1155 svn_error_t *(*absent_file)(const char *path,
1156 void *parent_baton,
1157 apr_pool_t *scratch_pool);
1158
1159 /** All delta processing is done. Call this, with the @a edit_baton for
1160 * the entire edit.
1161 *
1162 * Any temporary allocations may be performed in @a scratch_pool.
1163 */
1164 svn_error_t *(*close_edit)(void *edit_baton,
1165 apr_pool_t *scratch_pool);
1166
1167 /** The editor-driver has decided to bail out. Allow the editor to
1168 * gracefully clean up things if it needs to.
1169 *
1170 * Any temporary allocations may be performed in @a scratch_pool.
1171 */
1172 svn_error_t *(*abort_edit)(void *edit_baton,
1173 apr_pool_t *scratch_pool);
1174
1175 /** Apply a text delta stream, yielding the new revision of a file.
1176 * This callback operates on the passed-in @a editor instance.
1177 *
1178 * @a file_baton indicates the file we're creating or updating, and the
1179 * ancestor file on which it is based; it is the baton set by some
1180 * prior @c add_file or @c open_file callback.
1181 *
1182 * @a open_func is a function that opens a #svn_txdelta_stream_t object.
1183 * @a open_baton is provided by the caller.
1184 *
1185 * @a base_checksum is the hex MD5 digest for the base text against
1186 * which the delta is being applied; it is ignored if NULL, and may
1187 * be ignored even if not NULL. If it is not ignored, it must match
1188 * the checksum of the base text against which svndiff data is being
1189 * applied; if it does not, @c apply_textdelta_stream call which detects
1190 * the mismatch will return the error #SVN_ERR_CHECKSUM_MISMATCH
1191 * (if there is no base text, there may still be an error if
1192 * @a base_checksum is neither NULL nor the hex MD5 checksum of the
1193 * empty string).
1194 *
1195 * Any temporary allocations may be performed in @a scratch_pool.
1196 *
1197 * @since New in 1.10.
1198 */
1199 svn_error_t *(*apply_textdelta_stream)(
1200 const struct svn_delta_editor_t *editor,
1201 void *file_baton,
1202 const char *base_checksum,
1204 void *open_baton,
1205 apr_pool_t *scratch_pool);
1206
1207 /* Be sure to update svn_delta_get_cancellation_editor() and
1208 * svn_delta_default_editor() if you add a new callback here. */
1209} svn_delta_editor_t;
1210
1211
1212/** Return a default delta editor template, allocated in @a pool.
1213 *
1214 * The editor functions in the template do only the most basic
1215 * baton-swapping: each editor function that produces a baton does so
1216 * by copying its incoming baton into the outgoing baton reference.
1217 *
1218 * This editor is not intended to be useful by itself, but is meant to
1219 * be the basis for a useful editor. After getting a default editor,
1220 * you substitute in your own implementations for the editor functions
1221 * you care about. The ones you don't care about, you don't have to
1222 * implement -- you can rely on the template's implementation to
1223 * safely do nothing of consequence.
1224 */
1225svn_delta_editor_t *
1227
1228/** A text-delta window handler which does nothing.
1229 *
1230 * Editors can return this handler from @c apply_textdelta if they don't
1231 * care about text delta windows.
1232 */
1235 void *baton);
1236
1237/** Set @a *editor and @a *edit_baton to a cancellation editor that
1238 * wraps @a wrapped_editor and @a wrapped_baton.
1239 *
1240 * The @a editor will call @a cancel_func with @a cancel_baton when each of
1241 * its functions is called, continuing on to call the corresponding wrapped
1242 * function if @a cancel_func returns #SVN_NO_ERROR.
1243 *
1244 * If @a cancel_func is @c NULL, set @a *editor to @a wrapped_editor and
1245 * @a *edit_baton to @a wrapped_baton.
1246 */
1249 void *cancel_baton,
1250 const svn_delta_editor_t *wrapped_editor,
1251 void *wrapped_baton,
1252 const svn_delta_editor_t **editor,
1253 void **edit_baton,
1254 apr_pool_t *pool);
1255
1256/** Set @a *editor and @a *edit_baton to an depth-based filtering
1257 * editor that wraps @a wrapped_editor and @a wrapped_baton.
1258 *
1259 * The @a editor will track the depth of this drive against the @a
1260 * requested_depth, taking into account whether not the edit drive is
1261 * making use of a target (via @a has_target), and forward editor
1262 * calls which operate "within" the request depth range through to @a
1263 * wrapped_editor.
1264 *
1265 * @a requested_depth must be one of the following depth values:
1266 * #svn_depth_infinity, #svn_depth_empty, #svn_depth_files,
1267 * #svn_depth_immediates, or #svn_depth_unknown.
1268 *
1269 * If filtering is deemed unnecessary (or if @a requested_depth is
1270 * #svn_depth_unknown), @a *editor and @a *edit_baton will be set to @a
1271 * wrapped_editor and @a wrapped_baton, respectively; otherwise,
1272 * they'll be set to new objects allocated from @a pool.
1273 *
1274 * @note Because the svn_delta_editor_t interface's @c delete_entry()
1275 * function doesn't carry node kind information, a depth-based
1276 * filtering editor being asked to filter for #svn_depth_files but
1277 * receiving a @c delete_entry() call on an immediate child of the
1278 * editor's target is unable to know if that deletion should be
1279 * allowed or filtered out -- a delete of a top-level file is okay in
1280 * this case, a delete of a top-level subdirectory is not. As such,
1281 * this filtering editor takes a conservative approach, and ignores
1282 * top-level deletion requests when filtering for #svn_depth_files.
1283 * Fortunately, most non-depth-aware (pre-1.5) Subversion editor
1284 * drivers can be told to drive non-recursively (where non-recursive
1285 * means essentially #svn_depth_files), which means they won't
1286 * transmit out-of-scope editor commands anyway.
1287 *
1288 * @since New in 1.5.
1289 */
1291svn_delta_depth_filter_editor(const svn_delta_editor_t **editor,
1292 void **edit_baton,
1293 const svn_delta_editor_t *wrapped_editor,
1294 void *wrapped_edit_baton,
1295 svn_depth_t requested_depth,
1296 svn_boolean_t has_target,
1297 apr_pool_t *pool);
1298
1299/** @} */
1300
1301␌
1302/** Path-based editor drives.
1303 *
1304 * @defgroup svn_delta_path_delta_drivers Path-based delta drivers
1305 * @{
1306 */
1307
1308/** Callback function type for svn_delta_path_driver().
1309 *
1310 * The handler of this callback is given the callback baton @a
1311 * callback_baton, @a editor and @a edit_baton which represent the
1312 * editor being driven, @a relpath which is a relpath relative to the
1313 * root of the edit, and the @a parent_baton which represents
1314 * @a relpath's parent directory as created by the editor.
1315 *
1316 * If the handler deletes the node at @a relpath (and does not replace it
1317 * with an added directory) it must set @a *dir_baton to null or leave
1318 * it unchanged.
1319 *
1320 * If the handler opens (or adds) a directory at @a relpath, it must set
1321 * @a *dir_baton to the directory baton for @a relpath, generated from
1322 * the same editor. The driver will close the directory later.
1323 *
1324 * If the handler opens (or adds) a file at @a relpath, the handler must
1325 * set @a *dir_baton to null or leave it unchanged. The handler must
1326 * either close the file immediately, or delay that close until the end
1327 * of the edit when svn_delta_path_driver() returns.
1328 *
1329 * Finally, if @a parent_baton is @c NULL, then the root of the edit
1330 * is also one of the paths passed to svn_delta_path_driver(). The
1331 * handler of this callback must call the editor's open_root()
1332 * function and return the top-level root dir baton in @a *dir_baton.
1333 *
1334 * @since New in 1.12.
1335 */
1336typedef svn_error_t *(*svn_delta_path_driver_cb_func2_t)(
1337 void **dir_baton,
1338 const svn_delta_editor_t *editor,
1339 void *edit_baton,
1340 void *parent_baton,
1341 void *callback_baton,
1342 const char *relpath,
1343 apr_pool_t *pool);
1344
1345/** Like #svn_delta_path_driver_cb_func2_t but without the @a editor and
1346 * @a edit_baton parameters. The user must arrange for the editor to be
1347 * passed through @a callback_baton (if required, which it usually is).
1348 * And @a path could possibly have a '/' prefix instead of being a relpath;
1349 * see the note on svn_delta_path_driver2().
1350 *
1351 * @deprecated Provided for backward compatibility with the 1.11 API.
1352 */
1353typedef svn_error_t *(*svn_delta_path_driver_cb_func_t)(
1354 void **dir_baton,
1355 void *parent_baton,
1356 void *callback_baton,
1357 const char *path,
1358 apr_pool_t *pool);
1359
1360
1361/** Drive @a editor (with its @a edit_baton) to visit each path in @a relpaths.
1362 *
1363 * As each path is hit as part of the editor drive, use
1364 * @a callback_func and @a callback_baton to allow the caller to handle
1365 * the portion of the editor drive related to that path.
1366 *
1367 * Each path in @a relpaths is a (const char *) relpath, relative
1368 * to the root path of the edit. The editor drive will be
1369 * performed in the same order as @a relpaths. The paths should be sorted
1370 * using something like svn_sort_compare_paths() to ensure that each
1371 * directory in the depth-first walk is visited only once. If @a sort_paths
1372 * is set, the function will sort the paths for you. Some callers may need
1373 * further customization of the order (ie. libsvn_delta/compat.c).
1374 *
1375 * If the first target path (after any requested sorting) is @c "" (the
1376 * root of the edit), the callback function will be responsible for
1377 * calling the editor's @c open_root method; otherwise, this function
1378 * will call @c open_root.
1379 *
1380 * Use @a scratch_pool for all necessary allocations.
1381 *
1382 * @since New in 1.12.
1383 */
1385svn_delta_path_driver3(const svn_delta_editor_t *editor,
1386 void *edit_baton,
1387 const apr_array_header_t *relpaths,
1388 svn_boolean_t sort_paths,
1390 void *callback_baton,
1391 apr_pool_t *pool);
1392
1393/** Like svn_delta_path_driver3() but with a different callback function
1394 * signature.
1395 *
1396 * Optionally, paths in @a paths could have a '/' prefix instead of being
1397 * relpaths. If any of them do, then (since 1.12) ALL paths sent to the
1398 * callback will have a '/' prefix.
1399 *
1400 * @deprecated Provided for backward compatibility with the 1.11 API.
1401 * @since New in 1.8. Before 1.12, paths sent to the callback were the
1402 * exact paths passed in @a paths.
1403 */
1406svn_delta_path_driver2(const svn_delta_editor_t *editor,
1407 void *edit_baton,
1408 const apr_array_header_t *paths,
1409 svn_boolean_t sort_paths,
1410 svn_delta_path_driver_cb_func_t callback_func,
1411 void *callback_baton,
1412 apr_pool_t *scratch_pool);
1413
1414
1415/** Similar to svn_delta_path_driver2, but takes an (unused) revision,
1416 * and will sort the provided @a paths using svn_sort_compare_paths.
1417 *
1418 * @note In versions prior to 1.8, this function would modify the order
1419 * of elements in @a paths, despite the 'const' marker on the parameter.
1420 * This has been fixed in 1.8.
1421 *
1422 * @deprecated Provided for backward compatibility with the 1.7 API.
1423 */
1426svn_delta_path_driver(const svn_delta_editor_t *editor,
1427 void *edit_baton,
1429 const apr_array_header_t *paths,
1430 svn_delta_path_driver_cb_func_t callback_func,
1431 void *callback_baton,
1432 apr_pool_t *scratch_pool);
1433
1434
1435/** A state object for the path driver that is obtained from
1436 * svn_delta_path_driver_start() and driven by
1437 * svn_delta_path_driver_step() and svn_delta_path_driver_finish().
1438 *
1439 * @since New in 1.12.
1440 */
1442
1443/** Return a path driver object that can drive @a editor (with its
1444 * @a edit_baton) to visit a series of paths.
1445 *
1446 * As each path is hit as part of the editor drive, the path driver will
1447 * call @a callback_func and @a callback_baton to allow the caller to handle
1448 * the portion of the editor drive related to that path.
1449 *
1450 * This will not call the editor's open_root method; for that, see
1451 * svn_delta_path_driver_step().
1452 *
1453 * @since New in 1.12.
1454 */
1457 const svn_delta_editor_t *editor,
1458 void *edit_baton,
1460 void *callback_baton,
1461 apr_pool_t *result_pool);
1462
1463/** Visit @a relpath.
1464 *
1465 * @a state is the object returned by svn_delta_path_driver_start().
1466 *
1467 * @a relpath is a relpath relative to the root path of the edit.
1468 *
1469 * This function uses the editor and the callback that were originally
1470 * supplied to svn_delta_path_driver_start().
1471 *
1472 * This drives the editor in a depth-first order, closing and then opening
1473 * directories if necessary to move from the last visited path to the new
1474 * path, as required by the editor driving rules.
1475 *
1476 * This then calls the callback to allow the caller to handle
1477 * the portion of the editor drive related to that path.
1478 *
1479 * If the first path to visit is @c "" (the root of the edit), the
1480 * callback function will be responsible for calling the editor's
1481 * @c open_root method; otherwise, this function will call @c open_root.
1482 *
1483 * The order of paths to visit should in general be sorted using something
1484 * like svn_sort_compare_paths() to ensure that each directory in the
1485 * depth-first walk is visited only once. Some editors may rely on such a
1486 * restriction.
1487 *
1488 * @since New in 1.12.
1489 */
1492 const char *relpath,
1493 apr_pool_t *scratch_pool);
1494
1495/** Finish driving the editor.
1496 *
1497 * @a state is the object returned by svn_delta_path_driver_start().
1498 *
1499 * This drives the editor to close any open directories and then calls
1500 * the editor's @c close_edit method.
1501 *
1502 * @since New in 1.12.
1503 */
1506 apr_pool_t *scratch_pool);
1507
1508/** @} */
1509
1510␌
1511/*** File revision iterator types ***/
1512
1513/**
1514 * The callback invoked by file rev loopers, such as
1515 * svn_ra_plugin_t.get_file_revs2() and svn_repos_get_file_revs2().
1516 *
1517 * @a baton is provided by the caller, @a path is the pathname of the file
1518 * in revision @a rev and @a rev_props are the revision properties.
1519 *
1520 * If @a delta_handler and @a delta_baton are non-NULL, they may be set to a
1521 * handler/baton which will be called with the delta between the previous
1522 * revision and this one after the return of this callback. They may be
1523 * left as NULL/NULL.
1524 *
1525 * @a result_of_merge will be @c TRUE if the revision being returned was
1526 * included as the result of a merge.
1527 *
1528 * @a prop_diffs is an array of svn_prop_t elements indicating the property
1529 * delta for this and the previous revision.
1530 *
1531 * @a pool may be used for temporary allocations, but you can't rely
1532 * on objects allocated to live outside of this particular call and
1533 * the immediately following calls to @a *delta_handler if any. (Pass
1534 * in a pool via @a baton if need be.)
1535 *
1536 * @since New in 1.5.
1537 */
1538typedef svn_error_t *(*svn_file_rev_handler_t)(
1539 void *baton,
1540 const char *path,
1541 svn_revnum_t rev,
1542 apr_hash_t *rev_props,
1543 svn_boolean_t result_of_merge,
1544 svn_txdelta_window_handler_t *delta_handler,
1545 void **delta_baton,
1546 apr_array_header_t *prop_diffs,
1547 apr_pool_t *pool);
1548
1549/**
1550 * The old file rev handler interface.
1551 *
1552 * @note #svn_file_rev_handler_old_t is a placeholder type for both
1553 * #svn_repos_file_rev_handler_t and #svn_ra_file_rev_handler_t. It is
1554 * reproduced here for dependency reasons.
1555 *
1556 * @deprecated This type is provided for the svn_compat_wrap_file_rev_handler()
1557 * compatibility wrapper, and should not be used for new development.
1558 * @since New in 1.5.
1559 */
1560typedef svn_error_t *(*svn_file_rev_handler_old_t)(
1561 void *baton,
1562 const char *path,
1563 svn_revnum_t rev,
1564 apr_hash_t *rev_props,
1565 svn_txdelta_window_handler_t *delta_handler,
1566 void **delta_baton,
1567 apr_array_header_t *prop_diffs,
1568 apr_pool_t *pool);
1569
1570/** Return, in @a *handler2 and @a *handler2_baton a function/baton that
1571 * will call @a handler/@a handler_baton, allocating the @a *handler2_baton
1572 * in @a pool.
1573 *
1574 * @note This is used by compatibility wrappers, which exist in more than
1575 * Subversion core library.
1576 *
1577 * @note #svn_file_rev_handler_old_t is a placeholder type for both
1578 * #svn_repos_file_rev_handler_t and #svn_ra_file_rev_handler_t. It is
1579 * reproduced here for dependency reasons.
1580 *
1581 * @since New in 1.5.
1582 */
1583void
1585 void **handler2_baton,
1587 void *handler_baton,
1588 apr_pool_t *pool);
1589
1590/** @} end group: delta_support */
1591
1592␌
1593#ifdef __cplusplus
1594}
1595#endif /* __cplusplus */
1596
1597#endif /* SVN_DELTA_H */
svn_error_t *(* svn_file_rev_handler_t)(void *baton, const char *path, svn_revnum_t rev, apr_hash_t *rev_props, svn_boolean_t result_of_merge, svn_txdelta_window_handler_t *delta_handler, void **delta_baton, apr_array_header_t *prop_diffs, apr_pool_t *pool)
The callback invoked by file rev loopers, such as svn_ra_plugin_t.get_file_revs2() and svn_repos_get_...
Definition svn_delta.h:1538
svn_error_t *(* svn_file_rev_handler_old_t)(void *baton, const char *path, svn_revnum_t rev, apr_hash_t *rev_props, svn_txdelta_window_handler_t *delta_handler, void **delta_baton, apr_array_header_t *prop_diffs, apr_pool_t *pool)
The old file rev handler interface.
Definition svn_delta.h:1560
void svn_compat_wrap_file_rev_handler(svn_file_rev_handler_t *handler2, void **handler2_baton, svn_file_rev_handler_old_t handler, void *handler_baton, apr_pool_t *pool)
Return, in *handler2 and *handler2_baton a function/baton that will call handler/handler_baton,...
svn_error_t * svn_delta_path_driver3(const svn_delta_editor_t *editor, void *edit_baton, const apr_array_header_t *relpaths, svn_boolean_t sort_paths, svn_delta_path_driver_cb_func2_t callback_func, void *callback_baton, apr_pool_t *pool)
Drive editor (with its edit_baton) to visit each path in relpaths.
svn_error_t * svn_delta_path_driver(const svn_delta_editor_t *editor, void *edit_baton, svn_revnum_t revision, const apr_array_header_t *paths, svn_delta_path_driver_cb_func_t callback_func, void *callback_baton, apr_pool_t *scratch_pool)
Similar to svn_delta_path_driver2, but takes an (unused) revision, and will sort the provided paths u...
svn_error_t * svn_delta_path_driver_step(svn_delta_path_driver_state_t *state, const char *relpath, apr_pool_t *scratch_pool)
Visit relpath.
svn_error_t * svn_delta_path_driver_finish(svn_delta_path_driver_state_t *state, apr_pool_t *scratch_pool)
Finish driving the editor.
svn_error_t *(* svn_delta_path_driver_cb_func_t)(void **dir_baton, void *parent_baton, void *callback_baton, const char *path, apr_pool_t *pool)
Like svn_delta_path_driver_cb_func2_t but without the editor and edit_baton parameters.
Definition svn_delta.h:1353
struct svn_delta_path_driver_state_t svn_delta_path_driver_state_t
A state object for the path driver that is obtained from svn_delta_path_driver_start() and driven by ...
Definition svn_delta.h:1441
svn_error_t *(* svn_delta_path_driver_cb_func2_t)(void **dir_baton, const svn_delta_editor_t *editor, void *edit_baton, void *parent_baton, void *callback_baton, const char *relpath, apr_pool_t *pool)
Callback function type for svn_delta_path_driver().
Definition svn_delta.h:1336
svn_error_t * svn_delta_path_driver2(const svn_delta_editor_t *editor, void *edit_baton, const apr_array_header_t *paths, svn_boolean_t sort_paths, svn_delta_path_driver_cb_func_t callback_func, void *callback_baton, apr_pool_t *scratch_pool)
Like svn_delta_path_driver3() but with a different callback function signature.
svn_error_t * svn_delta_path_driver_start(svn_delta_path_driver_state_t **state_p, const svn_delta_editor_t *editor, void *edit_baton, svn_delta_path_driver_cb_func2_t callback_func, void *callback_baton, apr_pool_t *result_pool)
Return a path driver object that can drive editor (with its edit_baton) to visit a series of paths.
svn_error_t * svn_delta_noop_window_handler(svn_txdelta_window_t *window, void *baton)
A text-delta window handler which does nothing.
svn_error_t * svn_delta_depth_filter_editor(const svn_delta_editor_t **editor, void **edit_baton, const svn_delta_editor_t *wrapped_editor, void *wrapped_edit_baton, svn_depth_t requested_depth, svn_boolean_t has_target, apr_pool_t *pool)
Set *editor and *edit_baton to an depth-based filtering editor that wraps wrapped_editor and wrapped_...
svn_delta_editor_t * svn_delta_default_editor(apr_pool_t *pool)
Return a default delta editor template, allocated in pool.
svn_error_t * svn_delta_get_cancellation_editor(svn_cancel_func_t cancel_func, void *cancel_baton, const svn_delta_editor_t *wrapped_editor, void *wrapped_baton, const svn_delta_editor_t **editor, void **edit_baton, apr_pool_t *pool)
Set *editor and *edit_baton to a cancellation editor that wraps wrapped_editor and wrapped_baton.
void svn_txdelta_to_svndiff(svn_stream_t *output, apr_pool_t *pool, svn_txdelta_window_handler_t *handler, void **handler_baton)
Similar to svn_txdelta_to_svndiff2, but always using svndiff version 0.
void svn_txdelta2(svn_txdelta_stream_t **stream, svn_stream_t *source, svn_stream_t *target, svn_boolean_t calculate_checksum, apr_pool_t *pool)
Set *stream to a pointer to a delta stream that will turn the byte string from source into the byte s...
svn_txdelta_window_t * svn_txdelta_window_dup(const svn_txdelta_window_t *window, apr_pool_t *pool)
Return a deep copy of window, allocated in pool.
svn_error_t * svn_txdelta_send_contents(const unsigned char *contents, apr_size_t len, svn_txdelta_window_handler_t handler, void *handler_baton, apr_pool_t *pool)
Send the contents of length len as a txdelta against an empty source directly to window-handler handl...
svn_txdelta_stream_t * svn_txdelta_stream_create(void *baton, svn_txdelta_next_window_fn_t next_window, svn_txdelta_md5_digest_fn_t md5_digest, apr_pool_t *pool)
Create and return a generic text delta stream with baton, next_window and md5_digest.
svn_error_t * svn_txdelta_send_stream(svn_stream_t *stream, svn_txdelta_window_handler_t handler, void *handler_baton, unsigned char *digest, apr_pool_t *pool)
Send the contents of stream to window-handler handler/baton.
svn_error_t * svn_txdelta_run(svn_stream_t *source, svn_stream_t *target, svn_txdelta_window_handler_t handler, void *handler_baton, svn_checksum_kind_t checksum_kind, svn_checksum_t **checksum, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
This function will generate delta windows that turn source into target, and pushing these windows int...
svn_error_t * svn_txdelta_skip_svndiff_window(apr_file_t *file, int svndiff_version, apr_pool_t *pool)
Read and skip one delta window in svndiff format from the file file.
svn_txdelta_window_t * svn_txdelta_compose_windows(const svn_txdelta_window_t *window_A, const svn_txdelta_window_t *window_B, apr_pool_t *pool)
Compose two delta windows, yielding a third, allocated in pool.
void svn_txdelta_apply_instructions(svn_txdelta_window_t *window, const char *sbuf, char *tbuf, apr_size_t *tlen)
Apply the instructions from window to a source view sbuf to produce a target view tbuf.
svn_stream_t * svn_txdelta_target_push(svn_txdelta_window_handler_t handler, void *handler_baton, svn_stream_t *source, apr_pool_t *pool)
Return a writable stream which, when fed target data, will send delta windows to handler/handler_bato...
void svn_txdelta_apply2(svn_stream_t *source, svn_stream_t *target, unsigned char *result_digest, const char *error_info, apr_pool_t *pool, svn_txdelta_window_handler_t *handler, void **handler_baton)
Prepare to apply a text delta.
void svn_txdelta(svn_txdelta_stream_t **stream, svn_stream_t *source, svn_stream_t *target, apr_pool_t *pool)
Similar to svn_txdelta2 but always calculating the target checksum.
void svn_txdelta_apply(svn_stream_t *source, svn_stream_t *target, unsigned char *result_digest, const char *error_info, apr_pool_t *pool, svn_txdelta_window_handler_t *handler, void **handler_baton)
Similar to svn_txdelta_apply2(), but the source stream is NOT closed.
svn_error_t * svn_txdelta_send_string(const svn_string_t *string, svn_txdelta_window_handler_t handler, void *handler_baton, apr_pool_t *pool)
Send the contents of string to window-handler handler/baton.
svn_stream_t * svn_txdelta_to_svndiff_stream(svn_txdelta_stream_t *txstream, int svndiff_version, int compression_level, apr_pool_t *pool)
Return a readable generic stream which will produce svndiff-encoded text delta from the delta stream ...
const unsigned char *(* svn_txdelta_md5_digest_fn_t)(void *baton)
A typedef for a function that will return the md5 checksum of the fulltext deltified by a svn_txdelta...
Definition svn_delta.h:331
svn_error_t * svn_txdelta_send_txstream(svn_txdelta_stream_t *txstream, svn_txdelta_window_handler_t handler, void *handler_baton, apr_pool_t *pool)
Send the contents of txstream to window-handler handler/baton.
svn_error_t * svn_txdelta_next_window(svn_txdelta_window_t **window, svn_txdelta_stream_t *stream, apr_pool_t *pool)
Set *window to a pointer to the next window from the delta stream stream.
void svn_txdelta_to_svndiff3(svn_txdelta_window_handler_t *handler, void **handler_baton, svn_stream_t *output, int svndiff_version, int compression_level, apr_pool_t *pool)
Prepare to produce an svndiff-format diff from text delta windows.
svn_error_t *(* svn_txdelta_next_window_fn_t)(svn_txdelta_window_t **window, void *baton, apr_pool_t *pool)
A typedef for a function that will set *window to the next window from a svn_txdelta_stream_t object.
Definition svn_delta.h:317
svn_error_t * svn_txdelta_read_svndiff_window(svn_txdelta_window_t **window, svn_stream_t *stream, int svndiff_version, apr_pool_t *pool)
Read and parse one delta window in svndiff format from the readable stream stream and place it in *wi...
svn_error_t *(* svn_txdelta_stream_open_func_t)(svn_txdelta_stream_t **txdelta_stream, void *baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
A typedef for a function that opens an svn_txdelta_stream_t object, allocated in result_pool.
Definition svn_delta.h:340
svn_stream_t * svn_txdelta_parse_svndiff(svn_txdelta_window_handler_t handler, void *handler_baton, svn_boolean_t error_on_early_close, apr_pool_t *pool)
Return a writable generic stream which will parse svndiff-format data into a text delta,...
svn_delta_action
Action codes for text delta instructions.
Definition svn_delta.h:116
svn_error_t *(* svn_txdelta_window_handler_t)(svn_txdelta_window_t *window, void *baton)
A typedef for functions that consume a series of delta windows, for use in caller-pushes interfaces.
Definition svn_delta.h:265
struct svn_txdelta_stream_t svn_txdelta_stream_t
A delta stream — this is the hat from which we pull a series of svn_txdelta_window_t objects,...
Definition svn_delta.h:305
void svn_txdelta_to_svndiff2(svn_txdelta_window_handler_t *handler, void **handler_baton, svn_stream_t *output, int svndiff_version, apr_pool_t *pool)
Similar to svn_txdelta_to_svndiff3(), but always using the SVN default compression level (SVN_DELTA_C...
const unsigned char * svn_txdelta_md5_digest(svn_txdelta_stream_t *stream)
Return the md5 digest for the complete fulltext deltified by stream, or NULL if stream has not yet re...
@ svn_txdelta_target
Append the length bytes at offset in the target view, to the target.
Definition svn_delta.h:145
@ svn_txdelta_new
Append the length bytes at offset in the window's new string to the target.
Definition svn_delta.h:155
@ svn_txdelta_source
Append the length bytes at offset in the source view to the target.
Definition svn_delta.h:126
struct svn_stream_t svn_stream_t
An abstract stream of bytes–either incoming or outgoing or both.
Definition svn_io.h:863
apr_hash_t * rev_props
If action is svn_wc_notify_blame_revision, contains a list of revision properties for the specified r...
Definition svn_wc.h:1485
svn_revnum_t revision
When action is svn_wc_notify_update_completed, target revision of the update, or SVN_INVALID_REVNUM i...
Definition svn_wc.h:1455
const char * path
Structure used in the svn_wc_notify_func2_t function.
Definition svn_wc.h:1416
A generic checksum representation.
Subversion error object.
Definition svn_types.h:177
A simple counted string.
Definition svn_string.h:97
A single text delta instruction.
Definition svn_delta.h:160
apr_size_t offset
Offset of delta, see svn_delta_action for more details.
Definition svn_delta.h:164
apr_size_t length
Number of bytes of delta, see svn_delta_action for more details.
Definition svn_delta.h:166
enum svn_delta_action action_code
Action code of delta instruction.
Definition svn_delta.h:162
An svn_txdelta_window_t object describes how to reconstruct a contiguous section of the target string...
Definition svn_delta.h:189
svn_filesize_t sview_offset
The offset of the source view for this window.
Definition svn_delta.h:192
apr_size_t sview_len
The length of the source view for this window.
Definition svn_delta.h:195
apr_size_t tview_len
The length of the target view for this window, i.e.
Definition svn_delta.h:199
const svn_txdelta_op_t * ops
The instructions for this window.
Definition svn_delta.h:211
int src_ops
The number of svn_txdelta_source instructions in this window.
Definition svn_delta.h:208
int num_ops
The number of instructions in this window.
Definition svn_delta.h:202
Version information.
Subversion checksum routines.
svn_checksum_kind_t
Various types of checksums.
const svn_version_t * svn_delta_version(void)
Get libsvn_delta version information.
General file I/O for Subversion.
Counted-length strings for Subversion, plus some C string goodies.
Subversion's data types.
int svn_boolean_t
YABT: Yet Another Boolean Type.
Definition svn_types.h:137
apr_int64_t svn_filesize_t
The size of a file in the Subversion FS.
Definition svn_types.h:430
svn_error_t *(* svn_cancel_func_t)(void *cancel_baton)
A user defined callback that subversion will call with a user defined baton to see if the current ope...
Definition svn_types.h:1081
#define SVN_DEPRECATED
Macro used to mark deprecated functions.
Definition svn_types.h:62
svn_depth_t
The concept of depth for directories.
long int svn_revnum_t
A revision number.