~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/libsvn_delta/cancel.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * cancel.c :  Routines to support cancelation of running subversion functions.
 
3
 *
 
4
 * ====================================================================
 
5
 * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 
6
 *
 
7
 * This software is licensed as described in the file COPYING, which
 
8
 * you should have received as part of this distribution.  The terms
 
9
 * are also available at http://subversion.tigris.org/license-1.html.
 
10
 * If newer versions of this license are posted there, you may use a
 
11
 * newer version instead, at your option.
 
12
 *
 
13
 * This software consists of voluntary contributions made by many
 
14
 * individuals.  For exact contribution history, see the revision
 
15
 * history and logs, available at http://subversion.tigris.org/.
 
16
 * ====================================================================
 
17
 */
 
18
 
 
19
#include <svn_delta.h>
 
20
 
 
21
struct edit_baton
 
22
{
 
23
  const svn_delta_editor_t *wrapped_editor;
 
24
  void *wrapped_edit_baton;
 
25
 
 
26
  svn_cancel_func_t cancel_func;
 
27
  void *cancel_baton;
 
28
};
 
29
 
 
30
struct dir_baton
 
31
{
 
32
  void *edit_baton;
 
33
  void *wrapped_dir_baton;
 
34
};
 
35
 
 
36
struct file_baton
 
37
{
 
38
  void *edit_baton;
 
39
  void *wrapped_file_baton;
 
40
};
 
41
 
 
42
static svn_error_t *
 
43
set_target_revision (void *edit_baton,
 
44
                     svn_revnum_t target_revision,
 
45
                     apr_pool_t *pool)
 
46
{
 
47
  struct edit_baton *eb = edit_baton;
 
48
 
 
49
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
50
 
 
51
  SVN_ERR (eb->wrapped_editor->set_target_revision (eb->wrapped_edit_baton,
 
52
                                                    target_revision,
 
53
                                                    pool));
 
54
 
 
55
  return SVN_NO_ERROR;
 
56
}
 
57
 
 
58
static svn_error_t *
 
59
open_root (void *edit_baton,
 
60
           svn_revnum_t base_revision,
 
61
           apr_pool_t *pool,
 
62
           void **root_baton)
 
63
{
 
64
  struct edit_baton *eb = edit_baton;
 
65
  struct dir_baton *dir_baton = apr_palloc (pool, sizeof (*dir_baton));
 
66
 
 
67
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
68
 
 
69
  SVN_ERR (eb->wrapped_editor->open_root (eb->wrapped_edit_baton,
 
70
                                          base_revision,
 
71
                                          pool,
 
72
                                          &dir_baton->wrapped_dir_baton));
 
73
 
 
74
  dir_baton->edit_baton = edit_baton;
 
75
 
 
76
  *root_baton = dir_baton;
 
77
 
 
78
  return SVN_NO_ERROR;
 
79
}
 
80
 
 
81
static svn_error_t *
 
82
delete_entry (const char *path,
 
83
              svn_revnum_t base_revision,
 
84
              void *parent_baton,
 
85
              apr_pool_t *pool)
 
86
{
 
87
  struct dir_baton *pb = parent_baton;
 
88
  struct edit_baton *eb = pb->edit_baton;
 
89
 
 
90
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
91
 
 
92
  SVN_ERR (eb->wrapped_editor->delete_entry (path,
 
93
                                             base_revision,
 
94
                                             pb->wrapped_dir_baton,
 
95
                                             pool));
 
96
 
 
97
  return SVN_NO_ERROR;
 
98
}
 
99
 
 
100
static svn_error_t *
 
101
add_directory (const char *path,
 
102
               void *parent_baton,
 
103
               const char *copyfrom_path,
 
104
               svn_revnum_t copyfrom_revision,
 
105
               apr_pool_t *pool,
 
106
               void **child_baton)
 
107
{
 
108
  struct dir_baton *pb = parent_baton;
 
109
  struct edit_baton *eb = pb->edit_baton;
 
110
  struct dir_baton *b = apr_palloc (pool, sizeof (*b));
 
111
 
 
112
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
113
 
 
114
  SVN_ERR (eb->wrapped_editor->add_directory (path,
 
115
                                              pb->wrapped_dir_baton,
 
116
                                              copyfrom_path,
 
117
                                              copyfrom_revision,
 
118
                                              pool,
 
119
                                              &b->wrapped_dir_baton));
 
120
 
 
121
  b->edit_baton = eb;
 
122
  *child_baton = b;
 
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->cancel_func (eb->cancel_baton));
 
