GME  13
svn_delta.h
Go to the documentation of this file.
00001 
00027 /* ==================================================================== */
00028 
00029 
00030 
00031 #ifndef SVN_DELTA_H
00032 #define SVN_DELTA_H
00033 
00034 #include <apr.h>
00035 #include <apr_pools.h>
00036 #include <apr_hash.h>
00037 #include <apr_tables.h>
00038 #include <apr_file_io.h>  /* for apr_file_t */
00039 
00040 #include "svn_types.h"
00041 #include "svn_string.h"
00042 #include "svn_io.h"
00043 #include "svn_checksum.h"
00044 
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif /* __cplusplus */
00048 
00049 
00050 
00056 #define SVN_DELTA_COMPRESSION_LEVEL_NONE 0
00057 
00062 #define SVN_DELTA_COMPRESSION_LEVEL_MAX 9
00063 
00070 #define SVN_DELTA_COMPRESSION_LEVEL_DEFAULT 5
00071 
00077 const svn_version_t *
00078 svn_delta_version(void);
00079 
00116 enum svn_delta_action {
00117     /* Note: The svndiff implementation relies on the values assigned in
00118      * this enumeration matching the instruction encoding values. */
00119 
00126     svn_txdelta_source,
00127 
00145     svn_txdelta_target,
00146 
00155     svn_txdelta_new
00156 };
00157 
00159 typedef struct svn_txdelta_op_t
00160 {
00162   enum svn_delta_action action_code;
00164   apr_size_t offset;
00166   apr_size_t length;
00167 } svn_txdelta_op_t;
00168 
00169 
00188 typedef struct svn_txdelta_window_t
00189 {
00190 
00192   svn_filesize_t sview_offset;
00193 
00195   apr_size_t sview_len;
00196 
00199   apr_size_t tview_len;
00200 
00202   int num_ops;
00203 
00208   int src_ops;
00209 
00211   const svn_txdelta_op_t *ops;
00212 
00214   const svn_string_t *new_data;
00215 
00216 } svn_txdelta_window_t;
00217 
00223 svn_txdelta_window_t *
00224 svn_txdelta_window_dup(const svn_txdelta_window_t *window,
00225                        apr_pool_t *pool);
00226 
00233 svn_txdelta_window_t *
00234 svn_txdelta_compose_windows(const svn_txdelta_window_t *window_A,
00235                             const svn_txdelta_window_t *window_B,
00236                             apr_pool_t *pool);
00237 
00253 void
00254 svn_txdelta_apply_instructions(svn_txdelta_window_t *window,
00255                                const char *sbuf, char *tbuf,
00256                                apr_size_t *tlen);
00257 
00264 typedef svn_error_t *(*svn_txdelta_window_handler_t)(
00265   svn_txdelta_window_t *window, void *baton);
00266 
00267 
00286 svn_error_t *
00287 svn_txdelta_run(svn_stream_t *source,
00288                 svn_stream_t *target,
00289                 svn_txdelta_window_handler_t handler,
00290                 void *handler_baton,
00291                 svn_checksum_kind_t checksum_kind,
00292                 svn_checksum_t **checksum,
00293                 svn_cancel_func_t cancel_func,
00294                 void *cancel_baton,
00295                 apr_pool_t *result_pool,
00296                 apr_pool_t *scratch_pool);
00297 
00298 
00304 typedef struct svn_txdelta_stream_t svn_txdelta_stream_t;
00305 
00306 
00315 typedef svn_error_t *
00316 (*svn_txdelta_next_window_fn_t)(svn_txdelta_window_t **window,
00317                                 void *baton,
00318                                 apr_pool_t *pool);
00319 
00329 typedef const unsigned char *
00330 (*svn_txdelta_md5_digest_fn_t)(void *baton);
00331 
00338 svn_txdelta_stream_t *
00339 svn_txdelta_stream_create(void *baton,
00340                           svn_txdelta_next_window_fn_t next_window,
00341                           svn_txdelta_md5_digest_fn_t md5_digest,
00342                           apr_pool_t *pool);
00343 
00350 svn_error_t *
00351 svn_txdelta_next_window(svn_txdelta_window_t **window,
00352                         svn_txdelta_stream_t *stream,
00353                         apr_pool_t *pool);
00354 
00355 
00361 const unsigned char *
00362 svn_txdelta_md5_digest(svn_txdelta_stream_t *stream);
00363 
00377 void
00378 svn_txdelta2(svn_txdelta_stream_t **stream,
00379              svn_stream_t *source,
00380              svn_stream_t *target,
00381              svn_boolean_t calculate_checksum,
00382              apr_pool_t *pool);
00383 
00388 SVN_DEPRECATED
00389 void
00390 svn_txdelta(svn_txdelta_stream_t **stream,
00391             svn_stream_t *source,
00392             svn_stream_t *target,
00393             apr_pool_t *pool);
00394 
00395 
00406 svn_stream_t *
00407 svn_txdelta_target_push(svn_txdelta_window_handler_t handler,
00408                         void *handler_baton,
00409                         svn_stream_t *source,
00410                         apr_pool_t *pool);
00411 
00412 
00419 svn_error_t *
00420 svn_txdelta_send_string(const svn_string_t *string,
00421                         svn_txdelta_window_handler_t handler,
00422                         void *handler_baton,
00423                         apr_pool_t *pool);
00424 
00435 svn_error_t *
00436 svn_txdelta_send_stream(svn_stream_t *stream,
00437                         svn_txdelta_window_handler_t handler,
00438                         void *handler_baton,
00439                         unsigned char *digest,
00440                         apr_pool_t *pool);
00441 
00447 svn_error_t *
00448 svn_txdelta_send_txstream(svn_txdelta_stream_t *txstream,
00449                           svn_txdelta_window_handler_t handler,
00450                           void *handler_baton,
00451                           apr_pool_t *pool);
00452 
00453 
00461 svn_error_t *
00462 svn_txdelta_send_contents(const unsigned char *contents,
00463                           apr_size_t len,
00464                           svn_txdelta_window_handler_t handler,
00465                           void *handler_baton,
00466                           apr_pool_t *pool);
00467 
00488 void
00489 svn_txdelta_apply(svn_stream_t *source,
00490                   svn_stream_t *target,
00491                   unsigned char *result_digest,
00492                   const char *error_info,
00493                   apr_pool_t *pool,
00494                   svn_txdelta_window_handler_t *handler,
00495                   void **handler_baton);
00496 
00497 
00498 
00499 
00500 /*** Producing and consuming svndiff-format text deltas.  ***/
00501 
00512 void
00513 svn_txdelta_to_svndiff3(svn_txdelta_window_handler_t *handler,
00514                         void **handler_baton,
00515                         svn_stream_t *output,
00516                         int svndiff_version,
00517                         int compression_level,
00518                         apr_pool_t *pool);
00519 
00526 SVN_DEPRECATED
00527 void
00528 svn_txdelta_to_svndiff2(svn_txdelta_window_handler_t *handler,
00529                         void **handler_baton,
00530                         svn_stream_t *output,
00531                         int svndiff_version,
00532                         apr_pool_t *pool);
00533 
00539 SVN_DEPRECATED
00540 void
00541 svn_txdelta_to_svndiff(svn_stream_t *output,
00542                        apr_pool_t *pool,
00543                        svn_txdelta_window_handler_t *handler,
00544                        void **handler_baton);
00545 
00553 svn_stream_t *
00554 svn_txdelta_parse_svndiff(svn_txdelta_window_handler_t handler,
00555                           void *handler_baton,
00556                           svn_boolean_t error_on_early_close,
00557                           apr_pool_t *pool);
00558 
00570 svn_error_t *
00571 svn_txdelta_read_svndiff_window(svn_txdelta_window_t **window,
00572                                 svn_stream_t *stream,
00573                                 int svndiff_version,
00574                                 apr_pool_t *pool);
00575 
00587 svn_error_t *
00588 svn_txdelta_skip_svndiff_window(apr_file_t *file,
00589                                 int svndiff_version,
00590                                 apr_pool_t *pool);
00591 
00594 
00829 typedef struct svn_delta_editor_t
00830 {
00841   svn_error_t *(*set_target_revision)(void *edit_baton,
00842                                       svn_revnum_t target_revision,
00843                                       apr_pool_t *scratch_pool);
00844 
00857   svn_error_t *(*open_root)(void *edit_baton,
00858                             svn_revnum_t base_revision,
00859                             apr_pool_t *result_pool,
00860                             void **root_baton);
00861 
00862 
00878   svn_error_t *(*delete_entry)(const char *path,
00879                                svn_revnum_t revision,
00880                                void *parent_baton,
00881                                apr_pool_t *scratch_pool);
00882 
00883 
00897   svn_error_t *(*add_directory)(const char *path,
00898                                 void *parent_baton,
00899                                 const char *copyfrom_path,
00900                                 svn_revnum_t copyfrom_revision,
00901                                 apr_pool_t *result_pool,
00902                                 void **child_baton);
00903 
00915   svn_error_t *(*open_directory)(const char *path,
00916                                  void *parent_baton,
00917                                  svn_revnum_t base_revision,
00918                                  apr_pool_t *result_pool,
00919                                  void **child_baton);
00920 
00932   svn_error_t *(*change_dir_prop)(void *dir_baton,
00933                                   const char *name,
00934                                   const svn_string_t *value,
00935                                   apr_pool_t *scratch_pool);
00936 
00944   svn_error_t *(*close_directory)(void *dir_baton,
00945                                   apr_pool_t *scratch_pool);
00946 
00947 
00956   svn_error_t *(*absent_directory)(const char *path,
00957                                    void *parent_baton,
00958                                    apr_pool_t *scratch_pool);
00959 
00983   svn_error_t *(*add_file)(const char *path,
00984                            void *parent_baton,
00985                            const char *copyfrom_path,
00986                            svn_revnum_t copyfrom_revision,
00987                            apr_pool_t *result_pool,
00988                            void **file_baton);
00989 
01005   svn_error_t *(*open_file)(const char *path,
01006                             void *parent_baton,
01007                             svn_revnum_t base_revision,
01008                             apr_pool_t *result_pool,
01009                             void **file_baton);
01010 
01034   svn_error_t *(*apply_textdelta)(void *file_baton,
01035                                   const char *base_checksum,
01036                                   apr_pool_t *result_pool,
01037                                   svn_txdelta_window_handler_t *handler,
01038                                   void **handler_baton);
01039 
01051   svn_error_t *(*change_file_prop)(void *file_baton,
01052                                    const char *name,
01053                                    const svn_string_t *value,
01054                                    apr_pool_t *scratch_pool);
01055 
01069   svn_error_t *(*close_file)(void *file_baton,
01070                              const char *text_checksum,
01071                              apr_pool_t *scratch_pool);
01072 
01081   svn_error_t *(*absent_file)(const char *path,
01082                               void *parent_baton,
01083                               apr_pool_t *scratch_pool);
01084 
01090   svn_error_t *(*close_edit)(void *edit_baton,
01091                              apr_pool_t *scratch_pool);
01092 
01098   svn_error_t *(*abort_edit)(void *edit_baton,
01099                              apr_pool_t *scratch_pool);
01100 
01101   /* Be sure to update svn_delta_get_cancellation_editor() and
01102    * svn_delta_default_editor() if you add a new callback here. */
01103 } svn_delta_editor_t;
01104 
01105 
01119 svn_delta_editor_t *
01120 svn_delta_default_editor(apr_pool_t *pool);
01121 
01127 svn_error_t *
01128 svn_delta_noop_window_handler(svn_txdelta_window_t *window,
01129                               void *baton);
01130 
01141 svn_error_t *
01142 svn_delta_get_cancellation_editor(svn_cancel_func_t cancel_func,
01143                                   void *cancel_baton,
01144                                   const svn_delta_editor_t *wrapped_editor,
01145                                   void *wrapped_baton,
01146                                   const svn_delta_editor_t **editor,
01147                                   void **edit_baton,
01148                                   apr_pool_t *pool);
01149 
01184 svn_error_t *
01185 svn_delta_depth_filter_editor(const svn_delta_editor_t **editor,
01186                               void **edit_baton,
01187                               const svn_delta_editor_t *wrapped_editor,
01188                               void *wrapped_edit_baton,
01189                               svn_depth_t requested_depth,
01190                               svn_boolean_t has_target,
01191                               apr_pool_t *pool);
01192 
01195 
01224 typedef svn_error_t *(*svn_delta_path_driver_cb_func_t)(
01225   void **dir_baton,
01226   void *parent_baton,
01227   void *callback_baton,
01228   const char *path,
01229   apr_pool_t *pool);
01230 
01231 
01249 svn_error_t *
01250 svn_delta_path_driver2(const svn_delta_editor_t *editor,
01251                        void *edit_baton,
01252                        const apr_array_header_t *paths,
01253                        svn_boolean_t sort_paths,
01254                        svn_delta_path_driver_cb_func_t callback_func,
01255                        void *callback_baton,
01256                        apr_pool_t *scratch_pool);
01257 
01258 
01268 SVN_DEPRECATED
01269 svn_error_t *
01270 svn_delta_path_driver(const svn_delta_editor_t *editor,
01271                       void *edit_baton,
01272                       svn_revnum_t revision,
01273                       const apr_array_header_t *paths,
01274                       svn_delta_path_driver_cb_func_t callback_func,
01275                       void *callback_baton,
01276                       apr_pool_t *scratch_pool);
01277 
01280 
01281 /*** File revision iterator types ***/
01282 
01308 typedef svn_error_t *(*svn_file_rev_handler_t)(
01309   void *baton,
01310   const char *path,
01311   svn_revnum_t rev,
01312   apr_hash_t *rev_props,
01313   svn_boolean_t result_of_merge,
01314   svn_txdelta_window_handler_t *delta_handler,
01315   void **delta_baton,
01316   apr_array_header_t *prop_diffs,
01317   apr_pool_t *pool);
01318 
01330 typedef svn_error_t *(*svn_file_rev_handler_old_t)(
01331   void *baton,
01332   const char *path,
01333   svn_revnum_t rev,
01334   apr_hash_t *rev_props,
01335   svn_txdelta_window_handler_t *delta_handler,
01336   void **delta_baton,
01337   apr_array_header_t *prop_diffs,
01338   apr_pool_t *pool);
01339 
01353 void
01354 svn_compat_wrap_file_rev_handler(svn_file_rev_handler_t *handler2,
01355                                  void **handler2_baton,
01356                                  svn_file_rev_handler_old_t handler,
01357                                  void *handler_baton,
01358                                  apr_pool_t *pool);
01359 
01362 
01363 #ifdef __cplusplus
01364 }
01365 #endif /* __cplusplus */
01366 
01367 #endif /* SVN_DELTA_H */