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)
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;
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,
80
82
SVN_ERR(svn_wc_locked(&locked, dir_path, pool));
81
83
SVN_ERR(svn_wc_entries_read(&entries, adm_access, TRUE, pool));
85
else if (err && err->apr_err == SVN_ERR_WC_LOCKED
87
&& ! strcmp(dir_path, svn_wc_adm_access_path(related)))
89
/* Common caller error: Can't open a baton when there is one. */
91
SVN_ERR(svn_wc_locked(&locked, dir_path, pool));
92
SVN_ERR(svn_wc_entries_read(&entries, related, TRUE, pool));
85
96
const char *dir_abspath, *lockfile_path;
102
113
for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
106
const svn_wc_entry_t *entry;
108
apr_hash_this(hi, &key, NULL, &value);
115
const char *key = svn__apr_hash_index_key(hi);
116
const svn_wc_entry_t *entry = svn__apr_hash_index_val(hi);
111
118
SVN_ERR_ASSERT(strcmp(key, entry->name) == 0);
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');
251
259
return svn_error_trace(svn_wc_context_destroy(bt.wc_ctx));
263
tree_dump_dir(const char *local_abspath,
264
svn_node_kind_t kind,
266
apr_pool_t *scratch_pool)
268
struct directory_walk_baton *bt = walk_baton;
271
if (kind != svn_node_dir)
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);
278
path = svn_dirent_join(bt->prefix_path, path, scratch_pool);
280
path = local_abspath;
282
printf("entries = {}\n");
283
SVN_ERR(entries_dump(path, bt->adm_access, scratch_pool));
285
printf("dirs['%s'] = entries\n", path);
291
tree_dump_txn(void *baton, svn_sqlite__db_t *db, apr_pool_t *scratch_pool)
293
struct directory_walk_baton *bt = baton;
295
SVN_ERR(svn_wc__internal_walk_children(bt->wc_ctx->db, bt->root_abspath, FALSE,
296
NULL, tree_dump_dir, bt,
298
NULL, NULL, scratch_pool));
304
tree_dump(const char *path,
305
apr_pool_t *scratch_pool)
307
struct directory_walk_baton bt;
308
svn_sqlite__db_t *sdb;
311
bt.prefix_path = path;
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,
317
db = svn_wc__adm_get_db(bt.adm_access);
319
SVN_ERR(svn_wc__context_create_with_db(&bt.wc_ctx, NULL, db, scratch_pool));
321
SVN_ERR(svn_dirent_get_absolute(&bt.root_abspath, path, scratch_pool));
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,
328
SVN_ERR(svn_sqlite__with_lock(sdb, tree_dump_txn, &bt, scratch_pool));
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));
255
338
main(int argc, const char *argv[])
263
346
if (argc < 2 || argc > 4)
265
fprintf(stderr, "USAGE: entries-dump [--entries|--subdirs] DIR_PATH\n");
348
fprintf(stderr, "USAGE: entries-dump [--entries|--subdirs|--tree-dump] DIR_PATH\n");
269
if (apr_initialize() != APR_SUCCESS)
352
if (svn_cmdline_init("entries-dump", stderr) != EXIT_SUCCESS)
271
fprintf(stderr, "apr_initialize() failed.\n");
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.
360
pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
278
362
path = svn_dirent_internal_style(argv[argc-1], pool);
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);
290
376
err = svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
291
377
"Invalid command '%s'",