aboutsummaryrefslogtreecommitdiffstats
path: root/subversion/svndumpfilter/svndumpfilter.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2018-05-08 03:44:38 +0000
committerPeter Wemm <peter@FreeBSD.org>2018-05-08 03:44:38 +0000
commit3faf8d6bffc5d0fb2525ba37bb504c53366caf9d (patch)
tree7e47911263e75034b767fe34b2f8d3d17e91f66d /subversion/svndumpfilter/svndumpfilter.c
parenta55fb3c0d5eca7d887798125d5b95942b1f01d4b (diff)
downloadsrc-3faf8d6bffc5d0fb2525ba37bb504c53366caf9d.tar.gz
src-3faf8d6bffc5d0fb2525ba37bb504c53366caf9d.zip
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/svndumpfilter/svndumpfilter.c')
-rw-r--r--subversion/svndumpfilter/svndumpfilter.c73
1 files changed, 18 insertions, 55 deletions
diff --git a/subversion/svndumpfilter/svndumpfilter.c b/subversion/svndumpfilter/svndumpfilter.c
index 922482b6787d..b17ccd2e6588 100644
--- a/subversion/svndumpfilter/svndumpfilter.c
+++ b/subversion/svndumpfilter/svndumpfilter.c
@@ -48,42 +48,8 @@
#include "private/svn_cmdline_private.h"
#include "private/svn_sorts_private.h"
-#ifdef _WIN32
-typedef apr_status_t (__stdcall *open_fn_t)(apr_file_t **, apr_pool_t *);
-#else
-typedef apr_status_t (*open_fn_t)(apr_file_t **, apr_pool_t *);
-#endif
-
/*** Code. ***/
-/* Helper to open stdio streams */
-
-/* NOTE: we used to call svn_stream_from_stdio(), which wraps a stream
- around a standard stdio.h FILE pointer. The problem is that these
- pointers operate through C Run Time (CRT) on Win32, which does all
- sorts of translation on them: LF's become CRLF's, and ctrl-Z's
- embedded in Word documents are interpreted as premature EOF's.
-
- So instead, we use apr_file_open_std*, which bypass the CRT and
- directly wrap the OS's file-handles, which don't know or care about
- translation. Thus dump/load works correctly on Win32.
-*/
-static svn_error_t *
-create_stdio_stream(svn_stream_t **stream,
- open_fn_t open_fn,
- apr_pool_t *pool)
-{
- apr_file_t *stdio_file;
- apr_status_t apr_err = open_fn(&stdio_file, pool);
-
- if (apr_err)
- return svn_error_wrap_apr(apr_err, _("Can't open stdio file"));
-
- *stream = svn_stream_from_aprfile2(stdio_file, TRUE, pool);
- return SVN_NO_ERROR;
-}
-
-
/* Writes a property in dumpfile format to given stringbuf. */
static void
write_prop_to_stringbuf(svn_stringbuf_t *strbuf,
@@ -143,6 +109,7 @@ write_propdel_to_stringbuf(svn_stringbuf_t **strbuf,
* Return TRUE if any prefix is a prefix of PATH (matching whole path
* components); FALSE otherwise.
* PATH starts with a '/', as do the (const char *) paths in PREFIXES. */
+/* This function is a duplicate of svnadmin.c:ary_prefix_match(). */
static svn_boolean_t
ary_prefix_match(const apr_array_header_t *pfxlist, const char *path)
{
@@ -640,7 +607,7 @@ new_node_record(void **node_baton,
cf_orig_rev = SVN_STR_TO_REV(val);
cf_renum_val = apr_hash_get(pb->renumber_history,
&cf_orig_rev,
- sizeof(svn_revnum_t));
+ sizeof(cf_orig_rev));
if (! (cf_renum_val && SVN_IS_VALID_REVNUM(cf_renum_val->rev)))
return svn_error_createf
(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
@@ -730,14 +697,14 @@ adjust_mergeinfo(svn_string_t **final_val, const svn_string_t *initial_val,
svn_merge_range_t *);
revmap_start = apr_hash_get(pb->renumber_history,
- &range->start, sizeof(svn_revnum_t));
+ &range->start, sizeof(range->start));
if (! (revmap_start && SVN_IS_VALID_REVNUM(revmap_start->rev)))
return svn_error_createf
(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
_("No valid revision range 'start' in filtered stream"));
revmap_end = apr_hash_get(pb->renumber_history,
- &range->end, sizeof(svn_revnum_t));
+ &range->end, sizeof(range->end));
if (! (revmap_end && SVN_IS_VALID_REVNUM(revmap_end->rev)))
return svn_error_createf
(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
@@ -984,7 +951,10 @@ static const apr_getopt_option_t options_table[] =
{"quiet", svndumpfilter__quiet, 0,
N_("Do not display filtering statistics.") },
{"pattern", svndumpfilter__glob, 0,
- N_("Treat the path prefixes as file glob patterns.") },
+ N_("Treat the path prefixes as file glob patterns.\n"
+ " Glob special characters are '*' '?' '[]' and '\\'.\n"
+ " Character '/' is not treated specially, so\n"
+ " pattern /*/foo matches paths /a/foo and /a/b/foo.") },
{"drop-empty-revs", svndumpfilter__drop_empty_revs, 0,
N_("Remove revisions emptied by filtering.")},
{"drop-all-empty-revs", svndumpfilter__drop_all_empty_revs, 0,
@@ -1065,12 +1035,10 @@ parse_baton_initialize(struct parse_baton_t **pb,
struct parse_baton_t *baton = apr_palloc(pool, sizeof(*baton));
/* Read the stream from STDIN. Users can redirect a file. */
- SVN_ERR(create_stdio_stream(&(baton->in_stream),
- apr_file_open_stdin, pool));
+ SVN_ERR(svn_stream_for_stdin2(&baton->in_stream, TRUE, pool));
/* Have the parser dump results to STDOUT. Users can redirect a file. */
- SVN_ERR(create_stdio_stream(&(baton->out_stream),
- apr_file_open_stdout, pool));
+ SVN_ERR(svn_stream_for_stdout(&baton->out_stream, pool));
baton->do_exclude = do_exclude;
@@ -1404,7 +1372,8 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool)
opt_state.skip_missing_merge_sources = TRUE;
break;
case svndumpfilter__targets:
- opt_state.targets_file = opt_arg;
+ SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.targets_file,
+ opt_arg, pool));
break;
default:
{
@@ -1461,18 +1430,17 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool)
}
else
{
- const char *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(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(subcommand_help(NULL, NULL, pool));
*exit_code = EXIT_FAILURE;
return SVN_NO_ERROR;
@@ -1505,18 +1473,13 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool)
if (opt_state.targets_file)
{
svn_stringbuf_t *buffer, *buffer_utf8;
- const char *utf8_targets_file;
apr_array_header_t *targets = apr_array_make(pool, 0,
sizeof(const char *));
/* We need to convert to UTF-8 now, even before we divide
the targets into an array, because otherwise we wouldn't
know what delimiter to use for svn_cstring_split(). */
-
- SVN_ERR(svn_utf_cstring_to_utf8(&utf8_targets_file,
- opt_state.targets_file, pool));
-
- SVN_ERR(svn_stringbuf_from_file2(&buffer, utf8_targets_file,
+ SVN_ERR(svn_stringbuf_from_file2(&buffer, opt_state.targets_file,
pool));
SVN_ERR(svn_utf_stringbuf_to_utf8(&buffer_utf8, buffer, pool));