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

« back to all changes in this revision

Viewing changes to subversion/tests/cmdline/entries-dump.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:
30
30
#define SVN_DEPRECATED
31
31
 
32
32
#include "svn_types.h"
 
33
#include "svn_cmdline.h"
33
34
#include "svn_pools.h"
34
35
#include "svn_wc.h"
35
36
#include "svn_dirent_uri.h"
37
38
#include "private/svn_wc_private.h"
38
39
 
39
40
#include "../../libsvn_wc/wc.h"
 
41
#include "../../libsvn_wc/lock.h"
40
42
 
41
43
static void
42
44
str_value(const char *name, const char *value)
65
67
}
66
68
 
67
69
static svn_error_t *
68
 
entries_dump(const char *dir_path, apr_pool_t *pool)
 
70
entries_dump(const char *dir_path, svn_wc_adm_access_t *related, apr_pool_t *pool)
69
71
{
70
 
  svn_wc_adm_access_t *adm_access;
 
72
  svn_wc_adm_access_t *adm_access = NULL;
71
73
  apr_hash_t *entries;
72
74
  apr_hash_index_t *hi;
73
75
  svn_boolean_t locked;
74
76
  svn_error_t *err;
75
77
 
76
 
  err = svn_wc_adm_open3(&adm_access, NULL, dir_path, FALSE, 0,
 
78
  err = svn_wc_adm_open3(&adm_access, related, dir_path, FALSE, 0,
77
79
                         NULL, NULL, pool);
78
80
  if (!err)
79
81
    {
80
82
      SVN_ERR(svn_wc_locked(&locked, dir_path, pool));
81
83
      SVN_ERR(svn_wc_entries_read(&entries, adm_access, TRUE, pool));
82
84
    }
 
85
  else if (err && err->apr_err == SVN_ERR_WC_LOCKED
 
86
           && related
 
87
           && ! strcmp(dir_path, svn_wc_adm_access_path(related)))
 
88
    {
 
89
      /* Common caller error: Can't open a baton when there is one. */
 
90
      svn_error_clear(err);
 
91
      SVN_ERR(svn_wc_locked(&locked, dir_path, pool));
 
92
      SVN_ERR(svn_wc_entries_read(&entries, related, TRUE, pool));
 
93
    }
83
94
  else
84
95
    {
85
96
      const char *dir_abspath, *lockfile_path;
101
112
 
102
113
  for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
103
114
    {
104
 
      const void *key;
105
 
      void *value;
106
 
      const svn_wc_entry_t *entry;
107
 
 
108
 
      apr_hash_this(hi, &key, NULL, &value);
109
 
      entry = value;
 
115
      const char *key = svn__apr_hash_index_key(hi);
 
116
      const svn_wc_entry_t *entry = svn__apr_hash_index_val(hi);
110
117
 
111
118
      SVN_ERR_ASSERT(strcmp(key, entry->name) == 0);
112
119
 
147
154
      /* skip: keep_local */
148
155
      int_value("depth", entry->depth);
149
156
      /* skip: tree_conflict_data */
150
 
      /* skip: file_external_path */
 
157
      bool_value("file_external", entry->file_external_path != NULL);
151
158
      /* skip: file_external_peg_rev */
152
159
      /* skip: file_external_rev */
153
160
      bool_value("locked", locked && *entry->name == '\0');
167
174
  svn_wc_context_t *wc_ctx;
168
175
  const char *root_abspath;
169
176
  const char *prefix_path;
 
177
  svn_wc_adm_access_t *adm_access;
170
178
};
171
179
 
172
180
/* svn_wc__node_found_func_t implementation for directory_dump */
251
259
  return svn_error_trace(svn_wc_context_destroy(bt.wc_ctx));
252
260
}
253
261
 
 
262
static svn_error_t *
 
263
tree_dump_dir(const char *local_abspath,
 
264
              svn_node_kind_t kind,
 
265
              void *walk_baton,
 
266
              apr_pool_t *scratch_pool)
 
267
{
 
268
  struct directory_walk_baton *bt = walk_baton;
 
269
  const char *path;
 
270
 
 
271
  if (kind != svn_node_dir)
 
272
    return SVN_NO_ERROR;
 
273
 
 
274
  /* If LOCAL_ABSPATH a child of or equal to ROOT_ABSPATH, then display
 
275
     a relative path starting with PREFIX_PATH. */
 
276
  path = svn_dirent_skip_ancestor(bt->root_abspath, local_abspath);
 
277
  if (path)
 
278
    path = svn_dirent_join(bt->prefix_path, path, scratch_pool);
 
279
  else
 
280
    path = local_abspath;
 
281
 
 
282
  printf("entries = {}\n");
 
283
  SVN_ERR(entries_dump(path, bt->adm_access, scratch_pool));
 
284
 
 
285
  printf("dirs['%s'] = entries\n", path);
 
286
  return SVN_NO_ERROR;
 
287
 
 
288
}
 
289
 
 
290
static svn_error_t *
 
291
tree_dump_txn(void *baton, svn_sqlite__db_t *db, apr_pool_t *scratch_pool)
 
292
{
 
293
  struct directory_walk_baton *bt = baton;
 
294
 
 
295
  SVN_ERR(svn_wc__internal_walk_children(bt->wc_ctx->db, bt->root_abspath, FALSE,
 
296
                                         NULL, tree_dump_dir, bt,
 
297
                                         svn_depth_infinity,
 
298
                                         NULL, NULL, scratch_pool));
 
299
 
 
300
  return SVN_NO_ERROR;
 
301
}
 
302
 
 
303
static svn_error_t *
 
304
tree_dump(const char *path,
 
305
          apr_pool_t *scratch_pool)
 
306
{
 
307
  struct directory_walk_baton bt;
 
308
  svn_sqlite__db_t *sdb;
 
309
  svn_wc__db_t *db;
 
310
 
 
311
  bt.prefix_path = path;
 
312
 
 
313
  /* Obtain an access baton to allow re-using the same wc_db for all access */
 
314
  SVN_ERR(svn_wc_adm_open3(&bt.adm_access, NULL, path, FALSE, 0, NULL, NULL,
 
315
                           scratch_pool));
 
316
 
 
317
  db = svn_wc__adm_get_db(bt.adm_access);
 
318
 
 
319
  SVN_ERR(svn_wc__context_create_with_db(&bt.wc_ctx, NULL, db, scratch_pool));
 
320
 
 
321
  SVN_ERR(svn_dirent_get_absolute(&bt.root_abspath, path, scratch_pool));
 
322
 
 
323
  /* And now get us a transaction on the database to avoid obtaining and
 
324
     releasing locks all the time */
 
325
  SVN_ERR(svn_wc__db_temp_borrow_sdb(&sdb, bt.wc_ctx->db, bt.root_abspath,
 
326
                                     scratch_pool));
 
327
 
 
328
  SVN_ERR(svn_sqlite__with_lock(sdb, tree_dump_txn, &bt, scratch_pool));
 
329
 
 
330
  /* And close everything we've opened */
 
331
  SVN_ERR(svn_wc_context_destroy(bt.wc_ctx));
 
332
  SVN_ERR(svn_wc_adm_close2(bt.adm_access, scratch_pool));
 
333
 
 
334
  return SVN_NO_ERROR;
 
335
}
 
336
 
254
337
int
255
338
main(int argc, const char *argv[])
256
339
{
262
345
 
263
346
  if (argc < 2 || argc > 4)
264
347
    {
265
 
      fprintf(stderr, "USAGE: entries-dump [--entries|--subdirs] DIR_PATH\n");
 
348
      fprintf(stderr, "USAGE: entries-dump [--entries|--subdirs|--tree-dump] DIR_PATH\n");
266
349
      exit(1);
267
350
    }
268
351
 
269
 
  if (apr_initialize() != APR_SUCCESS)
 
352
  if (svn_cmdline_init("entries-dump", stderr) != EXIT_SUCCESS)
270
353
    {
271
 
      fprintf(stderr, "apr_initialize() failed.\n");
272
 
      exit(1);
 
354
      return EXIT_FAILURE;
273
355
    }
274
356
 
275
 
  /* set up the global pool */
276
 
  pool = svn_pool_create(NULL);
 
357
  /* Create our top-level pool.  Use a separate mutexless allocator,
 
358
   * given this application is single threaded.
 
359
   */
 
360
  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
277
361
 
278
362
  path = svn_dirent_internal_style(argv[argc-1], pool);
279
363
 
283
367
    cmd = NULL;
284
368
 
285
369
  if (!cmd || !strcmp(cmd, "--entries"))
286
 
    err = entries_dump(path, pool);
 
370
    err = entries_dump(path, NULL, pool);
287
371
  else if (!strcmp(cmd, "--subdirs"))
288
372
    err = directory_dump(path, pool);
 
373
  else if (!strcmp(cmd, "--tree-dump"))
 
374
    err = tree_dump(path, pool);
289
375
  else
290
376
    err = svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
291
377
                            "Invalid command '%s'",