Joseph Dunn wrote:
> My bored co-worker came up with a small patch to make svnadmin
> dump recognize dates. We only tested it minimally, but it seems pretty
> straight forward. I've just inlined it between the hash marks.
Inspired by this patch, I've gone on and written a more complete version, noticing that the same code was used in "svnadmin deltify" as well, and adding validation to reject forms like "-rBASE".
I'll commit this in a couple of days if there are no objections.
I don't think we will port this to the 1.0 branch; it will appear first in version 1.1.0.
- Julian
> On Mon, 22 Mar 2004, Julian Foad wrote:
>
>>Thanks for reporting this. I can see in the code that the function 'subcommand_dump' does not currently handle the '{DATE}' method of specifying a revision. Unfortunately it does not throw an error, and just ignores the revision specification. It should throw an error for any revision specification that it cannot handle: not just dates, but also 'COMMITTED' etc.
Make 'svnadmin dump' and 'svnadmin deltify' recognise the '{DATE}' form of
revision specifiers, and error out on invalid forms like 'BASE'.
Previously, they silently ignored '{DATE}' and invalid revision specifiers.
Based on a patch by a colleague of Joseph Dunn <Joseph.Dunn@Colorado.EDU>.
* subversion/svnadmin/main.c
(get_revnum): New function, factored out from subcommand_deltify and
subcommand_dump and enhanced to accept dates and to reject invalid
revision specifiers.
(subcommand_deltify, subcommand_dump): Call get_revnum.
Index: subversion/svnadmin/main.c
===================================================================
--- subversion/svnadmin/main.c (revision 9208)
+++ subversion/svnadmin/main.c (working copy)
@@ -342,6 +342,36 @@ struct svnadmin_opt_state
};
+/* Set *REVNUM to the revision specified by REVISION (or to
+ SVN_INVALID_REVNUM if that has the type 'unspecified'),
+ possibly making use of the YOUNGEST revision number in REPOS. */
+static svn_error_t *
+get_revnum (svn_revnum_t *revnum, const svn_opt_revision_t *revision,
+ svn_revnum_t youngest, svn_repos_t *repos, apr_pool_t *pool)
+{
+ if (revision->kind == svn_opt_revision_number)
+ *revnum = revision->value.number;
+ else if (revision->kind == svn_opt_revision_head)
+ *revnum = youngest;
+ else if (revision->kind == svn_opt_revision_date)
+ SVN_ERR (svn_repos_dated_revision
+ (revnum, repos, revision->value.date, pool));
+ else if (revision->kind == svn_opt_revision_unspecified)
+ *revnum = SVN_INVALID_REVNUM;
+ else
+ return svn_error_create
+ (SVN_ERR_CL_ARG_PARSING_ERROR, NULL, "Invalid revision specifier");
+
+ if (*revnum > youngest)
+ return svn_error_createf
+ (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ "Revisions must not be greater than the youngest revision (%"
+ SVN_REVNUM_T_FMT ")", youngest);
+
+ return SVN_NO_ERROR;
+}
+
+
/* This implements `svn_opt_subcommand_t'. */
static svn_error_t *
subcommand_create (apr_getopt_t *os, void *baton, apr_pool_t *pool)
@@ -383,20 +413,11 @@ subcommand_deltify (apr_getopt_t *os, vo
fs = svn_repos_fs (repos);
SVN_ERR (svn_fs_youngest_rev (&youngest, fs, pool));
- /* ### We only handle revision numbers right now, not dates. */
- if (opt_state->start_revision.kind == svn_opt_revision_number)
- start = opt_state->start_revision.value.number;
- else if (opt_state->start_revision.kind == svn_opt_revision_head)
- start = youngest;
- else
- start = SVN_INVALID_REVNUM;
-
- if (opt_state->end_revision.kind == svn_opt_revision_number)
- end = opt_state->end_revision.value.number;
- else if (opt_state->end_revision.kind == svn_opt_revision_head)
- end = youngest;
- else
- end = SVN_INVALID_REVNUM;
+ /* Find the revision numbers at which to start and end. */
+ SVN_ERR (get_revnum (&start, &opt_state->start_revision,
+ youngest, repos, pool));
+ SVN_ERR (get_revnum (&end, &opt_state->end_revision,
+ youngest, repos, pool));
/* Fill in implied revisions if necessary. */
if (start == SVN_INVALID_REVNUM)
@@ -408,11 +429,6 @@ subcommand_deltify (apr_getopt_t *os, vo
return svn_error_create
(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
"First revision cannot be higher than second");
- if ((start > youngest) || (end > youngest))
- return svn_error_createf
- (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
- "Revisions must not be greater than the youngest revision (%"
- SVN_REVNUM_T_FMT ")", youngest);
/* Loop over the requested revision range, performing the
predecessor deltification on paths changed in each. */
@@ -446,20 +462,11 @@ subcommand_dump (apr_getopt_t *os, void
fs = svn_repos_fs (repos);
SVN_ERR (svn_fs_youngest_rev (&youngest, fs, pool));
- /* ### We only handle revision numbers right now, not dates. */
- if (opt_state->start_revision.kind == svn_opt_revision_number)
- lower = opt_state->start_revision.value.number;
- else if (opt_state->start_revision.kind == svn_opt_revision_head)
- lower = youngest;
- else
- lower = SVN_INVALID_REVNUM;
-
- if (opt_state->end_revision.kind == svn_opt_revision_number)
- upper = opt_state->end_revision.value.number;
- else if (opt_state->end_revision.kind == svn_opt_revision_head)
- upper = youngest;
- else
- upper = SVN_INVALID_REVNUM;
+ /* Find the revision numbers at which to start and end. */
+ SVN_ERR (get_revnum (&lower, &opt_state->start_revision,
+ youngest, repos, pool));
+ SVN_ERR (get_revnum (&upper, &opt_state->end_revision,
+ youngest, repos, pool));
/* Fill in implied revisions if necessary. */
if (lower == SVN_INVALID_REVNUM)
@@ -476,11 +483,6 @@ subcommand_dump (apr_getopt_t *os, void
return svn_error_create
(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
"First revision cannot be higher than second");
- if ((lower > youngest) || (upper > youngest))
- return svn_error_createf
- (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
- "Revisions must not be greater than the youngest revision (%"
- SVN_REVNUM_T_FMT ")", youngest);
/* Run the dump to STDOUT. Let the user redirect output into
a file if they want. :-) */
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Mar 26 01:12:54 2004