diff options
author | Peter Wemm <peter@FreeBSD.org> | 2018-05-08 03:44:38 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2018-05-08 03:44:38 +0000 |
commit | 3faf8d6bffc5d0fb2525ba37bb504c53366caf9d (patch) | |
tree | 7e47911263e75034b767fe34b2f8d3d17e91f66d /subversion/svnrdump | |
parent | a55fb3c0d5eca7d887798125d5b95942b1f01d4b (diff) |
Import Subversion-1.10.0vendor/subversion/subversion-1.10.0
Notes
Notes:
svn path=/vendor/subversion/dist/; revision=333347
svn path=/vendor/subversion/subversion-1.10.0/; revision=333348; tag=vendor/subversion/subversion-1.10.0
Diffstat (limited to 'subversion/svnrdump')
-rw-r--r-- | subversion/svnrdump/dump_editor.c | 11 | ||||
-rw-r--r-- | subversion/svnrdump/load_editor.c | 45 | ||||
-rw-r--r-- | subversion/svnrdump/svnrdump.c | 148 | ||||
-rw-r--r-- | subversion/svnrdump/svnrdump.h | 17 | ||||
-rw-r--r-- | subversion/svnrdump/util.c | 34 |
5 files changed, 113 insertions, 142 deletions
diff --git a/subversion/svnrdump/dump_editor.c b/subversion/svnrdump/dump_editor.c index bf4f81c8bdab..f900e209e276 100644 --- a/subversion/svnrdump/dump_editor.c +++ b/subversion/svnrdump/dump_editor.c @@ -879,7 +879,7 @@ close_file(void *file_baton, { struct file_baton *fb = file_baton; struct dump_edit_baton *eb = fb->eb; - apr_finfo_t *info = apr_pcalloc(pool, sizeof(apr_finfo_t)); + svn_filesize_t text_content_length = 0; svn_stringbuf_t *propstring = NULL; svn_repos__dumpfile_headers_t *headers; @@ -903,15 +903,12 @@ close_file(void *file_baton, /* Dump the text headers */ if (fb->dump_text) { - apr_status_t err; - /* Text-delta: true */ svn_repos__dumpfile_header_push( headers, SVN_REPOS_DUMPFILE_TEXT_DELTA, "true"); - err = apr_file_info_get(info, APR_FINFO_SIZE, eb->delta_file); - if (err) - SVN_ERR(svn_error_wrap_apr(err, NULL)); + SVN_ERR(svn_io_file_size_get(&text_content_length, eb->delta_file, + pool)); if (fb->base_checksum) /* Text-delta-base-md5: */ @@ -925,7 +922,7 @@ close_file(void *file_baton, /* Dump the headers and props now */ SVN_ERR(svn_repos__dump_node_record(eb->stream, headers, propstring, - fb->dump_text, info->size, + fb->dump_text, text_content_length, FALSE /*content_length_always*/, pool)); diff --git a/subversion/svnrdump/load_editor.c b/subversion/svnrdump/load_editor.c index 15dac6e98f18..2ebacf79e1b5 100644 --- a/subversion/svnrdump/load_editor.c +++ b/subversion/svnrdump/load_editor.c @@ -167,8 +167,7 @@ set_revision_mapping(apr_hash_t *rev_map, sizeof(svn_revnum_t) * 2); mapped_revs[0] = from_rev; mapped_revs[1] = to_rev; - apr_hash_set(rev_map, mapped_revs, - sizeof(svn_revnum_t), mapped_revs + 1); + apr_hash_set(rev_map, mapped_revs, sizeof(*mapped_revs), mapped_revs + 1); } /* Return the revision to which FROM_REV maps in REV_MAP, or @@ -392,7 +391,7 @@ new_revision_record(void **revision_baton, { struct revision_baton *rb; struct parse_baton *pb; - apr_hash_index_t *hi; + const char *rev_str; svn_revnum_t head_rev; rb = apr_pcalloc(pool, sizeof(*rb)); @@ -401,14 +400,9 @@ new_revision_record(void **revision_baton, rb->pb = pb; rb->db = NULL; - for (hi = apr_hash_first(pool, headers); hi; hi = apr_hash_next(hi)) - { - const char *hname = apr_hash_this_key(hi); - const char *hval = apr_hash_this_val(hi); - - if (strcmp(hname, SVN_REPOS_DUMPFILE_REVISION_NUMBER) == 0) - rb->rev = atoi(hval); - } + rev_str = svn_hash_gets(headers, SVN_REPOS_DUMPFILE_REVISION_NUMBER); + if (rev_str) + rb->rev = SVN_STR_TO_REV(rev_str); SVN_ERR(svn_ra_get_latest_revnum(pb->session, &head_rev, pool)); @@ -499,6 +493,7 @@ new_node_record(void **node_baton, const struct svn_delta_editor_t *commit_editor = rb->pb->commit_editor; void *commit_edit_baton = rb->pb->commit_edit_baton; struct node_baton *nb; + svn_revnum_t head_rev_before_commit = rb->rev - rb->rev_offset - 1; apr_hash_index_t *hi; void *child_baton; const char *nb_dirname; @@ -537,7 +532,7 @@ new_node_record(void **node_baton, rb->pb->commit_edit_baton = commit_edit_baton; SVN_ERR(commit_editor->open_root(commit_edit_baton, - rb->rev - rb->rev_offset - 1, + head_rev_before_commit, rb->pool, &child_baton)); /* child_baton corresponds to the root directory baton here */ @@ -570,7 +565,7 @@ new_node_record(void **node_baton, if (strcmp(hname, SVN_REPOS_DUMPFILE_TEXT_DELTA_BASE_MD5) == 0) nb->base_checksum = apr_pstrdup(rb->pool, hval); if (strcmp(hname, SVN_REPOS_DUMPFILE_NODE_COPYFROM_REV) == 0) - nb->copyfrom_rev = atoi(hval); + nb->copyfrom_rev = SVN_STR_TO_REV(hval); if (strcmp(hname, SVN_REPOS_DUMPFILE_NODE_COPYFROM_PATH) == 0) nb->copyfrom_path = apr_pstrdup(rb->pool, hval); } @@ -617,7 +612,7 @@ new_node_record(void **node_baton, rb->pool); SVN_ERR(commit_editor->open_directory(relpath_compose, rb->db->baton, - rb->rev - rb->rev_offset - 1, + head_rev_before_commit, rb->pool, &child_baton)); push_directory(rb, child_baton, relpath_compose, TRUE /*is_added*/, NULL, SVN_INVALID_REVNUM); @@ -660,7 +655,7 @@ new_node_record(void **node_baton, case svn_node_action_delete: case svn_node_action_replace: SVN_ERR(commit_editor->delete_entry(nb->path, - rb->rev - rb->rev_offset - 1, + head_rev_before_commit, rb->db->baton, rb->pool)); if (nb->action == svn_node_action_delete) break; @@ -698,7 +693,7 @@ new_node_record(void **node_baton, break; default: SVN_ERR(commit_editor->open_directory(nb->path, rb->db->baton, - rb->rev - rb->rev_offset - 1, + head_rev_before_commit, rb->pool, &child_baton)); push_directory(rb, child_baton, nb->path, FALSE /*is_added*/, NULL, SVN_INVALID_REVNUM); @@ -718,16 +713,15 @@ set_revision_property(void *baton, { struct revision_baton *rb = baton; - SVN_ERR(svn_rdump__normalize_prop(name, &value, rb->pool)); - + SVN_ERR(svn_repos__normalize_prop(&value, NULL, name, value, + rb->pool, rb->pool)); SVN_ERR(svn_repos__validate_prop(name, value, rb->pool)); if (rb->rev > 0) { if (! svn_hash_gets(rb->pb->skip_revprops, name)) svn_hash_sets(rb->revprop_table, - apr_pstrdup(rb->pool, name), - svn_string_dup(value, rb->pool)); + apr_pstrdup(rb->pool, name), value); } else if (rb->rev_offset == -1 && ! svn_hash_gets(rb->pb->skip_revprops, name)) @@ -742,9 +736,9 @@ set_revision_property(void *baton, /* Remember any datestamp/ author that passes through (see comment in close_revision). */ if (!strcmp(name, SVN_PROP_REVISION_DATE)) - rb->datestamp = svn_string_dup(value, rb->pool); + rb->datestamp = value; if (!strcmp(name, SVN_PROP_REVISION_AUTHOR)) - rb->author = svn_string_dup(value, rb->pool); + rb->author = value; return SVN_NO_ERROR; } @@ -781,13 +775,13 @@ set_node_property(void *baton, value = new_value; } - SVN_ERR(svn_rdump__normalize_prop(name, &value, pool)); + SVN_ERR(svn_repos__normalize_prop(&value, NULL, name, value, pool, pool)); SVN_ERR(svn_repos__validate_prop(name, value, pool)); prop = apr_palloc(nb->rb->pool, sizeof (*prop)); prop->name = apr_pstrdup(pool, name); - prop->value = svn_string_dup(value, pool); + prop->value = value; svn_hash_sets(nb->prop_changes, prop->name, prop); return SVN_NO_ERROR; @@ -988,6 +982,7 @@ close_revision(void *baton) } else { + svn_revnum_t head_rev_before_commit = rb->rev - rb->rev_offset - 1; void *child_baton; /* Legitimate revision with no node information */ @@ -997,7 +992,7 @@ close_revision(void *baton) NULL, FALSE, rb->pool)); SVN_ERR(commit_editor->open_root(commit_edit_baton, - rb->rev - rb->rev_offset - 1, + head_rev_before_commit, rb->pool, &child_baton)); SVN_ERR(commit_editor->close_directory(child_baton, rb->pool)); diff --git a/subversion/svnrdump/svnrdump.c b/subversion/svnrdump/svnrdump.c index df0286bca562..50b8a8983b66 100644 --- a/subversion/svnrdump/svnrdump.c +++ b/subversion/svnrdump/svnrdump.c @@ -22,7 +22,6 @@ * ==================================================================== */ -#include <apr_signal.h> #include <apr_uri.h> #include "svn_pools.h" @@ -47,27 +46,8 @@ /*** Cancellation ***/ -/* A flag to see if we've been cancelled by the client or not. */ -static volatile sig_atomic_t cancelled = FALSE; - -/* A signal handler to support cancellation. */ -static void -signal_handler(int signum) -{ - apr_signal(signum, SIG_IGN); - cancelled = TRUE; -} - /* Our cancellation callback. */ -static svn_error_t * -check_cancel(void *baton) -{ - if (cancelled) - return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal")); - else - return SVN_NO_ERROR; -} - +static svn_cancel_func_t check_cancel = NULL; @@ -79,6 +59,7 @@ enum svn_svnrdump__longopt_t opt_config_option, opt_auth_username, opt_auth_password, + opt_auth_password_from_stdin, opt_auth_nocache, opt_non_interactive, opt_skip_revprop, @@ -93,6 +74,7 @@ enum svn_svnrdump__longopt_t opt_config_option, \ opt_auth_username, \ opt_auth_password, \ + opt_auth_password_from_stdin, \ opt_auth_nocache, \ opt_trust_server_cert, \ opt_trust_server_cert_failures, \ @@ -134,6 +116,8 @@ static const apr_getopt_option_t svnrdump__options[] = N_("specify a username ARG")}, {"password", opt_auth_password, 1, N_("specify a password ARG")}, + {"password-from-stdin", opt_auth_password_from_stdin, 0, + N_("read password from stdin")}, {"non-interactive", opt_non_interactive, 0, N_("do no interactive prompting (default is to prompt\n" " " @@ -174,6 +158,7 @@ static const apr_getopt_option_t svnrdump__options[] = "valid certificate) and 'other' (all other not\n" " " "separately classified certificate errors).")}, + {"dumpfile", 'F', 1, N_("Read or write to a dumpfile instead of stdin/stdout")}, {0, 0, 0, 0} }; @@ -194,6 +179,7 @@ typedef struct opt_baton_t { svn_client_ctx_t *ctx; svn_ra_session_t *session; const char *url; + const char *dumpfile; svn_boolean_t help; svn_boolean_t version; svn_opt_revision_t start_revision; @@ -483,31 +469,39 @@ replay_revisions(svn_ra_session_t *session, svn_revnum_t end_revision, svn_boolean_t quiet, svn_boolean_t incremental, + const char *dumpfile, apr_pool_t *pool) { struct replay_baton *replay_baton; const char *uuid; - svn_stream_t *stdout_stream; + svn_stream_t *output_stream; - SVN_ERR(svn_stream_for_stdout(&stdout_stream, pool)); + if (dumpfile) + { + SVN_ERR(svn_stream_open_writable(&output_stream, dumpfile, pool, pool)); + } + else + { + SVN_ERR(svn_stream_for_stdout(&output_stream, pool)); + } replay_baton = apr_pcalloc(pool, sizeof(*replay_baton)); - replay_baton->stdout_stream = stdout_stream; + replay_baton->stdout_stream = output_stream; replay_baton->extra_ra_session = extra_ra_session; replay_baton->quiet = quiet; /* Write the magic header and UUID */ - SVN_ERR(svn_stream_printf(stdout_stream, pool, + SVN_ERR(svn_stream_printf(output_stream, pool, SVN_REPOS_DUMPFILE_MAGIC_HEADER ": %d\n\n", SVN_REPOS_DUMPFILE_FORMAT_VERSION)); SVN_ERR(svn_ra_get_uuid2(session, &uuid, pool)); - SVN_ERR(svn_stream_printf(stdout_stream, pool, + SVN_ERR(svn_stream_printf(output_stream, pool, SVN_REPOS_DUMPFILE_UUID ": %s\n\n", uuid)); /* Fake revision 0 if necessary */ if (start_revision == 0) { - SVN_ERR(dump_revision_header(session, stdout_stream, + SVN_ERR(dump_revision_header(session, output_stream, start_revision, pool)); /* Revision 0 has no tree changes, so we're done. */ @@ -526,7 +520,7 @@ replay_revisions(svn_ra_session_t *session, if (!incremental) { SVN_ERR(dump_initial_full_revision(session, extra_ra_session, - stdout_stream, start_revision, + output_stream, start_revision, quiet, pool)); start_revision++; } @@ -546,7 +540,6 @@ replay_revisions(svn_ra_session_t *session, #endif } - SVN_ERR(svn_stream_close(stdout_stream)); return SVN_NO_ERROR; } @@ -559,23 +552,26 @@ replay_revisions(svn_ra_session_t *session, static svn_error_t * load_revisions(svn_ra_session_t *session, svn_ra_session_t *aux_session, - const char *url, + const char *dumpfile, svn_boolean_t quiet, apr_hash_t *skip_revprops, apr_pool_t *pool) { - apr_file_t *stdin_file; - svn_stream_t *stdin_stream; + svn_stream_t *output_stream; - apr_file_open_stdin(&stdin_file, pool); - stdin_stream = svn_stream_from_aprfile2(stdin_file, FALSE, pool); + if (dumpfile) + { + SVN_ERR(svn_stream_open_readonly(&output_stream, dumpfile, pool, pool)); + } + else + { + SVN_ERR(svn_stream_for_stdin2(&output_stream, TRUE, pool)); + } - SVN_ERR(svn_rdump__load_dumpstream(stdin_stream, session, aux_session, + SVN_ERR(svn_rdump__load_dumpstream(output_stream, session, aux_session, quiet, skip_revprops, check_cancel, NULL, pool)); - SVN_ERR(svn_stream_close(stdin_stream)); - return SVN_NO_ERROR; } @@ -641,7 +637,8 @@ dump_cmd(apr_getopt_t *os, return replay_revisions(opt_baton->session, extra_ra_session, opt_baton->start_revision.value.number, opt_baton->end_revision.value.number, - opt_baton->quiet, opt_baton->incremental, pool); + opt_baton->quiet, opt_baton->incremental, + opt_baton->dumpfile, pool); } /* Handle the "load" subcommand. Implements `svn_opt_subcommand_t'. */ @@ -655,8 +652,9 @@ load_cmd(apr_getopt_t *os, SVN_ERR(svn_client_open_ra_session2(&aux_session, opt_baton->url, NULL, opt_baton->ctx, pool, pool)); - return load_revisions(opt_baton->session, aux_session, opt_baton->url, - opt_baton->quiet, opt_baton->skip_revprops, pool); + return load_revisions(opt_baton->session, aux_session, + opt_baton->dumpfile, opt_baton->quiet, + opt_baton->skip_revprops, pool); } /* Handle the "help" subcommand. Implements `svn_opt_subcommand_t'. */ @@ -795,42 +793,23 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool) svn_boolean_t force_interactive = FALSE; apr_array_header_t *config_options = NULL; apr_getopt_t *os; - const char *first_arg; apr_array_header_t *received_opts; int i; + svn_boolean_t read_pass_from_stdin = FALSE; opt_baton = apr_pcalloc(pool, sizeof(*opt_baton)); opt_baton->start_revision.kind = svn_opt_revision_unspecified; opt_baton->end_revision.kind = svn_opt_revision_unspecified; opt_baton->url = NULL; opt_baton->skip_revprops = apr_hash_make(pool); + opt_baton->dumpfile = NULL; SVN_ERR(svn_cmdline__getopt_init(&os, argc, argv, pool)); os->interleave = TRUE; /* Options and arguments can be interleaved */ /* Set up our cancellation support. */ - apr_signal(SIGINT, signal_handler); -#ifdef SIGBREAK - /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */ - apr_signal(SIGBREAK, signal_handler); -#endif -#ifdef SIGHUP - apr_signal(SIGHUP, signal_handler); -#endif -#ifdef SIGTERM - apr_signal(SIGTERM, signal_handler); -#endif -#ifdef SIGPIPE - /* Disable SIGPIPE generation for the platforms that have it. */ - apr_signal(SIGPIPE, SIG_IGN); -#endif -#ifdef SIGXFSZ - /* Disable SIGXFSZ generation for the platforms that have it, otherwise - * working with large files when compiled against an APR that doesn't have - * large file support will crash the program, which is uncool. */ - apr_signal(SIGXFSZ, SIG_IGN); -#endif + check_cancel = svn_cmdline__setup_cancellation_handler(); received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int)); @@ -896,6 +875,9 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool) case opt_auth_password: SVN_ERR(svn_utf_cstring_to_utf8(&password, opt_arg, pool)); break; + case opt_auth_password_from_stdin: + read_pass_from_stdin = TRUE; + break; case opt_auth_nocache: no_auth_cache = TRUE; break; @@ -936,6 +918,11 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool) opt_arg, "svnrdump: ", pool)); + break; + case 'F': + SVN_ERR(svn_utf_cstring_to_utf8(&opt_arg, opt_arg, pool)); + opt_baton->dumpfile = opt_arg; + break; } } @@ -977,19 +964,19 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool) } else { - first_arg = os->argv[os->ind++]; + const char *first_arg; + + SVN_ERR(svn_utf_cstring_to_utf8(&first_arg, os->argv[os->ind++], + pool)); subcommand = svn_opt_get_canonical_subcommand2(svnrdump__cmd_table, first_arg); if (subcommand == NULL) { - const char *first_arg_utf8; - SVN_ERR(svn_utf_cstring_to_utf8(&first_arg_utf8, first_arg, - pool)); svn_error_clear( svn_cmdline_fprintf(stderr, pool, _("Unknown subcommand: '%s'\n"), - first_arg_utf8)); + first_arg)); SVN_ERR(help_cmd(NULL, NULL, pool)); *exit_code = EXIT_FAILURE; return SVN_NO_ERROR; @@ -1051,6 +1038,24 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool) "--non-interactive")); } + if (read_pass_from_stdin && !non_interactive) + { + return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL, + _("--password-from-stdin requires " + "--non-interactive")); + } + + if (strcmp(subcommand->name, "load") == 0) + { + if (read_pass_from_stdin && opt_baton->dumpfile == NULL) + { + /* error here, since load cannot process a password over stdin */ + return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL, + _("load subcommand with " + "--password-from-stdin requires -F")); + } + } + /* Expect one more non-option argument: the repository URL. */ if (os->ind != os->argc - 1) { @@ -1085,6 +1090,12 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool) force_interactive = (username == NULL || password == NULL); } + /* Get password from stdin if necessary */ + if (read_pass_from_stdin) + { + SVN_ERR(svn_cmdline__stdin_readline(&password, pool, pool)); + } + non_interactive = !svn_cmdline__be_interactive(non_interactive, force_interactive); @@ -1162,5 +1173,8 @@ main(int argc, const char *argv[]) } svn_pool_destroy(pool); + + svn_cmdline__cancellation_exit(); + return exit_code; } diff --git a/subversion/svnrdump/svnrdump.h b/subversion/svnrdump/svnrdump.h index 919ea5e1e844..b6ac7c1bf2bc 100644 --- a/subversion/svnrdump/svnrdump.h +++ b/subversion/svnrdump/svnrdump.h @@ -100,29 +100,12 @@ svn_rdump__load_dumpstream(svn_stream_t *stream, * currently all svn:* props) so that they contain only LF (\n) line endings. * * Put the normalized props into NORMAL_PROPS, allocated in RESULT_POOL. - * - * Note: this function does not do a deep copy; it is expected that PROPS has - * a longer lifetime than NORMAL_PROPS. */ svn_error_t * svn_rdump__normalize_props(apr_hash_t **normal_props, apr_hash_t *props, apr_pool_t *result_pool); -/* Normalize the line ending style of a single property that "needs - * translation" (according to svn_prop_needs_translation(), - * currently all svn:* props) so that they contain only LF (\n) line endings. - * "\r" characters found mid-line are replaced with "\n". - * "\r\n" sequences are replaced with "\n" - * - * NAME is used to check that VALUE should be normalized, and if this is the - * case, VALUE is then normalized, allocated from RESULT_POOL - */ -svn_error_t * -svn_rdump__normalize_prop(const char *name, - const svn_string_t **value, - apr_pool_t *result_pool); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/subversion/svnrdump/util.c b/subversion/svnrdump/util.c index 9a89c8918da9..e612b12b48af 100644 --- a/subversion/svnrdump/util.c +++ b/subversion/svnrdump/util.c @@ -21,53 +21,35 @@ * ==================================================================== */ -#include "svn_error.h" -#include "svn_pools.h" -#include "svn_string.h" -#include "svn_props.h" -#include "svn_subst.h" +#include "private/svn_repos_private.h" #include "svnrdump.h" svn_error_t * -svn_rdump__normalize_prop(const char *name, - const svn_string_t **value, - apr_pool_t *result_pool) -{ - if (svn_prop_needs_translation(name) && *value) - { - const char *cstring; - - SVN_ERR(svn_subst_translate_cstring2((*value)->data, &cstring, - "\n", TRUE, - NULL, FALSE, - result_pool)); - - *value = svn_string_create(cstring, result_pool); - } - return SVN_NO_ERROR; -} - -svn_error_t * svn_rdump__normalize_props(apr_hash_t **normal_props, apr_hash_t *props, apr_pool_t *result_pool) { apr_hash_index_t *hi; + apr_pool_t *iterpool; *normal_props = apr_hash_make(result_pool); + iterpool = svn_pool_create(result_pool); for (hi = apr_hash_first(result_pool, props); hi; hi = apr_hash_next(hi)) { const char *key = apr_hash_this_key(hi); const svn_string_t *value = apr_hash_this_val(hi); - SVN_ERR(svn_rdump__normalize_prop(key, &value, - result_pool)); + svn_pool_clear(iterpool); + SVN_ERR(svn_repos__normalize_prop(&value, NULL, key, value, + result_pool, iterpool)); svn_hash_sets(*normal_props, key, value); } + svn_pool_destroy(iterpool); + return SVN_NO_ERROR; } |