]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/subversion/subversion/libsvn_delta/default_editor.c
Upgrade to OpenSSH 7.6p1. This will be followed shortly by 7.7p1.
[FreeBSD/FreeBSD.git] / contrib / subversion / subversion / libsvn_delta / default_editor.c
1 /*
2  * default_editor.c -- provide a basic svn_delta_editor_t
3  *
4  * ====================================================================
5  *    Licensed to the Apache Software Foundation (ASF) under one
6  *    or more contributor license agreements.  See the NOTICE file
7  *    distributed with this work for additional information
8  *    regarding copyright ownership.  The ASF licenses this file
9  *    to you under the Apache License, Version 2.0 (the
10  *    "License"); you may not use this file except in compliance
11  *    with the License.  You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  *    Unless required by applicable law or agreed to in writing,
16  *    software distributed under the License is distributed on an
17  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18  *    KIND, either express or implied.  See the License for the
19  *    specific language governing permissions and limitations
20  *    under the License.
21  * ====================================================================
22  */
23
24
25 #include <apr_pools.h>
26 #include <apr_strings.h>
27
28 #include "svn_types.h"
29 #include "svn_delta.h"
30
31 \f
32 static svn_error_t *
33 set_target_revision(void *edit_baton,
34                     svn_revnum_t target_revision,
35                     apr_pool_t *pool)
36 {
37   return SVN_NO_ERROR;
38 }
39 static svn_error_t *
40 add_item(const char *path,
41          void *parent_baton,
42          const char *copyfrom_path,
43          svn_revnum_t copyfrom_revision,
44          apr_pool_t *pool,
45          void **baton)
46 {
47   *baton = NULL;
48   return SVN_NO_ERROR;
49 }
50
51
52 static svn_error_t *
53 single_baton_func(void *baton,
54                   apr_pool_t *pool)
55 {
56   return SVN_NO_ERROR;
57 }
58
59
60 static svn_error_t *
61 absent_xxx_func(const char *path,
62                 void *baton,
63                 apr_pool_t *pool)
64 {
65   return SVN_NO_ERROR;
66 }
67
68
69 static svn_error_t *
70 open_root(void *edit_baton,
71           svn_revnum_t base_revision,
72           apr_pool_t *dir_pool,
73           void **root_baton)
74 {
75   *root_baton = NULL;
76   return SVN_NO_ERROR;
77 }
78
79 static svn_error_t *
80 delete_entry(const char *path,
81              svn_revnum_t revision,
82              void *parent_baton,
83              apr_pool_t *pool)
84 {
85   return SVN_NO_ERROR;
86 }
87
88 static svn_error_t *
89 open_item(const char *path,
90           void *parent_baton,
91           svn_revnum_t base_revision,
92           apr_pool_t *pool,
93           void **baton)
94 {
95   *baton = NULL;
96   return SVN_NO_ERROR;
97 }
98
99 static svn_error_t *
100 change_prop(void *file_baton,
101             const char *name,
102             const svn_string_t *value,
103             apr_pool_t *pool)
104 {
105   return SVN_NO_ERROR;
106 }
107
108 svn_error_t *svn_delta_noop_window_handler(svn_txdelta_window_t *window,
109                                            void *baton)
110 {
111   return SVN_NO_ERROR;
112 }
113
114 static svn_error_t *
115 apply_textdelta(void *file_baton,
116                 const char *base_checksum,
117                 apr_pool_t *pool,
118                 svn_txdelta_window_handler_t *handler,
119                 void **handler_baton)
120 {
121   *handler = svn_delta_noop_window_handler;
122   *handler_baton = NULL;
123   return SVN_NO_ERROR;
124 }
125
126
127 static svn_error_t *
128 close_file(void *file_baton,
129            const char *text_checksum,
130            apr_pool_t *pool)
131 {
132   return SVN_NO_ERROR;
133 }
134
135
136 static svn_error_t *
137 apply_textdelta_stream(const svn_delta_editor_t *editor,
138                        void *file_baton,
139                        const char *base_checksum,
140                        svn_txdelta_stream_open_func_t open_func,
141                        void *open_baton,
142                        apr_pool_t *scratch_pool)
143 {
144   svn_txdelta_window_handler_t handler;
145   void *handler_baton;
146
147   SVN_ERR(editor->apply_textdelta(file_baton, base_checksum,
148                                   scratch_pool, &handler,
149                                   &handler_baton));
150   if (handler != svn_delta_noop_window_handler)
151     {
152       svn_txdelta_stream_t *txdelta_stream;
153
154       SVN_ERR(open_func(&txdelta_stream, open_baton, scratch_pool,
155                         scratch_pool));
156       SVN_ERR(svn_txdelta_send_txstream(txdelta_stream, handler,
157                                         handler_baton, scratch_pool));
158     }
159
160   return SVN_NO_ERROR;
161 }
162
163 \f
164 static const svn_delta_editor_t default_editor =
165 {
166   set_target_revision,
167   open_root,
168   delete_entry,
169   add_item,
170   open_item,
171   change_prop,
172   single_baton_func,
173   absent_xxx_func,
174   add_item,
175   open_item,
176   apply_textdelta,
177   change_prop,
178   close_file,
179   absent_xxx_func,
180   single_baton_func,
181   single_baton_func,
182   apply_textdelta_stream
183 };
184
185 svn_delta_editor_t *
186 svn_delta_default_editor(apr_pool_t *pool)
187 {
188   return apr_pmemdup(pool, &default_editor, sizeof(default_editor));
189 }