139
 
 
140
  SVN_ERR (eb->wrapped_editor->open_directory (path,
 
141
                                               pb->wrapped_dir_baton,
 
142
                                               base_revision,
 
143
                                               pool,
 
144
                                               &db->wrapped_dir_baton));
 
145
 
 
146
  db->edit_baton = eb;
 
147
  *child_baton = db;
 
148
 
 
149
  return SVN_NO_ERROR;
 
150
}
 
151
 
 
152
static svn_error_t *
 
153
add_file (const char *path,
 
154
          void *parent_baton,
 
155
          const char *copyfrom_path,
 
156
          svn_revnum_t copyfrom_revision,
 
157
          apr_pool_t *pool,
 
158
          void **file_baton)
 
159
{
 
160
  struct dir_baton *pb = parent_baton;
 
161
  struct edit_baton *eb = pb->edit_baton;
 
162
  struct file_baton *fb = apr_palloc (pool, sizeof (*fb));
 
163
 
 
164
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
165
 
 
166
  SVN_ERR (eb->wrapped_editor->add_file (path,
 
167
                                         pb->wrapped_dir_baton,
 
168
                                         copyfrom_path,
 
169
                                         copyfrom_revision,
 
170
                                         pool,
 
171
                                         &fb->wrapped_file_baton));
 
172
 
 
173
  fb->edit_baton = eb;
 
174
  *file_baton = fb;
 
175
 
 
176
  return SVN_NO_ERROR;
 
177
}
 
178
 
 
179
static svn_error_t *
 
180
open_file (const char *path,
 
181
           void *parent_baton,
 
182
           svn_revnum_t base_revision,
 
183
           apr_pool_t *pool,
 
184
           void **file_baton)
 
185
{
 
186
  struct dir_baton *pb = parent_baton;
 
187
  struct edit_baton *eb = pb->edit_baton;
 
188
  struct file_baton *fb = apr_palloc (pool, sizeof (*fb));
 
189
 
 
190
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
191
 
 
192
  SVN_ERR (eb->wrapped_editor->open_file (path,
 
193
                                          pb->wrapped_dir_baton,
 
194
                                          base_revision,
 
195
                                          pool,
 
196
                                          &fb->wrapped_file_baton));
 
197
 
 
198
  fb->edit_baton = eb;
 
199
  *file_baton = fb;
 
200
 
 
201
  return SVN_NO_ERROR;
 
202
}
 
203
 
 
204
static svn_error_t *
 
205
apply_textdelta (void *file_baton,
 
206
                 const char *base_checksum,
 
207
                 apr_pool_t *pool,
 
208
                 svn_txdelta_window_handler_t *handler,
 
209
                 void **handler_baton)
 
210
{
 
211
  struct file_baton *fb = file_baton;
 
212
  struct edit_baton *eb = fb->edit_baton;
 
213
 
 
214
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
215
 
 
216
  SVN_ERR (eb->wrapped_editor->apply_textdelta (fb->wrapped_file_baton,
 
217
                                                base_checksum,
 
218
                                                pool,
 
219
                                                handler,
 
220
                                                handler_baton));
 
221
 
 
222
  return SVN_NO_ERROR;
 
223
}
 
224
 
 
225
static svn_error_t *
 
226
close_file (void *file_baton,
 
227
            const char *text_checksum,
 
228
            apr_pool_t *pool)
 
229
{
 
230
  struct file_baton *fb = file_baton;
 
231
  struct edit_baton *eb = fb->edit_baton;
 
232
 
 
233
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
234
 
 
235
  SVN_ERR (eb->wrapped_editor->close_file (fb->wrapped_file_baton,
 
236
                                           text_checksum, pool));
 
237
 
 
238
  return SVN_NO_ERROR;
 
239
}
 
240
 
 
241
static svn_error_t *
 
242
absent_file (const char *path,
 
243
             void *file_baton,
 
244
             apr_pool_t *pool)
 
245
{
 
246
  struct file_baton *fb = file_baton;
 
247
  struct edit_baton *eb = fb->edit_baton;
 
248
 
 
249
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
250
 
 
251
  SVN_ERR (eb->wrapped_editor->absent_file (path, fb->wrapped_file_baton,
 
252
                                            pool));
 
253
 
 
254
  return SVN_NO_ERROR;
 
255
}
 
256
 
 
257
static svn_error_t *
 
258
close_directory (void *dir_baton,
 
259
                 apr_pool_t *pool)
 
260
{
 
261
  struct dir_baton *db = dir_baton;
 
262
  struct edit_baton *eb = db->edit_baton;
 
263
 
 
264
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
265
 
 
266
  SVN_ERR (eb->wrapped_editor->close_directory (db->wrapped_dir_baton,
 
267
                                                pool));
 
268
 
 
269
  return SVN_NO_ERROR;
 
270
}
 
