~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/libsvn_client/util.c

  • Committer: Package Import Robot
  • Author(s): James McCoy, Peter Samuelson, James McCoy
  • Date: 2014-01-12 19:48:33 UTC
  • mfrom: (0.2.10)
  • Revision ID: package-import@ubuntu.com-20140112194833-w3axfwksn296jn5x
Tags: 1.8.5-1
[ Peter Samuelson ]
* New upstream release.  (Closes: #725787) Rediff patches:
  - Remove apr-abi1 (applied upstream), rename apr-abi2 to apr-abi
  - Remove loosen-sqlite-version-check (shouldn't be needed)
  - Remove java-osgi-metadata (applied upstream)
  - svnmucc prompts for a changelog if none is provided. (Closes: #507430)
  - Remove fix-bdb-version-detection, upstream uses "apu-config --dbm-libs"
  - Remove ruby-test-wc (applied upstream)
  - Fix “svn diff -r N file” when file has svn:mime-type set.
    (Closes: #734163)
  - Support specifying an encoding for mod_dav_svn's environment in which
    hooks are run.  (Closes: #601544)
  - Fix ordering of “svnadmin dump” paths with certain APR versions.
    (Closes: #687291)
  - Provide a better error message when authentication fails with an
    svn+ssh:// URL.  (Closes: #273874)
  - Updated Polish translations.  (Closes: #690815)

[ James McCoy ]
* Remove all traces of libneon, replaced by libserf.
* patches/sqlite_3.8.x_workaround: Upstream fix for wc-queries-test test
  failurse.
* Run configure with --with-apache-libexecdir, which allows removing part of
  patches/rpath.
* Re-enable auth-test as upstream has fixed the problem of picking up
  libraries from the environment rather than the build tree.
  (Closes: #654172)
* Point LD_LIBRARY_PATH at the built auth libraries when running the svn
  command during the build.  (Closes: #678224)
* Add a NEWS entry describing how to configure mod_dav_svn to understand
  UTF-8.  (Closes: #566148)
* Remove ancient transitional package, libsvn-ruby.
* Enable compatibility with Sqlite3 versions back to Wheezy.
* Enable hardening flags.  (Closes: #734918)
* patches/build-fixes: Enable verbose build logs.
* Build against the default ruby version.  (Closes: #722393)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <apr_pools.h>
25
25
#include <apr_strings.h>
26
26
 
 
27
#include "svn_hash.h"
27
28
#include "svn_pools.h"
28
29
#include "svn_error.h"
29
30
#include "svn_types.h"
41
42
 
42
43
#include "svn_private_config.h"
43
44
 
 
45
svn_client__pathrev_t *
 
46
svn_client__pathrev_create(const char *repos_root_url,
 
47
                           const char *repos_uuid,
 
48
                           svn_revnum_t rev,
 
49
                           const char *url,
 
50
                           apr_pool_t *result_pool)
 
51
{
 
52
  svn_client__pathrev_t *loc = apr_palloc(result_pool, sizeof(*loc));
 
53
 
 
54
  SVN_ERR_ASSERT_NO_RETURN(svn_path_is_url(repos_root_url));
 
55
  SVN_ERR_ASSERT_NO_RETURN(svn_path_is_url(url));
 
56
 
 
57
  loc->repos_root_url = apr_pstrdup(result_pool, repos_root_url);
 
58
  loc->repos_uuid = apr_pstrdup(result_pool, repos_uuid);
 
59
  loc->rev = rev;
 
60
  loc->url = apr_pstrdup(result_pool, url);
 
61
  return loc;
 
62
}
 
63
 
 
64
svn_client__pathrev_t *
 
65
svn_client__pathrev_create_with_relpath(const char *repos_root_url,
 
66
                                        const char *repos_uuid,
 
67
                                        svn_revnum_t rev,
 
68
                                        const char *relpath,
 
69
                                        apr_pool_t *result_pool)
 
70
{
 
71
  SVN_ERR_ASSERT_NO_RETURN(svn_relpath_is_canonical(relpath));
 
72
 
 
73
  return svn_client__pathrev_create(
 
74
           repos_root_url, repos_uuid, rev,
 
75
           svn_path_url_add_component2(repos_root_url, relpath, result_pool),
 
76
           result_pool);
 
77
}
 
78
 
 
79
svn_error_t *
 
80
svn_client__pathrev_create_with_session(svn_client__pathrev_t **pathrev_p,
 
81
                                        svn_ra_session_t *ra_session,
 
82
                                        svn_revnum_t rev,
 
83
                                        const char *url,
 
84
                                        apr_pool_t *result_pool)
 
85
{
 
86
  svn_client__pathrev_t *pathrev = apr_palloc(result_pool, sizeof(*pathrev));
 
87
 
 
88
  SVN_ERR_ASSERT(svn_path_is_url(url));
 
89
 
 
90
  SVN_ERR(svn_ra_get_repos_root2(ra_session, &pathrev->repos_root_url,
 
91
                                 result_pool));
 
92
  SVN_ERR(svn_ra_get_uuid2(ra_session, &pathrev->repos_uuid, result_pool));
 
93
  pathrev->rev = rev;
 
94
  pathrev->url = apr_pstrdup(result_pool, url);
 
95
  *pathrev_p = pathrev;
 
96
  return SVN_NO_ERROR;
 
97
}
 
98
 
 
99
svn_client__pathrev_t *
 
100
svn_client__pathrev_dup(const svn_client__pathrev_t *pathrev,
 
101
                        apr_pool_t *result_pool)
 
102
{
 
103
  return svn_client__pathrev_create(
 
104
           pathrev->repos_root_url, pathrev->repos_uuid,
 
105
           pathrev->rev, pathrev->url, result_pool);
 
106
}
 
107
 
 
108
svn_client__pathrev_t *
 
109
svn_client__pathrev_join_relpath(const svn_client__pathrev_t *pathrev,
 
110
                                 const char *relpath,
 
111
                                 apr_pool_t *result_pool)
 
112
{
 
113
  return svn_client__pathrev_create(
 
114
           pathrev->repos_root_url, pathrev->repos_uuid, pathrev->rev,
 
115
           svn_path_url_add_component2(pathrev->url, relpath, result_pool),
 
116
           result_pool);
 
117
}
 
118
 
 
119
const char *
 
120
svn_client__pathrev_relpath(const svn_client__pathrev_t *pathrev,
 
121
                            apr_pool_t *result_pool)
 
122
{
 
123
  return svn_uri_skip_ancestor(pathrev->repos_root_url, pathrev->url,
 
124
                               result_pool);
 
125
}
 
126
 
 
127
const char *
 
128
svn_client__pathrev_fspath(const svn_client__pathrev_t *pathrev,
 
129
                           apr_pool_t *result_pool)
 
130
{
 
131
  return svn_fspath__canonicalize(svn_uri_skip_ancestor(
 
132
                                    pathrev->repos_root_url, pathrev->url,
 
133
                                    result_pool),
 
134
                                  result_pool);
 
135
}
 
136
 
 
137
 
44
138
svn_client_commit_item3_t *
45
139
svn_client_commit_item3_create(apr_pool_t *pool)
46
140
{
76
170
}
77
171
 
78
172
svn_error_t *
79
 
svn_client__path_relative_to_root(const char **rel_path,
80
 
                                  svn_wc_context_t *wc_ctx,
81
 
                                  const char *abspath_or_url,
82
 
                                  const char *repos_root,
83
 
                                  svn_boolean_t include_leading_slash,
84
 
                                  svn_ra_session_t *ra_session,
85
 
                                  apr_pool_t *result_pool,
86
 
                                  apr_pool_t *scratch_pool)
87
 
{
88
 
  const char *repos_relpath;
89
 
 
90
 
  /* If we have a WC path... */
91
 
  if (! svn_path_is_url(abspath_or_url))
92
 
    {
93
 
      /* ...fetch its entry, and attempt to get both its full URL and
94
 
         repository root URL.  If we can't get REPOS_ROOT from the WC
95
 
         entry, we'll get it from the RA layer.*/
96
 
 
97
 
      SVN_ERR(svn_wc__node_get_repos_relpath(&repos_relpath,
98
 
                                             wc_ctx,
99
 
                                             abspath_or_url,
100
 
                                             result_pool,
101
 
                                             scratch_pool));
102
 
 
103
 
      SVN_ERR_ASSERT(repos_relpath != NULL);
104
 
    }
105
 
     /* Merge handling passes a root that is not the repos root */
106
 
  else if (repos_root != NULL)
107
 
    {
108
 
      if (!svn_uri__is_ancestor(repos_root, abspath_or_url))
109
 
        return svn_error_createf(SVN_ERR_CLIENT_UNRELATED_RESOURCES, NULL,
110
 
                                 _("URL '%s' is not a child of repository "
111
 
                                   "root URL '%s'"),
112
 
                                 abspath_or_url, repos_root);
113
 
 
114
 
      repos_relpath = svn_uri_skip_ancestor(repos_root, abspath_or_url,
115
 
                                            result_pool);
116
 
    }
117
 
  else
 
173
svn_client__wc_node_get_base(svn_client__pathrev_t **base_p,
 
174
                             const char *wc_abspath,
 
175
                             svn_wc_context_t *wc_ctx,
 
176
                             apr_pool_t *result_pool,
 
177
                             apr_pool_t *scratch_pool)
 
178
{
 
179
  const char *relpath;
 
180
 
 
181
  *base_p = apr_palloc(result_pool, sizeof(**base_p));
 
182
 
 
183
  SVN_ERR(svn_wc__node_get_base(NULL,
 
184
                                &(*base_p)->rev,
 
185
                                &relpath,
 
186
                                &(*base_p)->repos_root_url,
 
187
                                &(*base_p)->repos_uuid,
 
188
                                NULL,
 
189
                                wc_ctx, wc_abspath,
 
190
                                TRUE /* ignore_enoent */,
 
191
                                TRUE /* show_hidden */,
 
192
                                result_pool, scratch_pool));
 
193
  if ((*base_p)->repos_root_url && relpath)
 
194
    {
 
195
      (*base_p)->url = svn_path_url_add_component2(
 
196
                           (*base_p)->repos_root_url, relpath, result_pool);
 
197
    }
 
198
  else
 
199
    {
 
200
      *base_p = NULL;
 
201
    }
 
202
  return SVN_NO_ERROR;
 
203
}
 
204
 
 
205
svn_error_t *
 
206
svn_client__wc_node_get_origin(svn_client__pathrev_t **origin_p,
 
207
                               const char *wc_abspath,
 
208
                               svn_client_ctx_t *ctx,
 
209
                               apr_pool_t *result_pool,
 
210
                               apr_pool_t *scratch_pool)
 
211
{
 
212
  const char *relpath;
 
213
 
 
214
  *origin_p = apr_palloc(result_pool, sizeof(**origin_p));
 
215
 
 
216
  SVN_ERR(svn_wc__node_get_origin(NULL /* is_copy */,
 
217
                                  &(*origin_p)->rev,
 
218
                                  &relpath,
 
219
                                  &(*origin_p)->repos_root_url,
 
220
                                  &(*origin_p)->repos_uuid,
 
221
                                  NULL, ctx->wc_ctx, wc_abspath,
 
222
                                  FALSE /* scan_deleted */,
 
223
                                  result_pool, scratch_pool));
 
224
  if ((*origin_p)->repos_root_url && relpath)
 
225
    {
 
226
      (*origin_p)->url = svn_path_url_add_component2(
 
227
                           (*origin_p)->repos_root_url, relpath, result_pool);
 
228
    }
 
229
  else
 
230
    {
 
231
      *origin_p = NULL;
 
232
    }
 
233
  return SVN_NO_ERROR;
 
234
}
 
235
 
 
236
svn_error_t *
 
237
svn_client_get_repos_root(const char **repos_root,
 
238
                          const char **repos_uuid,
 
239
                          const char *abspath_or_url,
 
240
                          svn_client_ctx_t *ctx,
 
241
                          apr_pool_t *result_pool,
 
242
                          apr_pool_t *scratch_pool)
 
243
{
 
244
  svn_ra_session_t *ra_session;
 
245
 
 
246
  /* If PATH_OR_URL is a local path we can fetch the repos root locally. */
 
247
  if (!svn_path_is_url(abspath_or_url))
118
248
    {
119
249
      svn_error_t *err;
120
 
 
121
 
      SVN_ERR_ASSERT(ra_session != NULL);
122
 
 
123
 
      /* Ask the RA layer to create a relative path for us */
124
 
      err = svn_ra_get_path_relative_to_root(ra_session, &repos_relpath,
125
 
                                             abspath_or_url, scratch_pool);
 
250
      err = svn_wc__node_get_repos_info(NULL, NULL, repos_root, repos_uuid,
 
251
                                        ctx->wc_ctx, abspath_or_url,
 
252
                                        result_pool, scratch_pool);
126
253
 
127
254
      if (err)
128
255
        {
129
 
          if (err->apr_err == SVN_ERR_RA_ILLEGAL_URL)
130
 
            return svn_error_createf(SVN_ERR_CLIENT_UNRELATED_RESOURCES, err,
131
 
                                     _("URL '%s' is not inside repository"),
132
 
                                     abspath_or_url);
 
256
          if (err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND
 
257
              && err->apr_err != SVN_ERR_WC_NOT_WORKING_COPY)
 
258
            return svn_error_trace(err);
133
259
 
134
 
          return svn_error_trace(err);
 
260
          svn_error_clear(err);
 
261
          if (repos_root)
 
262
            *repos_root = NULL;
 
263
          if (repos_uuid)
 
264
            *repos_uuid = NULL;
135
265
        }
136
 
    }
137
 
 
138
 
  if (include_leading_slash)
139
 
    *rel_path = apr_pstrcat(result_pool, "/", repos_relpath, NULL);
140
 
  else
141
 
    *rel_path = repos_relpath;
142
 
 
143
 
   return SVN_NO_ERROR;
144
 
}
145
 
 
146
 
svn_error_t *
147
 
svn_client__get_repos_root(const char **repos_root,
148
 
                           const char *abspath_or_url,
149
 
                           svn_client_ctx_t *ctx,
150
 
                           apr_pool_t *result_pool,
151
 
                           apr_pool_t *scratch_pool)
152
 
{
153
 
  svn_ra_session_t *ra_session;
154
 
 
155
 
  /* If PATH_OR_URL is a local path we can fetch the repos root locally. */
156
 
  if (!svn_path_is_url(abspath_or_url))
157
 
    {
158
 
      SVN_ERR(svn_wc__node_get_repos_info(repos_root, NULL,
159
 
                                          ctx->wc_ctx, abspath_or_url,
160
 
                                          result_pool, scratch_pool));
161
 
 
162
266
      return SVN_NO_ERROR;
163
267
    }
164
268
 
165
269
  /* If PATH_OR_URL was a URL, we use the RA layer to look it up. */
166
 
  SVN_ERR(svn_client__open_ra_session_internal(&ra_session, NULL,
167
 
                                               abspath_or_url,
168
 
                                               NULL, NULL, FALSE, TRUE,
169
 
                                               ctx, scratch_pool));
 
270
  SVN_ERR(svn_client_open_ra_session2(&ra_session,  abspath_or_url, NULL,
 
271
                                      ctx, scratch_pool, scratch_pool));
170
272
 
171
 
  SVN_ERR(svn_ra_get_repos_root2(ra_session, repos_root, result_pool));
 
273
  if (repos_root)
 
274
    SVN_ERR(svn_ra_get_repos_root2(ra_session, repos_root, result_pool));
 
275
  if (repos_uuid)
 
276
    SVN_ERR(svn_ra_get_uuid2(ra_session, repos_uuid, result_pool));
172
277
 
173
278
  return SVN_NO_ERROR;
174
279
}
175
280
 
176
 
 
177
 
svn_error_t *
178
 
svn_client__default_walker_error_handler(const char *path,
179
 
                                         svn_error_t *err,
180
 
                                         void *walk_baton,
181
 
                                         apr_pool_t *pool)
182
 
{
183
 
  return svn_error_trace(err);
184
 
}
185
 
 
186
 
 
187
281
const svn_opt_revision_t *
188
282
svn_cl__rev_default_to_head_or_base(const svn_opt_revision_t *revision,
189
283
                                    const char *path_or_url)
238
332
 
239
333
  return SVN_NO_ERROR;
240
334
}
 
335
 
 
336
struct shim_callbacks_baton
 
337
{
 
338
  svn_wc_context_t *wc_ctx;
 
339
  apr_hash_t *relpath_map;
 
340
};
 
341
 
 
342
static svn_error_t *
 
343
fetch_props_func(apr_hash_t **props,
 
344
                 void *baton,
 
345
                 const char *path,
 
346
                 svn_revnum_t base_revision,
 
347
                 apr_pool_t *result_pool,
 
348
                 apr_pool_t *scratch_pool)
 
349
{
 
350
  struct shim_callbacks_baton *scb = baton;
 
351
  const char *local_abspath;
 
352
 
 
353
  local_abspath = svn_hash_gets(scb->relpath_map, path);
 
354
  if (!local_abspath)
 
355
    {
 
356
      *props = apr_hash_make(result_pool);
 
357
      return SVN_NO_ERROR;
 
358
    }
 
359
 
 
360
  /* Reads the pristine properties of WORKING, not those of BASE */
 
361
  SVN_ERR(svn_wc_get_pristine_props(props, scb->wc_ctx, local_abspath,
 
362
                                    result_pool, scratch_pool));
 
363
 
 
364
  if (!*props)
 
365
    *props = apr_hash_make(result_pool);
 
366
 
 
367
  return SVN_NO_ERROR;
 
368
}
 
369
 
 
370
static svn_error_t *
 
371
fetch_kind_func(svn_node_kind_t *kind,
 
372
                void *baton,
 
373
                const char *path,
 
374
                svn_revnum_t base_revision,
 
375
                apr_pool_t *scratch_pool)
 
376
{
 
377
  struct shim_callbacks_baton *scb = baton;
 
378
  const char *local_abspath;
 
379
 
 
380
  local_abspath = svn_hash_gets(scb->relpath_map, path);
 
381
  if (!local_abspath)
 
382
    {
 
383
      *kind = svn_node_unknown;
 
384
      return SVN_NO_ERROR;
 
385
    }
 
386
  /* Reads the WORKING kind. Not the BASE kind */
 
387
  SVN_ERR(svn_wc_read_kind2(kind, scb->wc_ctx, local_abspath,
 
388
                            TRUE, FALSE, scratch_pool));
 
389
 
 
390
  return SVN_NO_ERROR;
 
391
}
 
392
 
 
393
static svn_error_t *
 
394
fetch_base_func(const char **filename,
 
395
                void *baton,
 
396
                const char *path,
 
397
                svn_revnum_t base_revision,
 
398
                apr_pool_t *result_pool,
 
399
                apr_pool_t *scratch_pool)
 
400
{
 
401
  struct shim_callbacks_baton *scb = baton;
 
402
  const char *local_abspath;
 
403
  svn_stream_t *pristine_stream;
 
404
  svn_stream_t *temp_stream;
 
405
  svn_error_t *err;
 
406
 
 
407
  local_abspath = svn_hash_gets(scb->relpath_map, path);
 
408
  if (!local_abspath)
 
409
    {
 
410
      *filename = NULL;
 
411
      return SVN_NO_ERROR;
 
412
    }
 
413
 
 
414
  /* Reads the pristine of WORKING, not of BASE */
 
415
  err = svn_wc_get_pristine_contents2(&pristine_stream, scb->wc_ctx,
 
416
                                      local_abspath, scratch_pool,
 
417
                                      scratch_pool);
 
418
  if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
 
419
    {
 
420
      svn_error_clear(err);
 
421
      *filename = NULL;
 
422
      return SVN_NO_ERROR;
 
423
    }
 
424
  else if (err)
 
425
    return svn_error_trace(err);
 
426
 
 
427
  SVN_ERR(svn_stream_open_unique(&temp_stream, filename, NULL,
 
428
                                 svn_io_file_del_on_pool_cleanup,
 
429
                                 result_pool, scratch_pool));
 
430
  SVN_ERR(svn_stream_copy3(pristine_stream, temp_stream, NULL, NULL,
 
431
                           scratch_pool));
 
432
 
 
433
  return SVN_NO_ERROR;
 
434
}
 
435
 
 
436
svn_delta_shim_callbacks_t *
 
437
svn_client__get_shim_callbacks(svn_wc_context_t *wc_ctx,
 
438
                               apr_hash_t *relpath_map,
 
439
                               apr_pool_t *result_pool)
 
440
{
 
441
  svn_delta_shim_callbacks_t *callbacks =
 
442
                            svn_delta_shim_callbacks_default(result_pool);
 
443
  struct shim_callbacks_baton *scb = apr_pcalloc(result_pool, sizeof(*scb));
 
444
 
 
445
  scb->wc_ctx = wc_ctx;
 
446
  if (relpath_map)
 
447
    scb->relpath_map = relpath_map;
 
448
  else
 
449
    scb->relpath_map = apr_hash_make(result_pool);
 
450
 
 
451
  callbacks->fetch_props_func = fetch_props_func;
 
452
  callbacks->fetch_kind_func = fetch_kind_func;
 
453
  callbacks->fetch_base_func = fetch_base_func;
 
454
  callbacks->fetch_baton = scb;
 
455
 
 
456
  return callbacks;
 
457
}