]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/subversion/subversion/libsvn_delta/branch_migrate.c
Update svn-1.9.7 to 1.10.0.
[FreeBSD/FreeBSD.git] / contrib / subversion / subversion / libsvn_delta / branch_migrate.c
1 /*
2  * migrate.c: Migrate history from non-move-tracking revisions
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 #include "svn_types.h"
25 #include "svn_error.h"
26 #include "svn_delta.h"
27 #include "svn_ra.h"
28
29 #include "private/svn_branch.h"
30 #include "private/svn_branch_compat.h"
31
32 #include "svn_private_config.h"
33
34
35 struct edit_baton
36 {
37   svn_branch__txn_t *edit_txn;
38   svn_ra_session_t *from_session;
39   svn_revnum_t revision;
40 };
41
42 struct dir_baton
43 {
44   struct edit_baton *edit_baton;
45 };
46
47 struct file_baton
48 {
49   struct edit_baton *edit_baton;
50 };
51
52 static svn_error_t *
53 set_target_revision(void *edit_baton,
54                     svn_revnum_t target_revision,
55                     apr_pool_t *pool)
56 {
57   /*struct edit_baton *eb = edit_baton;*/
58
59   /*SVN_ERR(eb->wrapped_editor->set_target_revision(eb->wrapped_edit_baton,
60                                                  target_revision,
61                                                  pool));*/
62   return SVN_NO_ERROR;
63 }
64
65 static svn_error_t *
66 open_root(void *edit_baton,
67           svn_revnum_t base_revision,
68           apr_pool_t *pool,
69           void **root_baton)
70 {
71   struct edit_baton *eb = edit_baton;
72   struct dir_baton *dir_baton = apr_palloc(pool, sizeof(*dir_baton));
73
74   /*SVN_ERR(eb->wrapped_editor->open_root(eb->wrapped_edit_baton,
75                                         base_revision,
76                                         pool,
77                                         &dir_baton->wrapped_dir_baton));*/
78
79   dir_baton->edit_baton = eb;
80
81   *root_baton = dir_baton;
82
83   return SVN_NO_ERROR;
84 }
85
86 static svn_error_t *
87 delete_entry(const char *path,
88              svn_revnum_t base_revision,
89              void *parent_baton,
90              apr_pool_t *pool)
91 {
92   /*struct dir_baton *pb = parent_baton;
93   struct edit_baton *eb = pb->edit_baton;*/
94
95   /*SVN_ERR(eb->wrapped_editor->delete_entry(path,
96                                           base_revision,
97                                           pb->wrapped_dir_baton,
98                                           pool);*/
99   return SVN_NO_ERROR;
100 }
101
102 static svn_error_t *
103 add_directory(const char *path,
104               void *parent_baton,
105               const char *copyfrom_path,
106               svn_revnum_t copyfrom_revision,
107               apr_pool_t *pool,
108               void **child_baton)
109 {
110   struct dir_baton *pb = parent_baton;
111   struct edit_baton *eb = pb->edit_baton;
112   struct dir_baton *db = apr_palloc(pool, sizeof(*db));
113
114   /*SVN_ERR(eb->wrapped_editor->add_directory(path,
115                                             pb->wrapped_dir_baton,
116                                             copyfrom_path,
117                                             copyfrom_revision,
118                                             pool,
119                                             &db->wrapped_dir_baton));*/
120
121   db->edit_baton = eb;
122   *child_baton = db;
123
124   return SVN_NO_ERROR;
125 }
126
127 static svn_error_t *
128 open_directory(const char *path,
129                void *parent_baton,
130                svn_revnum_t base_revision,
131                apr_pool_t *pool,
132                void **child_baton)
133 {
134   struct dir_baton *pb = parent_baton;
135   struct edit_baton *eb = pb->edit_baton;
136   struct dir_baton *db = apr_palloc(pool, sizeof(*db));
137
138   /*SVN_ERR(eb->wrapped_editor->open_directory(path,
139                                              pb->wrapped_dir_baton,
140                                              base_revision,
141                                              pool,
142                                              &db->wrapped_dir_baton));*/
143
144   db->edit_baton = eb;
145   *child_baton = db;
146
147   return SVN_NO_ERROR;
148 }
149
150 static svn_error_t *
151 add_file(const char *path,
152          void *parent_baton,
153          const char *copyfrom_path,
154          svn_revnum_t copyfrom_revision,
155          apr_pool_t *pool,
156          void **file_baton)
157 {
158   struct dir_baton *pb = parent_baton;
159   struct edit_baton *eb = pb->edit_baton;
160   struct file_baton *fb = apr_palloc(pool, sizeof(*fb));
161
162   /*SVN_ERR(eb->wrapped_editor->add_file(path,
163                                        pb->wrapped_dir_baton,
164                                        copyfrom_path,
165                                        copyfrom_revision,
166                                        pool,
167                                        &fb->wrapped_file_baton));*/
168
169   fb->edit_baton = eb;
170   *file_baton = fb;
171
172   return SVN_NO_ERROR;
173 }
174
175 static svn_error_t *
176 open_file(const char *path,
177           void *parent_baton,
178           svn_revnum_t base_revision,
179           apr_pool_t *pool,
180           void **file_baton)
181 {
182   struct dir_baton *pb = parent_baton;
183   struct edit_baton *eb = pb->edit_baton;
184   struct file_baton *fb = apr_palloc(pool, sizeof(*fb));
185
186   /*SVN_ERR(eb->wrapped_editor->open_file(path,
187                                         pb->wrapped_dir_baton,
188                                         base_revision,
189                                         pool,
190                                         &fb->wrapped_file_baton));*/
191
192   fb->edit_baton = eb;
193   *file_baton = fb;
194
195   return SVN_NO_ERROR;
196 }
197
198 static svn_error_t *
199 apply_textdelta(void *file_baton,
200                 const char *base_checksum,
201                 apr_pool_t *pool,
202                 svn_txdelta_window_handler_t *handler,
203                 void **handler_baton)
204 {
205   /*struct file_baton *fb = file_baton;
206   struct edit_baton *eb = fb->edit_baton;*/
207
208   /*SVN_ERR(eb->wrapped_editor->apply_textdelta(fb->wrapped_file_baton,
209                                               base_checksum,
210                                               pool,
211                                               handler,
212                                               handler_baton));*/
213
214   return SVN_NO_ERROR;
215 }
216
217 static svn_error_t *
218 close_file(void *file_baton,
219            const char *text_checksum,
220            apr_pool_t *pool)
221 {
222   /*struct file_baton *fb = file_baton;
223   struct edit_baton *eb = fb->edit_baton;*/
224
225   /*SVN_ERR(eb->wrapped_editor->close_file(fb->wrapped_file_baton,
226                                          text_checksum, pool));*/
227
228   return SVN_NO_ERROR;
229 }
230
231 static svn_error_t *
232 absent_file(const char *path,
233             void *file_baton,
234             apr_pool_t *pool)
235 {
236   /*struct file_baton *fb = file_baton;
237   struct edit_baton *eb = fb->edit_baton;*/
238
239   /*SVN_ERR(eb->wrapped_editor->absent_file(path, fb->wrapped_file_baton,
240                                           pool));*/
241
242   return SVN_NO_ERROR;
243 }
244
245 static svn_error_t *
246 close_directory(void *dir_baton,
247                 apr_pool_t *pool)
248 {
249   /*struct dir_baton *db = dir_baton;
250   struct edit_baton *eb = db->edit_baton;*/
251
252   /*SVN_ERR(eb->wrapped_editor->close_directory(db->wrapped_dir_baton,
253                                               pool));*/
254
255   return SVN_NO_ERROR;
256 }
257
258 static svn_error_t *
259 absent_directory(const char *path,
260                  void *dir_baton,
261                  apr_pool_t *pool)
262 {
263   /*struct dir_baton *db = dir_baton;
264   struct edit_baton *eb = db->edit_baton;*/
265
266   /*SVN_ERR(eb->wrapped_editor->absent_directory(path, db->wrapped_dir_baton,
267                                                pool));*/
268
269   return SVN_NO_ERROR;
270 }
271
272 static svn_error_t *
273 change_file_prop(void *file_baton,
274                  const char *name,
275                  const svn_string_t *value,
276                  apr_pool_t *pool)
277 {
278   /*struct file_baton *fb = file_baton;
279   struct edit_baton *eb = fb->edit_baton;*/
280
281   /*SVN_ERR(eb->wrapped_editor->change_file_prop(fb->wrapped_file_baton,
282                                                name,
283                                                value,
284                                                pool));*/
285
286   return SVN_NO_ERROR;
287 }
288
289 static svn_error_t *
290 change_dir_prop(void *dir_baton,
291                 const char *name,
292                 const svn_string_t *value,
293                 apr_pool_t *pool)
294 {
295   /*struct dir_baton *db = dir_baton;
296   struct edit_baton *eb = db->edit_baton;*/
297
298   /*SVN_ERR(eb->wrapped_editor->change_dir_prop(db->wrapped_dir_baton,
299                                               name,
300                                               value,
301                                               pool));*/
302
303   return SVN_NO_ERROR;
304 }
305
306 static svn_error_t *
307 close_edit(void *edit_baton,
308            apr_pool_t *pool)
309 {
310   /*struct edit_baton *eb = edit_baton;*/
311
312   /*SVN_ERR(eb->wrapped_editor->close_edit(eb->wrapped_edit_baton, pool));*/
313
314   return SVN_NO_ERROR;
315 }
316
317 static svn_error_t *
318 abort_edit(void *edit_baton,
319            apr_pool_t *pool)
320 {
321   /*struct edit_baton *eb = edit_baton;*/
322
323   /*SVN_ERR(eb->wrapped_editor->abort_edit(eb->wrapped_edit_baton, pool));*/
324
325   return SVN_NO_ERROR;
326 }
327
328 svn_error_t *
329 svn_branch__compat_get_migration_editor(
330                         const svn_delta_editor_t **old_editor,
331                         void **old_edit_baton,
332                         svn_branch__txn_t *edit_txn,
333                         svn_ra_session_t *from_session,
334                         svn_revnum_t revision,
335                         apr_pool_t *result_pool)
336 {
337   static const svn_delta_editor_t editor = {
338     set_target_revision,
339     open_root,
340     delete_entry,
341     add_directory,
342     open_directory,
343     change_dir_prop,
344     close_directory,
345     absent_directory,
346     add_file,
347     open_file,
348     apply_textdelta,
349     change_file_prop,
350     close_file,
351     absent_file,
352     close_edit,
353     abort_edit
354   };
355   struct edit_baton *eb = apr_palloc(result_pool, sizeof(*eb));
356
357   eb->edit_txn = edit_txn;
358   eb->from_session = from_session;
359   eb->revision = revision;
360
361   *old_editor = &editor;
362   *old_edit_baton = eb;
363
364   return SVN_NO_ERROR;
365 }
366