Author: stsp Date: Tue Jul 20 16:14:53 2010 New Revision: 965892 URL: http://svn.apache.org/viewvc?rev=965892&view=rev Log: Make svnadmin dump print headers containing MD5 and SHA1 checksums of property content, as was already done for file content. Checksums are printed for revision properties as well as versioned properties.
* notes/dump-load-format.txt: Document the new Prop-content-md5 and Prop-content-sha1 headers. These headers are optional, and unknown headers are ignored, so no format version number bump is needed. * subversion/include/svn_repos.h (SVN_REPOS_DUMPFILE_PROP_CONTENT_MD5, SVN_REPOS_DUMPFILE_PROP_CONTENT_SHA1): New. * subversion/libsvn_repos/dump.c (write_prop_content_checksums): New. Writes Prop-content-md5 and Prop-content-SHA1 headers for a given property hash. (dump_nodem, write_revision_record): When dumping properties, generate Prop-content-md5 and Prop-content-sha1 headers. Modified: subversion/trunk/notes/dump-load-format.txt subversion/trunk/subversion/include/svn_repos.h subversion/trunk/subversion/libsvn_repos/dump.c Modified: subversion/trunk/notes/dump-load-format.txt URL: http://svn.apache.org/viewvc/subversion/trunk/notes/dump-load-format.txt?rev=965892&r1=965891&r2=965892&view=diff ============================================================================== --- subversion/trunk/notes/dump-load-format.txt (original) +++ subversion/trunk/notes/dump-load-format.txt Tue Jul 20 16:14:53 2010 @@ -23,6 +23,8 @@ following: [Text-delta-base-sha1: blob] [Text-copy-source-sha1: blob] [Text-content-sha1: blob] +[Prop-content-md5: (<property name>) blob] +[Prop-content-sha1: (<property name>) blob] The default value for the boolean headers is "false". If the value is set to "true", then the text and property contents will be treated @@ -51,6 +53,9 @@ currently used by the loader. They are Subversion so that future loaders can optionally choose which checksum to use for checking for corruption. +Prop-content-md5 and Prop-content-sha1 are written by 1.7-and-later versions, +and can optionally be used to verify property content upon loading. + ===== SVN DUMPFILE VERSION 2 FORMAT ===== (generated by SVN versions 0.18.0-present, by default) Modified: subversion/trunk/subversion/include/svn_repos.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_repos.h?rev=965892&r1=965891&r2=965892&view=diff ============================================================================== --- subversion/trunk/subversion/include/svn_repos.h (original) +++ subversion/trunk/subversion/include/svn_repos.h Tue Jul 20 16:14:53 2010 @@ -2323,6 +2323,10 @@ svn_repos_node_from_baton(void *edit_bat /** @since New in 1.5. */ #define SVN_REPOS_DUMPFILE_TEXT_DELTA_BASE_CHECKSUM \ SVN_REPOS_DUMPFILE_TEXT_DELTA_BASE_MD5 +/** @since New in 1.7. */ +#define SVN_REPOS_DUMPFILE_PROP_CONTENT_MD5 "Prop-content-md5" +/** @since New in 1.7. */ +#define SVN_REPOS_DUMPFILE_PROP_CONTENT_SHA1 "Prop-content-sha1" /** * Verify the contents of the file system in @a repos. Modified: subversion/trunk/subversion/libsvn_repos/dump.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/dump.c?rev=965892&r1=965891&r2=965892&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_repos/dump.c (original) +++ subversion/trunk/subversion/libsvn_repos/dump.c Tue Jul 20 16:14:53 2010 @@ -295,6 +295,53 @@ make_dir_baton(const char *path, } +/* For each property in PROPHASH, write headers containing MD5 and SHA1 + * checksums of property content to STREAM. + * Do temporary allocations in SCRATCH_POOL. */ +static svn_error_t * +write_prop_content_checksums(svn_stream_t *stream, + apr_hash_t *prophash, + apr_pool_t *scratch_pool) +{ + apr_hash_index_t *hi; + apr_pool_t *iterpool; + + iterpool = svn_pool_create(scratch_pool); + for (hi = apr_hash_first(scratch_pool, prophash); + hi; + hi = apr_hash_next(hi)) + { + svn_checksum_t *checksum; + const char *hex_digest; + const char *propname; + svn_string_t *propval; + + svn_pool_clear(iterpool); + + propname = svn__apr_hash_index_key(hi); + propval = svn__apr_hash_index_val(hi); + + SVN_ERR(svn_checksum(&checksum, svn_checksum_md5, + propval->data, propval->len, iterpool)); + hex_digest = svn_checksum_to_cstring(checksum, iterpool); + if (hex_digest) + SVN_ERR(svn_stream_printf(stream, iterpool, + SVN_REPOS_DUMPFILE_PROP_CONTENT_MD5 + ": (%s) %s\n", propname, hex_digest)); + SVN_ERR(svn_checksum(&checksum, svn_checksum_sha1, + propval->data, propval->len, iterpool)); + hex_digest = svn_checksum_to_cstring(checksum, iterpool); + if (hex_digest) + SVN_ERR(svn_stream_printf(stream, iterpool, + SVN_REPOS_DUMPFILE_PROP_CONTENT_SHA1 + ": (%s) %s\n", propname, hex_digest)); + } + svn_pool_destroy(iterpool); + + return SVN_NO_ERROR; +} + + /* This helper is the main "meat" of the editor -- it does all the work of writing a node record. @@ -565,6 +612,7 @@ dump_node(struct edit_baton *eb, SVN_ERR(svn_stream_printf(eb->stream, pool, SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH ": %" APR_SIZE_T_FMT "\n", proplen)); + SVN_ERR(write_prop_content_checksums(eb->stream, prophash, pool)); } /* If we are supposed to dump text, write out a text length header @@ -992,6 +1040,7 @@ write_revision_record(svn_stream_t *stre SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH ": %" APR_SIZE_T_FMT "\n", encoded_prophash->len)); + SVN_ERR(write_prop_content_checksums(stream, props, pool)); /* Write out a regular Content-length header for the benefit of non-Subversion RFC-822 parsers. */