Subversion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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
46 extern "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  */
77 const svn_version_t *
78 svn_delta_version(void);
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. */
159 typedef 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  */
188 typedef struct svn_txdelta_window_t
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. */
202  int num_ops;
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  */
208  int src_ops;
209 
210  /** The instructions for this window. */
212 
213  /** New data, for use by any `svn_txdelta_new' instructions. */
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  */
253 void
255  const char *sbuf, char *tbuf,
256  apr_size_t *tlen);
257 
258 /** A typedef for functions that consume a series of delta windows, for
259  * use in caller-pushes interfaces. Such functions will typically
260  * apply the delta windows to produce some file, or save the windows
261  * somewhere. At the end of the delta window stream, you must call
262  * this function passing zero for the @a window argument.
263  */
264 typedef svn_error_t *(*svn_txdelta_window_handler_t)(
265  svn_txdelta_window_t *window, void *baton);
266 
267 
268 /** This function will generate delta windows that turn @a source into
269  * @a target, and pushing these windows into the @a handler window handler
270  * callback (passing @a handler_baton to each invocation).
271  *
272  * If @a checksum is not NULL, then a checksum (of kind @a checksum_kind)
273  * will be computed for the target stream, and placed into *checksum.
274  *
275  * If @a cancel_func is not NULL, then it should refer to a cancellation
276  * function (along with @a cancel_baton).
277  *
278  * Results (the checksum) will be allocated from @a result_pool, and all
279  * temporary allocations will be performed in @a scratch_pool.
280  *
281  * Note: this function replaces the combination of svn_txdelta() and
282  * svn_txdelta_send_txstream().
283  *
284  * @since New in 1.6.
285  */
286 svn_error_t *
288  svn_stream_t *target,
290  void *handler_baton,
291  svn_checksum_kind_t checksum_kind,
292  svn_checksum_t **checksum,
293  svn_cancel_func_t cancel_func,
294  void *cancel_baton,
295  apr_pool_t *result_pool,
296  apr_pool_t *scratch_pool);
297 
298 
299 /** A delta stream --- this is the hat from which we pull a series of
300  * svn_txdelta_window_t objects, which, taken in order, describe the
301  * entire target string. This type is defined within libsvn_delta, and
302  * opaque outside that library.
303  */
305 
306 
307 /** A typedef for a function that will set @a *window to the next
308  * window from a #svn_txdelta_stream_t object. If there are no more
309  * delta windows, NULL will be used. The returned window, if any,
310  * will be allocated in @a pool. @a baton is the baton specified
311  * when the stream was created.
312  *
313  * @since New in 1.4.
314  */
315 typedef svn_error_t *
316 (*svn_txdelta_next_window_fn_t)(svn_txdelta_window_t **window,
317  void *baton,
318  apr_pool_t *pool);
319 
320 /** A typedef for a function that will return the md5 checksum of the
321  * fulltext deltified by a #svn_txdelta_stream_t object. Will
322  * return NULL if the final null window hasn't yet been returned by
323  * the stream. The returned value will be allocated in the same pool
324  * as the stream. @a baton is the baton specified when the stream was
325  * created.
326  *
327  * @since New in 1.4.
328  */
329 typedef const unsigned char *
330 (*svn_txdelta_md5_digest_fn_t)(void *baton);
331 
332 /** Create and return a generic text delta stream with @a baton, @a
333  * next_window and @a md5_digest. Allocate the new stream in @a
334  * pool.
335  *
336  * @since New in 1.4.
337  */
339 svn_txdelta_stream_create(void *baton,
340  svn_txdelta_next_window_fn_t next_window,
341  svn_txdelta_md5_digest_fn_t md5_digest,
342  apr_pool_t *pool);
343 
344 /** Set @a *window to a pointer to the next window from the delta stream
345  * @a stream. When we have completely reconstructed the target string,
346  * set @a *window to zero.
347  *
348  * The window will be allocated in @a pool.
349  */
350 svn_error_t *
352  svn_txdelta_stream_t *stream,
353  apr_pool_t *pool);
354 
355 
356 /** Return the md5 digest for the complete fulltext deltified by
357  * @a stream, or @c NULL if @a stream has not yet returned its final
358  * @c NULL window. The digest is allocated in the same memory as @a
359  * STREAM.
360  */
361 const unsigned char *
363 
364 /** Set @a *stream to a pointer to a delta stream that will turn the byte
365  * string from @a source into the byte stream from @a target.
366  *
367  * @a source and @a target are both readable generic streams. When we call
368  * svn_txdelta_next_window() on @a *stream, it will read from @a source and
369  * @a target to gather as much data as it needs.
370  *
371  * Do any necessary allocation in a sub-pool of @a pool.
372  */
373 void
375  svn_stream_t *source,
376  svn_stream_t *target,
377  apr_pool_t *pool);
378 
379 
380 /**
381  * Return a writable stream which, when fed target data, will send
382  * delta windows to @a handler/@a handler_baton which transform the
383  * data in @a source to the target data. As usual, the window handler
384  * will receive a NULL window to signify the end of the window stream.
385  * The stream handler functions will read data from @a source as
386  * necessary.
387  *
388  * @since New in 1.1.
389  */
390 svn_stream_t *
392  void *handler_baton,
393  svn_stream_t *source,
394  apr_pool_t *pool);
395 
396 
397 /** Send the contents of @a string to window-handler @a handler/@a baton.
398  * This is effectively a 'copy' operation, resulting in delta windows that
399  * make the target equivalent to the value of @a string.
400  *
401  * All temporary allocation is performed in @a pool.
402  */
403 svn_error_t *
406  void *handler_baton,
407  apr_pool_t *pool);
408 
409 /** Send the contents of @a stream to window-handler @a handler/@a baton.
410  * This is effectively a 'copy' operation, resulting in delta windows that
411  * make the target equivalent to the stream.
412  *
413  * If @a digest is non-NULL, populate it with the md5 checksum for the
414  * fulltext that was deltified (@a digest must be at least
415  * @c APR_MD5_DIGESTSIZE bytes long).
416  *
417  * All temporary allocation is performed in @a pool.
418  */
419 svn_error_t *
422  void *handler_baton,
423  unsigned char *digest,
424  apr_pool_t *pool);
425 
426 /** Send the contents of @a txstream to window-handler @a handler/@a baton.
427  * Windows will be extracted from the stream and delivered to the handler.
428  *
429  * All temporary allocation is performed in @a pool.
430  */
431 svn_error_t *
434  void *handler_baton,
435  apr_pool_t *pool);
436 
437 
438 /** Prepare to apply a text delta. @a source is a readable generic stream
439  * yielding the source data, @a target is a writable generic stream to
440  * write target data to, and allocation takes place in a sub-pool of
441  * @a pool. On return, @a *handler is set to a window handler function and
442  * @a *handler_baton is set to the value to pass as the @a baton argument to
443  * @a *handler.
444  *
445  * If @a result_digest is non-NULL, it points to APR_MD5_DIGESTSIZE bytes
446  * of storage, and the final call to @a handler populates it with the
447  * MD5 digest of the resulting fulltext.
448  *
449  * If @a error_info is non-NULL, it is inserted parenthetically into
450  * the error string for any error returned by svn_txdelta_apply() or
451  * @a *handler. (It is normally used to provide path information,
452  * since there's nothing else in the delta application's context to
453  * supply a path for error messages.)
454  *
455  * @note To avoid lifetime issues, @a error_info is copied into
456  * @a pool or a subpool thereof.
457  */
458 void
460  svn_stream_t *target,
461  unsigned char *result_digest,
462  const char *error_info,
463  apr_pool_t *pool,
465  void **handler_baton);
466 
467 
468 
469 /*** Producing and consuming svndiff-format text deltas. ***/
470 
471 /** Prepare to produce an svndiff-format diff from text delta windows.
472  * @a output is a writable generic stream to write the svndiff data to.
473  * Allocation takes place in a sub-pool of @a pool. On return, @a *handler
474  * is set to a window handler function and @a *handler_baton is set to
475  * the value to pass as the @a baton argument to @a *handler. The svndiff
476  * version is @a svndiff_version. @a compression_level is the zlib
477  * compression level from 0 (no compression) and 9 (maximum compression).
478  *
479  * @since New in 1.7.
480  */
481 void
483  void **handler_baton,
484  svn_stream_t *output,
485  int svndiff_version,
486  int compression_level,
487  apr_pool_t *pool);
488 
489 /** Similar to svn_txdelta_to_svndiff3(), but always using the SVN default
490  * compression level (#SVN_DELTA_COMPRESSION_LEVEL_DEFAULT).
491  *
492  * @since New in 1.4.
493  * @deprecated Provided for backward compatibility with the 1.6 API.
494  */
496 void
498  void **handler_baton,
499  svn_stream_t *output,
500  int svndiff_version,
501  apr_pool_t *pool);
502 
503 /** Similar to svn_txdelta_to_svndiff2, but always using svndiff
504  * version 0.
505  *
506  * @deprecated Provided for backward compatibility with the 1.3 API.
507  */
509 void
511  apr_pool_t *pool,
513  void **handler_baton);
514 
515 /** Return a writable generic stream which will parse svndiff-format
516  * data into a text delta, invoking @a handler with @a handler_baton
517  * whenever a new window is ready. If @a error_on_early_close is @c
518  * TRUE, attempting to close this stream before it has handled the entire
519  * svndiff data set will result in #SVN_ERR_SVNDIFF_UNEXPECTED_END,
520  * else this error condition will be ignored.
521  */
522 svn_stream_t *
524  void *handler_baton,
525  svn_boolean_t error_on_early_close,
526  apr_pool_t *pool);
527 
528 /**
529  * Read and parse one delta window in svndiff format from the
530  * readable stream @a stream and place it in @a *window, allocating
531  * the result in @a pool. The caller must take responsibility for
532  * stripping off the four-byte 'SVN@<ver@>' header at the beginning of
533  * the svndiff document before reading the first window, and must
534  * provide the version number (the value of the fourth byte) to each
535  * invocation of this routine with the @a svndiff_version argument.
536  *
537  * @since New in 1.1.
538  */
539 svn_error_t *
541  svn_stream_t *stream,
542  int svndiff_version,
543  apr_pool_t *pool);
544 
545 /**
546  * Read and skip one delta window in svndiff format from the
547  * file @a file. @a pool is used for temporary allocations. The
548  * caller must take responsibility for stripping off the four-byte
549  * 'SVN@<ver@>' header at the beginning of the svndiff document before
550  * reading or skipping the first window, and must provide the version
551  * number (the value of the fourth byte) to each invocation of this
552  * routine with the @a svndiff_version argument.
553  *
554  * @since New in 1.1.
555  */
556 svn_error_t *
557 svn_txdelta_skip_svndiff_window(apr_file_t *file,
558  int svndiff_version,
559  apr_pool_t *pool);
560 
561 /** @} */
562 
563 
564 /** Traversing tree deltas.
565  *
566  * In Subversion, we've got various producers and consumers of tree
567  * deltas.
568  *
569  * In processing a `commit' command:
570  * - The client examines its working copy data, and produces a tree
571  * delta describing the changes to be committed.
572  * - The client networking library consumes that delta, and sends them
573  * across the wire as an equivalent series of network requests (for
574  * example, to svnserve as an ra_svn protocol stream, or to an
575  * Apache httpd server as WebDAV commands)
576  * - The server receives those requests and produces a tree delta ---
577  * hopefully equivalent to the one the client produced above.
578  * - The Subversion server module consumes that delta and commits an
579  * appropriate transaction to the filesystem.
580  *
581  * In processing an `update' command, the process is reversed:
582  * - The Subversion server module talks to the filesystem and produces
583  * a tree delta describing the changes necessary to bring the
584  * client's working copy up to date.
585  * - The server consumes this delta, and assembles a reply
586  * representing the appropriate changes.
587  * - The client networking library receives that reply, and produces a
588  * tree delta --- hopefully equivalent to the one the Subversion
589  * server produced above.
590  * - The working copy library consumes that delta, and makes the
591  * appropriate changes to the working copy.
592  *
593  * The simplest approach would be to represent tree deltas using the
594  * obvious data structure. To do an update, the server would
595  * construct a delta structure, and the working copy library would
596  * apply that structure to the working copy; the network layer's job
597  * would simply be to get the structure across the net intact.
598  *
599  * However, we expect that these deltas will occasionally be too large
600  * to fit in a typical workstation's swap area. For example, in
601  * checking out a 200Mb source tree, the entire source tree is
602  * represented by a single tree delta. So it's important to handle
603  * deltas that are too large to fit in swap all at once.
604  *
605  * So instead of representing the tree delta explicitly, we define a
606  * standard way for a consumer to process each piece of a tree delta
607  * as soon as the producer creates it. The #svn_delta_editor_t
608  * structure is a set of callback functions to be defined by a delta
609  * consumer, and invoked by a delta producer. Each invocation of a
610  * callback function describes a piece of the delta --- a file's
611  * contents changing, something being renamed, etc.
612  *
613  * @defgroup svn_delta_tree_deltas Tree deltas
614  * @{
615  */
616 
617 /** A structure full of callback functions the delta source will invoke
618  * as it produces the delta.
619  *
620  * @note Don't try to allocate one of these yourself. Instead, always
621  * use svn_delta_default_editor() or some other constructor, to ensure
622  * that unused slots are filled in with no-op functions.
623  *
624  * <h3>Function Usage</h3>
625  *
626  * Here's how to use these functions to express a tree delta.
627  *
628  * The delta consumer implements the callback functions described in
629  * this structure, and the delta producer invokes them. So the
630  * caller (producer) is pushing tree delta data at the callee
631  * (consumer).
632  *
633  * At the start of traversal, the consumer provides @a edit_baton, a
634  * baton global to the entire delta edit. If there is a target
635  * revision that needs to be set for this operation, the producer
636  * should call the @c set_target_revision function at this point.
637  *
638  * Next, if there are any tree deltas to express, the producer should
639  * pass the @a edit_baton to the @c open_root function, to get a baton
640  * representing root of the tree being edited.
641  *
642  * Most of the callbacks work in the obvious way:
643  *
644  * @c delete_entry
645  * @c add_file
646  * @c add_directory
647  * @c open_file
648  * @c open_directory
649  *
650  * Each of these takes a directory baton, indicating the directory
651  * in which the change takes place, and a @a path argument, giving the
652  * path (relative to the root of the edit) of the file,
653  * subdirectory, or directory entry to change. Editors will usually
654  * want to join this relative path with some base stored in the edit
655  * baton (e.g. a URL, a location in the OS filesystem).
656  *
657  * Since every call requires a parent directory baton, including
658  * @c add_directory and @c open_directory, where do we ever get our
659  * initial directory baton, to get things started? The @c open_root
660  * function returns a baton for the top directory of the change. In
661  * general, the producer needs to invoke the editor's @c open_root
662  * function before it can get anything of interest done.
663  *
664  * While @c open_root provides a directory baton for the root of
665  * the tree being changed, the @c add_directory and @c open_directory
666  * callbacks provide batons for other directories. Like the
667  * callbacks above, they take a @a parent_baton and a relative path
668  * @a path, and then return a new baton for the subdirectory being
669  * created / modified --- @a child_baton. The producer can then use
670  * @a child_baton to make further changes in that subdirectory.
671  *
672  * So, if we already have subdirectories named `foo' and `foo/bar',
673  * then the producer can create a new file named `foo/bar/baz.c' by
674  * calling:
675  *
676  * - @c open_root () --- yielding a baton @a root for the top directory
677  *
678  * - @c open_directory (@a root, "foo") --- yielding a baton @a f for `foo'
679  *
680  * - @c open_directory (@a f, "foo/bar") --- yielding a baton @a b for
681  * `foo/bar'
682  *
683  * - @c add_file (@a b, "foo/bar/baz.c")
684  *
685  * When the producer is finished making changes to a directory, it
686  * should call @c close_directory. This lets the consumer do any
687  * necessary cleanup, and free the baton's storage.
688  *
689  * The @c add_file and @c open_file callbacks each return a baton
690  * for the file being created or changed. This baton can then be
691  * passed to @c apply_textdelta to change the file's contents, or
692  * @c change_file_prop to change the file's properties. When the
693  * producer is finished making changes to a file, it should call
694  * @c close_file, to let the consumer clean up and free the baton.
695  *
696  * The @c add_file and @c add_directory functions each take arguments
697  * @a copyfrom_path and @a copyfrom_revision. If @a copyfrom_path is
698  * non-@c NULL, then @a copyfrom_path and @a copyfrom_revision indicate where
699  * the file or directory should be copied from (to create the file
700  * or directory being added). In that case, @a copyfrom_path must be
701  * either a path relative to the root of the edit, or a URI from the
702  * repository being edited. If @a copyfrom_path is @c NULL, then @a
703  * copyfrom_revision must be #SVN_INVALID_REVNUM; it is invalid to
704  * pass a mix of valid and invalid copyfrom arguments.
705  *
706  *
707  * <h3>Function Call Ordering</h3>
708  *
709  * There are six restrictions on the order in which the producer
710  * may use the batons:
711  *
712  * 1. The producer may call @c open_directory, @c add_directory,
713  * @c open_file, @c add_file at most once on any given directory
714  * entry. @c delete_entry may be called at most once on any given
715  * directory entry and may later be followed by @c add_directory or
716  * @c add_file on the same directory entry. @c delete_entry may
717  * not be called on any directory entry after @c open_directory,
718  * @c add_directory, @c open_file or @c add_file has been called on
719  * that directory entry.
720  *
721  * 2. The producer may not close a directory baton until it has
722  * closed all batons for its subdirectories.
723  *
724  * 3. When a producer calls @c open_directory or @c add_directory,
725  * it must specify the most recently opened of the currently open
726  * directory batons. Put another way, the producer cannot have
727  * two sibling directory batons open at the same time.
728  *
729  * 4. A producer must call @c change_dir_prop on a directory either
730  * before opening any of the directory's subdirs or after closing
731  * them, but not in the middle.
732  *
733  * 5. When the producer calls @c open_file or @c add_file, either:
734  *
735  * (a) The producer must follow with any changes to the file
736  * (@c change_file_prop and/or @c apply_textdelta, as applicable),
737  * followed by a @c close_file call, before issuing any other file
738  * or directory calls, or
739  *
740  * (b) The producer must follow with a @c change_file_prop call if
741  * it is applicable, before issuing any other file or directory
742  * calls; later, after all directory batons including the root
743  * have been closed, the producer must issue @c apply_textdelta
744  * and @c close_file calls.
745  *
746  * 6. When the producer calls @c apply_textdelta, it must make all of
747  * the window handler calls (including the @c NULL window at the
748  * end) before issuing any other #svn_delta_editor_t calls.
749  *
750  * So, the producer needs to use directory and file batons as if it
751  * is doing a single depth-first traversal of the tree, with the
752  * exception that the producer may keep file batons open in order to
753  * make @c apply_textdelta calls at the end.
754  *
755  *
756  * <h3>Pool Usage</h3>
757  *
758  * Many editor functions are invoked multiple times, in a sequence
759  * determined by the editor "driver". The driver is responsible for
760  * creating a pool for use on each iteration of the editor function,
761  * and clearing that pool between each iteration. The driver passes
762  * the appropriate pool on each function invocation.
763  *
764  * Based on the requirement of calling the editor functions in a
765  * depth-first style, it is usually customary for the driver to similarly
766  * nest the pools. However, this is only a safety feature to ensure
767  * that pools associated with deeper items are always cleared when the
768  * top-level items are also cleared. The interface does not assume, nor
769  * require, any particular organization of the pools passed to these
770  * functions. In fact, if "postfix deltas" are used for files, the file
771  * pools definitely need to live outside the scope of their parent
772  * directories' pools.
773  *
774  * Note that close_directory can be called *before* a file in that
775  * directory has been closed. That is, the directory's baton is
776  * closed before the file's baton. The implication is that
777  * @c apply_textdelta and @c close_file should not refer to a parent
778  * directory baton UNLESS the editor has taken precautions to
779  * allocate it in a pool of the appropriate lifetime (the @a dir_pool
780  * passed to @c open_directory and @c add_directory definitely does not
781  * have the proper lifetime). In general, it is recommended to simply
782  * avoid keeping a parent directory baton in a file baton.
783  *
784  *
785  * <h3>Errors</h3>
786  *
787  * At least one implementation of the editor interface is
788  * asynchronous; an error from one operation may be detected some
789  * number of operations later. As a result, an editor driver must not
790  * assume that an error from an editing function resulted from the
791  * particular operation being detected. Moreover, once an editing
792  * function returns an error, the edit is dead; the only further
793  * operation which may be called on the editor is abort_edit.
794  */
795 typedef struct svn_delta_editor_t
796 {
797  /** Set the target revision for this edit to @a target_revision. This
798  * call, if used, should precede all other editor calls.
799  *
800  * @note This is typically used only for server->client update-type
801  * operations. It doesn't really make much sense for commit-type
802  * operations, because the revision of a commit isn't known until
803  * the commit is finalized.
804  *
805  * Any temporary allocations may be performed in @a scratch_pool.
806  */
807  svn_error_t *(*set_target_revision)(void *edit_baton,
808  svn_revnum_t target_revision,
809  apr_pool_t *scratch_pool);
810 
811  /** Set @a *root_baton to a baton for the top directory of the change.
812  * (This is the top of the subtree being changed, not necessarily
813  * the root of the filesystem.) As with any other directory baton, the
814  * producer should call @c close_directory on @a root_baton when done.
815  * And as with other @c open_* calls, the @a base_revision here is the
816  * current revision of the directory (before getting bumped up to the
817  * new target revision set with @c set_target_revision).
818  *
819  * Allocations for the returned @a root_baton should be performed in
820  * @a result_pool. It is also typical to (possibly) save this pool for
821  * later usage by @c close_directory.
822  */
823  svn_error_t *(*open_root)(void *edit_baton,
824  svn_revnum_t base_revision,
825  apr_pool_t *result_pool,
826  void **root_baton);
827 
828 
829  /** Remove the directory entry named @a path, a child of the directory
830  * represented by @a parent_baton. If @a revision is a valid
831  * revision number, it is used as a sanity check to ensure that you
832  * are really removing the revision of @a path that you think you are.
833  *
834  * Any temporary allocations may be performed in @a scratch_pool.
835  *
836  * @note The @a revision parameter is typically used only for
837  * client->server commit-type operations, allowing the server to
838  * verify that it is deleting what the client thinks it should be
839  * deleting. It only really makes sense in the opposite direction
840  * (during server->client update-type operations) when the trees
841  * whose delta is being described are ancestrally related (that is,
842  * one tree is an ancestor of the other).
843  */
844  svn_error_t *(*delete_entry)(const char *path,
845  svn_revnum_t revision,
846  void *parent_baton,
847  apr_pool_t *scratch_pool);
848 
849 
850  /** We are going to add a new subdirectory named @a path. We will use
851  * the value this callback stores in @a *child_baton as the
852  * @a parent_baton for further changes in the new subdirectory.
853  *
854  * If @a copyfrom_path is non-@c NULL, this add has history (i.e., is a
855  * copy), and the origin of the copy may be recorded as
856  * @a copyfrom_path under @a copyfrom_revision.
857  *
858  * Allocations for the returned @a child_baton should be performed in
859  * @a result_pool. It is also typical to (possibly) save this pool for
860  * later usage by @c close_directory.
861  */
862  svn_error_t *(*add_directory)(const char *path,
863  void *parent_baton,
864  const char *copyfrom_path,
865  svn_revnum_t copyfrom_revision,
866  apr_pool_t *result_pool,
867  void **child_baton);
868 
869  /** We are going to make changes in a subdirectory (of the directory
870  * identified by @a parent_baton). The subdirectory is specified by
871  * @a path. The callback must store a value in @a *child_baton that
872  * should be used as the @a parent_baton for subsequent changes in this
873  * subdirectory. If a valid revnum, @a base_revision is the current
874  * revision of the subdirectory.
875  *
876  * Allocations for the returned @a child_baton should be performed in
877  * @a result_pool. It is also typical to (possibly) save this pool for
878  * later usage by @c close_directory.
879  */
880  svn_error_t *(*open_directory)(const char *path,
881  void *parent_baton,
882  svn_revnum_t base_revision,
883  apr_pool_t *result_pool,
884  void **child_baton);
885 
886  /** Change the value of a directory's property.
887  * - @a dir_baton specifies the directory whose property should change.
888  * - @a name is the name of the property to change.
889  * - @a value is the new (final) value of the property, or @c NULL if the
890  * property should be removed altogether.
891  *
892  * The callback is guaranteed to be called exactly once for each property
893  * whose value differs between the start and the end of the edit.
894  *
895  * Any temporary allocations may be performed in @a scratch_pool.
896  */
897  svn_error_t *(*change_dir_prop)(void *dir_baton,
898  const char *name,
899  const svn_string_t *value,
900  apr_pool_t *scratch_pool);
901 
902  /** We are done processing a subdirectory, whose baton is @a dir_baton
903  * (set by @c add_directory or @c open_directory). We won't be using
904  * the baton any more, so whatever resources it refers to may now be
905  * freed.
906  *
907  * Any temporary allocations may be performed in @a scratch_pool.
908  */
909  svn_error_t *(*close_directory)(void *dir_baton,
910  apr_pool_t *scratch_pool);
911 
912 
913  /** In the directory represented by @a parent_baton, indicate that
914  * @a path is present as a subdirectory in the edit source, but
915  * cannot be conveyed to the edit consumer (perhaps because of
916  * authorization restrictions).
917  *
918  * Any temporary allocations may be performed in @a scratch_pool.
919  */
920  svn_error_t *(*absent_directory)(const char *path,
921  void *parent_baton,
922  apr_pool_t *scratch_pool);
923 
924  /** We are going to add a new file named @a path. The callback can
925  * store a baton for this new file in @a **file_baton; whatever value
926  * it stores there should be passed through to @c apply_textdelta.
927  *
928  * If @a copyfrom_path is non-@c NULL, this add has history (i.e., is a
929  * copy), and the origin of the copy may be recorded as
930  * @a copyfrom_path under @a copyfrom_revision.
931  *
932  * Allocations for the returned @a file_baton should be performed in
933  * @a result_pool. It is also typical to save this pool for later usage
934  * by @c apply_textdelta and possibly @c close_file.
935  *
936  * @note Because the editor driver could be employing the "postfix
937  * deltas" paradigm, @a result_pool could potentially be relatively
938  * long-lived. Every file baton created by the editor for a given
939  * editor drive might be resident in memory similtaneously. Editor
940  * implementations should ideally keep their file batons as
941  * conservative (memory-usage-wise) as possible, and use @a result_pool
942  * only for those batons. (Consider using a subpool of @a result_pool
943  * for scratch work, destroying the subpool before exiting this
944  * function's implementation.)
945  */
946  svn_error_t *(*add_file)(const char *path,
947  void *parent_baton,
948  const char *copyfrom_path,
949  svn_revnum_t copyfrom_revision,
950  apr_pool_t *result_pool,
951  void **file_baton);
952 
953  /** We are going to make change to a file named @a path, which resides
954  * in the directory identified by @a parent_baton.
955  *
956  * The callback can store a baton for this new file in @a **file_baton;
957  * whatever value it stores there should be passed through to
958  * @c apply_textdelta. If a valid revnum, @a base_revision is the
959  * current revision of the file.
960  *
961  * Allocations for the returned @a file_baton should be performed in
962  * @a result_pool. It is also typical to save this pool for later usage
963  * by @c apply_textdelta and possibly @c close_file.
964  *
965  * @note See note about memory usage on @a add_file, which also
966  * applies here.
967  */
968  svn_error_t *(*open_file)(const char *path,
969  void *parent_baton,
970  svn_revnum_t base_revision,
971  apr_pool_t *result_pool,
972  void **file_baton);
973 
974  /** Apply a text delta, yielding the new revision of a file.
975  *
976  * @a file_baton indicates the file we're creating or updating, and the
977  * ancestor file on which it is based; it is the baton set by some
978  * prior @c add_file or @c open_file callback.
979  *
980  * The callback should set @a *handler to a text delta window
981  * handler; we will then call @a *handler on successive text
982  * delta windows as we receive them. The callback should set
983  * @a *handler_baton to the value we should pass as the @a baton
984  * argument to @a *handler. These values should be allocated within
985  * @a result_pool.
986  *
987  * @a base_checksum is the hex MD5 digest for the base text against
988  * which the delta is being applied; it is ignored if NULL, and may
989  * be ignored even if not NULL. If it is not ignored, it must match
990  * the checksum of the base text against which svndiff data is being
991  * applied; if it does not, @c apply_textdelta or the @a *handler call
992  * which detects the mismatch will return the error
993  * SVN_ERR_CHECKSUM_MISMATCH (if there is no base text, there may
994  * still be an error if @a base_checksum is neither NULL nor the hex
995  * MD5 checksum of the empty string).
996  */
997  svn_error_t *(*apply_textdelta)(void *file_baton,
998  const char *base_checksum,
999  apr_pool_t *result_pool,
1001  void **handler_baton);
1002 
1003  /** Change the value of a file's property.
1004  * - @a file_baton specifies the file whose property should change.
1005  * - @a name is the name of the property to change.
1006  * - @a value is the new (final) value of the property, or @c NULL if the
1007  * property should be removed altogether.
1008  *
1009  * The callback is guaranteed to be called exactly once for each property
1010  * whose value differs between the start and the end of the edit.
1011  *
1012  * Any temporary allocations may be performed in @a scratch_pool.
1013  */
1014  svn_error_t *(*change_file_prop)(void *file_baton,
1015  const char *name,
1016  const svn_string_t *value,
1017  apr_pool_t *scratch_pool);
1018 
1019  /** We are done processing a file, whose baton is @a file_baton (set by
1020  * @c add_file or @c open_file). We won't be using the baton any
1021  * more, so whatever resources it refers to may now be freed.
1022  *
1023  * @a text_checksum is the hex MD5 digest for the fulltext that
1024  * resulted from a delta application, see @c apply_textdelta. The
1025  * checksum is ignored if NULL. If not null, it is compared to the
1026  * checksum of the new fulltext, and the error
1027  * SVN_ERR_CHECKSUM_MISMATCH is returned if they do not match. If
1028  * there is no new fulltext, @a text_checksum is ignored.
1029  *
1030  * Any temporary allocations may be performed in @a scratch_pool.
1031  */
1032  svn_error_t *(*close_file)(void *file_baton,
1033  const char *text_checksum,
1034  apr_pool_t *scratch_pool);
1035 
1036  /** In the directory represented by @a parent_baton, indicate that
1037  * @a path is present as a file in the edit source, but cannot be
1038  * conveyed to the edit consumer (perhaps because of authorization
1039  * restrictions).
1040  *
1041  * Any temporary allocations may be performed in @a scratch_pool.
1042  */
1043  svn_error_t *(*absent_file)(const char *path,
1044  void *parent_baton,
1045  apr_pool_t *scratch_pool);
1046 
1047  /** All delta processing is done. Call this, with the @a edit_baton for
1048  * the entire edit.
1049  *
1050  * Any temporary allocations may be performed in @a scratch_pool.
1051  */
1052  svn_error_t *(*close_edit)(void *edit_baton,
1053  apr_pool_t *scratch_pool);
1054 
1055  /** The editor-driver has decided to bail out. Allow the editor to
1056  * gracefully clean up things if it needs to.
1057  *
1058  * Any temporary allocations may be performed in @a scratch_pool.
1059  */
1060  svn_error_t *(*abort_edit)(void *edit_baton,
1061  apr_pool_t *scratch_pool);
1062 
1063  /* Be sure to update svn_delta_get_cancellation_editor() and
1064  * svn_delta_default_editor() if you add a new callback here. */
1066 
1067 
1068 /** Return a default delta editor template, allocated in @a pool.
1069  *
1070  * The editor functions in the template do only the most basic
1071  * baton-swapping: each editor function that produces a baton does so
1072  * by copying its incoming baton into the outgoing baton reference.
1073  *
1074  * This editor is not intended to be useful by itself, but is meant to
1075  * be the basis for a useful editor. After getting a default editor,
1076  * you substitute in your own implementations for the editor functions
1077  * you care about. The ones you don't care about, you don't have to
1078  * implement -- you can rely on the template's implementation to
1079  * safely do nothing of consequence.
1080  */
1082 svn_delta_default_editor(apr_pool_t *pool);
1083 
1084 /** A text-delta window handler which does nothing.
1085  *
1086  * Editors can return this handler from @c apply_textdelta if they don't
1087  * care about text delta windows.
1088  */
1089 svn_error_t *
1091  void *baton);
1092 
1093 /** Set @a *editor and @a *edit_baton to a cancellation editor that
1094  * wraps @a wrapped_editor and @a wrapped_baton.
1095  *
1096  * The @a editor will call @a cancel_func with @a cancel_baton when each of
1097  * its functions is called, continuing on to call the corresponding wrapped
1098  * function if @a cancel_func returns #SVN_NO_ERROR.
1099  *
1100  * If @a cancel_func is @c NULL, set @a *editor to @a wrapped_editor and
1101  * @a *edit_baton to @a wrapped_baton.
1102  */
1103 svn_error_t *
1105  void *cancel_baton,
1106  const svn_delta_editor_t *wrapped_editor,
1107  void *wrapped_baton,
1108  const svn_delta_editor_t **editor,
1109  void **edit_baton,
1110  apr_pool_t *pool);
1111 
1112 /** Set @a *editor and @a *edit_baton to an depth-based filtering
1113  * editor that wraps @a wrapped_editor and @a wrapped_baton.
1114  *
1115  * The @a editor will track the depth of this drive against the @a
1116  * requested_depth, taking into account whether not the edit drive is
1117  * making use of a target (via @a has_target), and forward editor
1118  * calls which operate "within" the request depth range through to @a
1119  * wrapped_editor.
1120  *
1121  * @a requested_depth must be one of the following depth values:
1122  * #svn_depth_infinity, #svn_depth_empty, #svn_depth_files,
1123  * #svn_depth_immediates, or #svn_depth_unknown.
1124  *
1125  * If filtering is deemed unnecessary (or if @a requested_depth is
1126  * #svn_depth_unknown), @a *editor and @a *edit_baton will be set to @a
1127  * wrapped_editor and @a wrapped_baton, respectively; otherwise,
1128  * they'll be set to new objects allocated from @a pool.
1129  *
1130  * @note Because the svn_delta_editor_t interface's @c delete_entry()
1131  * function doesn't carry node kind information, a depth-based
1132  * filtering editor being asked to filter for #svn_depth_files but
1133  * receiving a @c delete_entry() call on an immediate child of the
1134  * editor's target is unable to know if that deletion should be
1135  * allowed or filtered out -- a delete of a top-level file is okay in
1136  * this case, a delete of a top-level subdirectory is not. As such,
1137  * this filtering editor takes a conservative approach, and ignores
1138  * top-level deletion requests when filtering for #svn_depth_files.
1139  * Fortunately, most non-depth-aware (pre-1.5) Subversion editor
1140  * drivers can be told to drive non-recursively (where non-recursive
1141  * means essentially #svn_depth_files), which means they won't
1142  * transmit out-of-scope editor commands anyway.
1143  *
1144  * @since New in 1.5.
1145  */
1146 svn_error_t *
1148  void **edit_baton,
1149  const svn_delta_editor_t *wrapped_editor,
1150  void *wrapped_edit_baton,
1151  svn_depth_t requested_depth,
1152  svn_boolean_t has_target,
1153  apr_pool_t *pool);
1154 
1155 /** @} */
1156 
1157 
1158 /** Path-based editor drives.
1159  *
1160  * @defgroup svn_delta_path_delta_drivers Path-based delta drivers
1161  * @{
1162  */
1163 
1164 /** Callback function type for svn_delta_path_driver().
1165  *
1166  * The handler of this callback is given the callback baton @a
1167  * callback_baton, @a path, and the @a parent_baton which represents
1168  * path's parent directory as created by the editor passed to
1169  * svn_delta_path_driver().
1170  *
1171  * If @a path represents a directory, the handler must return a @a
1172  * *dir_baton for @a path, generated from the same editor (so that the
1173  * driver can later close that directory).
1174  *
1175  * If, however, @a path represents a file, the handler should NOT
1176  * return any file batons. It can close any opened or added files
1177  * immediately, or delay that close until the end of the edit when
1178  * svn_delta_path_driver() returns.
1179  *
1180  * Finally, if @a parent_baton is @c NULL, then the root of the edit
1181  * is also one of the paths passed to svn_delta_path_driver(). The
1182  * handler of this callback must call the editor's open_root()
1183  * function and return the top-level root dir baton in @a *dir_baton.
1184  */
1185 typedef svn_error_t *(*svn_delta_path_driver_cb_func_t)(
1186  void **dir_baton,
1187  void *parent_baton,
1188  void *callback_baton,
1189  const char *path,
1190  apr_pool_t *pool);
1191 
1192 
1193 /** Drive @a editor (with its @a edit_baton) in such a way that
1194  * each path in @a paths is traversed in a depth-first fashion. As
1195  * each path is hit as part of the editor drive, use @a
1196  * callback_func and @a callback_baton to allow the caller to handle
1197  * the portion of the editor drive related to that path.
1198  *
1199  * Use @a revision as the revision number passed to intermediate
1200  * directory openings.
1201  *
1202  * Use @a pool for all necessary allocations.
1203  */
1204 svn_error_t *
1206  void *edit_baton,
1207  svn_revnum_t revision,
1208  const apr_array_header_t *paths,
1209  svn_delta_path_driver_cb_func_t callback_func,
1210  void *callback_baton,
1211  apr_pool_t *pool);
1212 
1213 /** @} */
1214 
1215 
1216 /*** File revision iterator types ***/
1217 
1218 /**
1219  * The callback invoked by file rev loopers, such as
1220  * svn_ra_plugin_t.get_file_revs2() and svn_repos_get_file_revs2().
1221  *
1222  * @a baton is provided by the caller, @a path is the pathname of the file
1223  * in revision @a rev and @a rev_props are the revision properties.
1224  *
1225  * If @a delta_handler and @a delta_baton are non-NULL, they may be set to a
1226  * handler/baton which will be called with the delta between the previous
1227  * revision and this one after the return of this callback. They may be
1228  * left as NULL/NULL.
1229  *
1230  * @a result_of_merge will be @c TRUE if the revision being returned was
1231  * included as the result of a merge.
1232  *
1233  * @a prop_diffs is an array of svn_prop_t elements indicating the property
1234  * delta for this and the previous revision.
1235  *
1236  * @a pool may be used for temporary allocations, but you can't rely
1237  * on objects allocated to live outside of this particular call and
1238  * the immediately following calls to @a *delta_handler if any. (Pass
1239  * in a pool via @a baton if need be.)
1240  *
1241  * @since New in 1.5.
1242  */
1243 typedef svn_error_t *(*svn_file_rev_handler_t)(
1244  void *baton,
1245  const char *path,
1246  svn_revnum_t rev,
1247  apr_hash_t *rev_props,
1248  svn_boolean_t result_of_merge,
1249  svn_txdelta_window_handler_t *delta_handler,
1250  void **delta_baton,
1251  apr_array_header_t *prop_diffs,
1252  apr_pool_t *pool);
1253 
1254 /**
1255  * The old file rev handler interface.
1256  *
1257  * @note #svn_file_rev_handler_old_t is a placeholder type for both
1258  * #svn_repos_file_rev_handler_t and #svn_ra_file_rev_handler_t. It is
1259  * reproduced here for dependency reasons.
1260  *
1261  * @deprecated This type is provided for the svn_compat_wrap_file_rev_handler()
1262  * compatibility wrapper, and should not be used for new development.
1263  * @since New in 1.5.
1264  */
1265 typedef svn_error_t *(*svn_file_rev_handler_old_t)(
1266  void *baton,
1267  const char *path,
1268  svn_revnum_t rev,
1269  apr_hash_t *rev_props,
1270  svn_txdelta_window_handler_t *delta_handler,
1271  void **delta_baton,
1272  apr_array_header_t *prop_diffs,
1273  apr_pool_t *pool);
1274 
1275 /** Return, in @a *handler2 and @a *handler2_baton a function/baton that
1276  * will call @a handler/@a handler_baton, allocating the @a *handler2_baton
1277  * in @a pool.
1278  *
1279  * @note This is used by compatibility wrappers, which exist in more than
1280  * Subversion core library.
1281  *
1282  * @note #svn_file_rev_handler_old_t is a placeholder type for both
1283  * #svn_repos_file_rev_handler_t and #svn_ra_file_rev_handler_t. It is
1284  * reproduced here for dependency reasons.
1285  *
1286  * @since New in 1.5.
1287  */
1288 void
1290  void **handler2_baton,
1292  void *handler_baton,
1293  apr_pool_t *pool);
1294 
1295 /** @} end group: delta_support */
1296 
1297 
1298 #ifdef __cplusplus
1299 }
1300 #endif /* __cplusplus */
1301 
1302 #endif /* SVN_DELTA_H */
Counted-length strings for Subversion, plus some C string goodies.
svn_depth_t
The concept of depth for directories.
Definition: svn_types.h:397
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_checksum_kind_t
Various types of checksums.
Definition: svn_checksum.h:45
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...
int num_ops
The number of instructions in this window.
Definition: svn_delta.h:202
struct svn_delta_editor_t svn_delta_editor_t
A structure full of callback functions the delta source will invoke as it produces the delta...
apr_size_t offset
Offset of delta, see svn_delta_action for more details.
Definition: svn_delta.h:164
General file I/O for Subversion.
Subversion checksum routines.
apr_size_t tview_len
The length of the target view for this window, i.e.
Definition: svn_delta.h:199
int src_ops
The number of svn_txdelta_source instructions in this window.
Definition: svn_delta.h:208
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.
enum svn_delta_action action_code
Action code of delta instruction.
Definition: svn_delta.h:162
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...
A structure full of callback functions the delta source will invoke as it produces the delta...
Definition: svn_delta.h:795
const svn_txdelta_op_t * ops
The instructions for this window.
Definition: svn_delta.h:211
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_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.
svn_delta_action
Action codes for text delta instructions.
Definition: svn_delta.h:116
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:330
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...
A simple counted string.
Definition: svn_string.h:96
void svn_txdelta(svn_txdelta_stream_t **stream, svn_stream_t *source, svn_stream_t *target, 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...
Append the length bytes at offset in the window&#39;s new string to the target.
Definition: svn_delta.h:155
Subversion error object.
Definition: svn_types.h:90
struct svn_txdelta_window_t svn_txdelta_window_t
An svn_txdelta_window_t object describes how to reconstruct a contiguous section of the target string...
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:304
A single text delta instruction.
Definition: svn_delta.h:159
apr_int64_t svn_filesize_t
The size of a file in the Subversion FS.
Definition: svn_types.h:353
apr_size_t length
Number of bytes of delta, see svn_delta_action for more details.
Definition: svn_delta.h:166
apr_size_t sview_len
The length of the source view for this window.
Definition: svn_delta.h:195
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:316
svn_delta_editor_t * svn_delta_default_editor(apr_pool_t *pool)
Return a default delta editor template, allocated in pool.
Append the length bytes at offset in the target view, to the target.
Definition: svn_delta.h:145
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_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:264
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...
struct svn_txdelta_op_t svn_txdelta_op_t
A single text delta instruction.
Version information.
Definition: svn_version.h:150
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:1265
svn_error_t * svn_delta_noop_window_handler(svn_txdelta_window_t *window, void *baton)
A text-delta window handler which does nothing.
struct svn_stream_t svn_stream_t
An abstract stream of bytes–either incoming or outgoing or both.
Definition: svn_io.h:743
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 *pool)
Drive editor (with its edit_baton) in such a way that each path in paths is traversed in a depth-firs...
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_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.
Subversion&#39;s data types.
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.
A generic checksum representation.
Definition: svn_checksum.h:59
#define SVN_DEPRECATED
Macro used to mark deprecated functions.
Definition: svn_types.h:58
svn_filesize_t sview_offset
The offset of the source view for this window.
Definition: svn_delta.h:192
const svn_string_t * new_data
New data, for use by any `svn_txdelta_new&#39; instructions.
Definition: svn_delta.h:214
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:1050
long int svn_revnum_t
About Special Files in Subversion.
Definition: svn_types.h:307
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_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:1243
Append the length bytes at offset in the source view to the target.
Definition: svn_delta.h:126
const svn_version_t * svn_delta_version(void)
Get libsvn_delta version information.
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)
Callback function type for svn_delta_path_driver().
Definition: svn_delta.h:1185
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.
int svn_boolean_t
YABT: Yet Another Boolean Type.
Definition: svn_types.h:370
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...
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.
An svn_txdelta_window_t object describes how to reconstruct a contiguous section of the target string...
Definition: svn_delta.h:188
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)
Prepare to apply a text delta.
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...
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...
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.
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, allocating the *handler2_baton in pool.