[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Add a --prefix-file switch to svndumpfilter

From: Hyrum K. Wright <hyrum_wright_at_mail.utexas.edu>
Date: 2006-12-19 22:53:54 CET

Eric Dorland wrote:
> Hello,
>
> I was recently extracting a project out of a fairly large svn repo, that
> had been converted from a CVS repo, so I needed a rather large number of
> exclude prefixes, more than I could pass as arguments to svndumpfilter.
> So the attached patch adds a --prefix-file switch which allows one to
> pass a file containing newline separated prefix paths instead of passing
> them on the command line. Hopefully it passes muster :)

Ping...

Would a committer take a moment to comment on Eric's patch? If nothing
happens I'll file an issue in a few days.

(Personally, I think the feature is useful, and using '-F' or
'--targets' in this context would make sense.)

-Hyrum

>
> ------------------------------------------------------------------------
>
> --- subversion-1.4.2dfsg1/subversion/svndumpfilter/main.c 2006-07-12 13:07:21.000000000 -0400
> +++ subversion-1.4.2dfsg1.new/subversion/svndumpfilter/main.c 2006-12-03 17:36:15.000000000 -0500
> @@ -766,6 +766,7 @@
> svndumpfilter__drop_empty_revs = SVN_OPT_FIRST_LONGOPT_ID,
> svndumpfilter__renumber_revs,
> svndumpfilter__preserve_revprops,
> + svndumpfilter__prefix_file,
> svndumpfilter__quiet,
> svndumpfilter__version
> };
> @@ -792,6 +793,8 @@
> N_("Renumber revisions left after filtering.") },
> {"preserve-revprops", svndumpfilter__preserve_revprops, 0,
> N_("Don't filter revision properties.") },
> + {"prefix-file", svndumpfilter__prefix_file, 1,
> + N_("Read prefix paths from file ARG.")},
> {NULL}
> };
>
> @@ -805,13 +808,15 @@
> N_("Filter out nodes with given prefixes from dumpstream.\n"
> "usage: svndumpfilter exclude PATH_PREFIX...\n"),
> {svndumpfilter__drop_empty_revs, svndumpfilter__renumber_revs,
> - svndumpfilter__preserve_revprops, svndumpfilter__quiet} },
> + svndumpfilter__preserve_revprops, svndumpfilter__prefix_file,
> + svndumpfilter__quiet} },
>
> {"include", subcommand_include, {0},
> N_("Filter out nodes without given prefixes from dumpstream.\n"
> "usage: svndumpfilter include PATH_PREFIX...\n"),
> {svndumpfilter__drop_empty_revs, svndumpfilter__renumber_revs,
> - svndumpfilter__preserve_revprops, svndumpfilter__quiet} },
> + svndumpfilter__preserve_revprops, svndumpfilter__prefix_file,
> + svndumpfilter__quiet} },
>
> {"help", subcommand_help, {"?", "h"},
> N_("Describe the usage of this program or its subcommands.\n"
> @@ -833,6 +838,7 @@
> svn_boolean_t help; /* --help or -? */
> svn_boolean_t renumber_revs; /* --renumber-revs */
> svn_boolean_t preserve_revprops; /* --preserve-revprops */
> + const char *prefix_file; /* --prefix-file */
> apr_array_header_t *prefixes; /* mainargs. */
> };
>
> @@ -1168,6 +1174,9 @@
> case svndumpfilter__preserve_revprops:
> opt_state.preserve_revprops = TRUE;
> break;
> + case svndumpfilter__prefix_file:
> + opt_state.prefix_file = opt_arg;
> + break;
> default:
> {
> subcommand_help(NULL, NULL, pool);
> @@ -1238,15 +1247,7 @@
>
> if (subcommand->cmd_func != subcommand_help)
> {
> - if (os->ind >= os->argc)
> - {
> - svn_error_clear(svn_cmdline_fprintf
> - (stderr, pool,
> - _("\nError: no prefixes supplied.\n")));
> - svn_pool_destroy(pool);
> - return EXIT_FAILURE;
> - }
> -
> +
> opt_state.prefixes = apr_array_make(pool, os->argc - os->ind,
> sizeof(const char *));
> for (i = os->ind ; i< os->argc; i++)
> @@ -1260,6 +1261,46 @@
> prefix = svn_path_join("/", prefix, pool);
> APR_ARRAY_PUSH(opt_state.prefixes, const char *) = prefix;
> }
> + if (opt_state.prefix_file)
> + {
> + apr_file_t *prefix_file;
> + svn_stream_t *stream;
> + svn_stringbuf_t *line;
> + const char *prefix;
> + svn_boolean_t eof;
> +
> + SVN_INT_ERR(svn_io_file_open(&prefix_file, opt_state.prefix_file,
> + APR_FOPEN_READ, 0, pool));
> + stream = svn_stream_from_aprfile2(prefix_file, FALSE, pool);
> +
> + while (TRUE)
> + {
> + SVN_INT_ERR(svn_stream_readline(stream, &line, "\n", &eof,
> + pool));
> + if (eof)
> + break;
> +
> + if (!svn_stringbuf_isempty(line))
> + {
> + SVN_INT_ERR(svn_utf_cstring_to_utf8(&prefix, line->data,
> + pool));
> + prefix = svn_path_internal_style(prefix, pool);
> + prefix = svn_path_join("/", prefix, pool);
> + APR_ARRAY_PUSH(opt_state.prefixes, const char *) = prefix;
> + }
> + }
> +
> + svn_stream_close(stream);
> + }
> +
> + if (apr_is_empty_array(opt_state.prefixes))
> + {
> + svn_error_clear(svn_cmdline_fprintf
> + (stderr, pool,
> + _("\nError: no prefixes supplied.\n")));
> + svn_pool_destroy(pool);
> + return EXIT_FAILURE;
> + }
> }
>
>

Received on Tue Dec 19 22:54:14 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.