Both ra-serf and neon misbehave when doing get_file on a
directory or get_dir on a file.
# ra-svn (right)
0 svn% ./get_dir-file svn://svnfe-test/r 84
doing get_dir2 on a file (welcome)
subversion/libsvn_fs_fs/dag.c:425: (apr_err=160016)
foo: Can't get entries of non-directory
# ra-neon (wrong)
1 svn% ./get_dir-file https://svnfe-test/r 84
doing get_dir2 on a file (welcome)
bad, should have died but got 0x8084970 0x807dfd0 (1 dirents)
d welcome
# ra-serf (different wrong)
0 svn% ./get_dir-file https://svnfe-test/r 84
doing get_dir2 on a file (welcome)
bad, should have died but got 0x80c81c0 0x80c80a0 (0 dirents)
# ra-svn
0 svn% ./get_file-dir svn://svnfe-test/r 84
doing get_file on a dir (changes)
subversion/libsvn_fs_fs/dag.c:984: (apr_err=160017)
foo: Attempted to get checksum of a *non*-file node
# ra-neon (wrong)
1 svn% ./get_file-dir https://svnfe-test/r 84
doing get_file on a dir (changes)
subversion/libsvn_ra_neon/util.c:549: (apr_err=175011)
foo: Repository moved permanently to 'https://svnfe-test/r/!svn/bc/119447/changes/'; please relocate
# ra-serf (different wrong)
1 svn% ./get_file-dir https://svnfe-test/r 84
doing get_file on a dir (changes)
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved here.</p>
</body></html>
bad, should have died
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
/* for svn initialization */
#include <apr_errno.h>
#include <apr_general.h>
#include <apr_strings.h>
#include <svn_auth.h>
#include <svn_cmdline.h>
#include <svn_config.h>
#include <svn_dso.h>
#include <svn_nls.h>
#include <svn_pools.h>
/* for svn_ra_get_dir2 */
#include <apr_hash.h>
#include <svn_error.h>
#include <svn_io.h>
#include <svn_path.h>
#include <svn_ra.h>
static svn_error_t *
open_tmp_file(apr_file_t **fp, void *baton, apr_pool_t *pool)
{
const char *base_fn, *base_path, *fn;
SVN_ERR(svn_io_temp_dir(&base_fn, pool));
base_path = svn_path_join(base_fn, "foo", pool);
return svn_io_open_unique_file2(fp, &fn, base_path, ".tmp",
svn_io_file_del_on_close, pool);
}
#define ERR(expr) \
do { \
svn_error_t *err = (expr); \
if (err) { \
fprintf(stderr, "%s:%ld: (apr_err=%d)\nfoo: %s\n", \
err->file, err->line, err->apr_err, \
err->message); \
svn_error_clear(err); \
svn_pool_destroy(pool); \
return 1; \
} \
} while (0)
int
main(int argc, char *argv[])
{
apr_pool_t *pool;
apr_hash_t *cfg_hash;
long revision;
svn_ra_callbacks2_t *callbacks;
if (argc < 3 || (argv[1] && argv[1][0] == '-')) {
fputs("usage: foo URL REVISION\n", stderr);
if (argv[1] && argv[1][0] == '-') {
return 0;
}
return 2;
}
errno = 0;
revision = strtol(argv[2], NULL, 10);
if (errno != 0) {
fprintf(stderr, "foo: strtol(%s): ", argv[2]);
perror("");
return 3;
}
/* Initialize svn. */
{
apr_status_t apr_status;
char buf[1024];
if ((apr_status = apr_initialize()) != APR_SUCCESS) {
apr_strerror(apr_status, buf, sizeof(buf) - 1);
fprintf(stderr, "foo: cannot initialize APR: %s\n", buf);
return 1;
}
svn_dso_initialize();
if (atexit(apr_terminate) != 0) {
fputs("atexit registration failed\n", stderr);
return 1;
}
pool = svn_pool_create(NULL);
svn_utf_initialize(pool);
ERR(svn_nls_init());
ERR(svn_config_get_config(&cfg_hash, NULL, pool));
ERR(svn_ra_initialize(pool));
ERR(svn_ra_create_callbacks(&callbacks, pool));
callbacks->open_tmp_file = open_tmp_file;
ERR(svn_cmdline_setup_auth_baton(&(callbacks->auth_baton),
TRUE, /* non_interactive */
NULL, /* username */
NULL, /* password */
NULL, /* config_dir */
FALSE, /* no_auth_cache */
apr_hash_get(cfg_hash,
SVN_CONFIG_CATEGORY_CONFIG,
APR_HASH_KEY_STRING),
NULL, /* cancel_func */
NULL, /* cancel_baton */
pool));
}
/* Try something simple enough. */
{
svn_ra_session_t *ra;
svn_revnum_t head;
apr_hash_t *dirents;
apr_hash_t *props;
ERR(svn_ra_open2(&ra, argv[1], callbacks, NULL, cfg_hash, pool));
ERR(svn_ra_get_latest_revnum(ra, &head, pool));
puts("doing get_dir2 on a file (welcome)");
ERR(svn_ra_get_dir2(ra, &dirents,
NULL, /* fetched_rev */
&props,
"welcome", /* path */
SVN_INVALID_REVNUM,
0, /* dirent_fields */
pool));
printf("bad, should have died but got %p %p (%d dirents)\n",
props, dirents,
apr_hash_count(dirents));
{
apr_hash_index_t *hi;
const char *dirname;
svn_dirent_t *dirent;
for (hi = apr_hash_first(pool, dirents); hi; hi = apr_hash_next(hi)) {
apr_hash_this(hi, (const void **)&dirname, NULL,
(void **)&dirent);
printf("%s %s\n", dirent->kind == svn_node_file ? "-" : "d",
dirname);
}
}
}
svn_pool_destroy(pool);
return 0;
}
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
/* for svn initialization */
#include <apr_errno.h>
#include <apr_general.h>
#include <apr_strings.h>
#include <svn_auth.h>
#include <svn_cmdline.h>
#include <svn_config.h>
#include <svn_dso.h>
#include <svn_nls.h>
#include <svn_pools.h>
/* for svn_ra_get_dir2 */
#include <apr_hash.h>
#include <svn_error.h>
#include <svn_io.h>
#include <svn_path.h>
#include <svn_ra.h>
static svn_error_t *
open_tmp_file(apr_file_t **fp, void *baton, apr_pool_t *pool)
{
const char *base_fn, *base_path, *fn;
SVN_ERR(svn_io_temp_dir(&base_fn, pool));
base_path = svn_path_join(base_fn, "foo", pool);
return svn_io_open_unique_file2(fp, &fn, base_path, ".tmp",
svn_io_file_del_on_close, pool);
}
#define ERR(expr) \
do { \
svn_error_t *err = (expr); \
if (err) { \
fprintf(stderr, "%s:%ld: (apr_err=%d)\nfoo: %s\n", \
err->file, err->line, err->apr_err, \
err->message); \
svn_error_clear(err); \
svn_pool_destroy(pool); \
return 1; \
} \
} while (0)
int
main(int argc, char *argv[])
{
apr_pool_t *pool;
apr_hash_t *cfg_hash;
long revision;
svn_ra_callbacks2_t *callbacks;
if (argc < 3 || (argv[1] && argv[1][0] == '-')) {
fputs("usage: foo URL REVISION\n", stderr);
if (argv[1] && argv[1][0] == '-') {
return 0;
}
return 2;
}
errno = 0;
revision = strtol(argv[2], NULL, 10);
if (errno != 0) {
fprintf(stderr, "foo: strtol(%s): ", argv[2]);
perror("");
return 3;
}
/* Initialize svn. */
{
apr_status_t apr_status;
char buf[1024];
if ((apr_status = apr_initialize()) != APR_SUCCESS) {
apr_strerror(apr_status, buf, sizeof(buf) - 1);
fprintf(stderr, "foo: cannot initialize APR: %s\n", buf);
return 1;
}
svn_dso_initialize();
if (atexit(apr_terminate) != 0) {
fputs("atexit registration failed\n", stderr);
return 1;
}
pool = svn_pool_create(NULL);
svn_utf_initialize(pool);
ERR(svn_nls_init());
ERR(svn_config_get_config(&cfg_hash, NULL, pool));
ERR(svn_ra_initialize(pool));
ERR(svn_ra_create_callbacks(&callbacks, pool));
callbacks->open_tmp_file = open_tmp_file;
ERR(svn_cmdline_setup_auth_baton(&(callbacks->auth_baton),
TRUE, /* non_interactive */
NULL, /* username */
NULL, /* password */
NULL, /* config_dir */
FALSE, /* no_auth_cache */
apr_hash_get(cfg_hash,
SVN_CONFIG_CATEGORY_CONFIG,
APR_HASH_KEY_STRING),
NULL, /* cancel_func */
NULL, /* cancel_baton */
pool));
}
/* Try something simple enough. */
{
svn_ra_session_t *ra;
svn_revnum_t head, fetched_rev;
svn_stream_t *stdout_stream;
apr_hash_t *props;
ERR(svn_ra_open2(&ra, argv[1], callbacks, NULL, cfg_hash, pool));
ERR(svn_ra_get_latest_revnum(ra, &head, pool));
ERR(svn_stream_for_stdout(&stdout_stream, pool));
puts("doing get_file on a dir (changes)");
ERR(svn_ra_get_file(ra,
"changes", /* path */
SVN_INVALID_REVNUM,
stdout_stream, &fetched_rev,
&props,
pool));
puts("bad, should have died");
}
svn_pool_destroy(pool);
return 0;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-05-21 01:56:28 CEST