271
 
 
272
static svn_error_t *
 
273
absent_directory (const char *path,
 
274
                  void *dir_baton,
 
275
                  apr_pool_t *pool)
 
276
{
 
277
  struct dir_baton *db = dir_baton;
 
278
  struct edit_baton *eb = db->edit_baton;
 
279
 
 
280
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
281
 
 
282
  SVN_ERR (eb->wrapped_editor->absent_directory (path, db->wrapped_dir_baton,
 
283
                                                 pool));
 
284
 
 
285
  return SVN_NO_ERROR;
 
286
}
 
287
 
 
288
static svn_error_t *
 
289
change_file_prop (void *file_baton,
 
290
                  const char *name,
 
291
                  const svn_string_t *value,
 
292
                  apr_pool_t *pool)
 
293
{
 
294
  struct file_baton *fb = file_baton;
 
295
  struct edit_baton *eb = fb->edit_baton;
 
296
 
 
297
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
298
 
 
299
  SVN_ERR (eb->wrapped_editor->change_file_prop (fb->wrapped_file_baton,
 
300
                                                 name,
 
301
                                                 value,
 
302
                                                 pool));
 
303
 
 
304
  return SVN_NO_ERROR;
 
305
}
 
306
 
 
307
static svn_error_t *
 
308
change_dir_prop (void *dir_baton,
 
309
                 const char *name,
 
310
                 const svn_string_t *value,
 
311
                 apr_pool_t *pool)
 
312
{
 
313
  struct dir_baton *db = dir_baton;
 
314
  struct edit_baton *eb = db->edit_baton;
 
315
 
 
316
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
317
 
 
318
  SVN_ERR (eb->wrapped_editor->change_dir_prop (db->wrapped_dir_baton,
 
319
                                                name,
 
320
                                                value,
 
321
                                                pool));
 
322
 
 
323
  return SVN_NO_ERROR;
 
324
}
 
325
 
 
326
static svn_error_t *
 
327
close_edit (void *edit_baton,
 
328
            apr_pool_t *pool)
 
329
{
 
330
  struct edit_baton *eb = edit_baton;
 
331
 
 
332
  SVN_ERR (eb->cancel_func (eb->cancel_baton));
 
333
 
 
334
  SVN_ERR (eb->wrapped_editor->close_edit (eb->wrapped_edit_baton, pool));
 
335
 
 
336
  return SVN_NO_ERROR;
 
337
}
 
338
 
 
339
svn_error_t *
 
340
svn_delta_get_cancellation_editor (svn_cancel_func_t cancel_func,
 
341
                                   void *cancel_baton,
 
342
                                   const svn_delta_editor_t *wrapped_editor,
 
343
                                   void *wrapped_edit_baton,
 
344
                                   const svn_delta_editor_t **editor,
 
345
                                   void **edit_baton,
 
346
                                   apr_pool_t *pool)
 
347
{
 
348
  if (cancel_func)
 
349
    {
 
350
      svn_delta_editor_t *tree_editor = svn_delta_default_editor (pool);
 
351
      struct edit_baton *eb = apr_palloc (pool, sizeof (*eb));
 
352
 
 
353
      tree_editor->set_target_revision = set_target_revision;
 
354
      tree_editor->open_root = open_root;
 
355
      tree_editor->delete_entry = delete_entry;
 
356
      tree_editor->add_directory = add_directory;
 
357
      tree_editor->open_directory = open_directory;
 
358
      tree_editor->change_dir_prop = change_dir_prop;
 
359
      tree_editor->close_directory = close_directory;
 
360
      tree_editor->absent_directory = absent_directory;
 
361
      tree_editor->add_file = add_file;
 
362
      tree_editor->open_file = open_file;
 
363
      tree_editor->apply_textdelta = apply_textdelta;
 
364
      tree_editor->change_file_prop = change_file_prop;
 
365
      tree_editor->close_file = close_file;
 
366
      tree_editor->absent_file = absent_file;
 
367
      tree_editor->close_edit = close_edit;
 
368
 
 
369
      eb->wrapped_editor = wrapped_editor;
 
370
      eb->wrapped_edit_baton = wrapped_edit_baton;
 
371
      eb->cancel_func = cancel_func;
 
372
      eb->cancel_baton = cancel_baton;
 
373
 
 
374
      *editor = tree_editor;
 
375
      *edit_baton = eb;
 
376
    }
 
377
  else
 
378
    {
 
379
      *editor = wrapped_editor;
 
380
      *edit_baton = wrapped_edit_baton;
 
381
    }
 
382
 
 
383
  return SVN_NO_ERROR;
 
384
}