svn_error_t * svn_repos_fs_revision_proplist(apr_hash_t **table_p, svn_repos_t *repos, svn_revnum_t rev, svn_repos_authz_func_t authz_read_func, void *authz_read_baton, apr_pool_t *pool) { svn_repos_revision_access_level_t readability; SVN_ERR(svn_repos_check_revision_access(&readability, repos, rev, authz_read_func, authz_read_baton, pool)); if (readability == svn_repos_revision_access_none) { /* Return an empty hash. */ *table_p = apr_hash_make(pool); } else if (readability == svn_repos_revision_access_partial) { apr_hash_t *tmphash; svn_string_t *value; /* Produce two property hashtables, both in POOL. */ SVN_ERR(svn_fs_revision_proplist(&tmphash, repos->fs, rev, pool)); *table_p = apr_hash_make(pool); /* If they exist, we only copy svn:author and svn:date into the 'real' hashtable being returned. */ value = apr_hash_get(tmphash, SVN_PROP_REVISION_AUTHOR, APR_HASH_KEY_STRING); if (value) apr_hash_set(*table_p, SVN_PROP_REVISION_AUTHOR, APR_HASH_KEY_STRING, value); value = apr_hash_get(tmphash, SVN_PROP_REVISION_DATE, APR_HASH_KEY_STRING); if (value) apr_hash_set(*table_p, SVN_PROP_REVISION_DATE, APR_HASH_KEY_STRING, value); } else /* wholly readable revision */ { SVN_ERR(svn_fs_revision_proplist(table_p, repos->fs, rev, pool)); } return SVN_NO_ERROR; }
/* Helper for svn_repos_dump_fs. Write a revision record of REV in FS to writable STREAM, using POOL. */ static svn_error_t * write_revision_record(svn_stream_t *stream, svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *pool) { apr_size_t len; apr_hash_t *props; svn_stringbuf_t *encoded_prophash; apr_time_t timetemp; svn_string_t *datevalue; svn_stream_t *propstream; /* Read the revision props even if we're aren't going to dump them for verification purposes */ SVN_ERR(svn_fs_revision_proplist(&props, fs, rev, pool)); /* Run revision date properties through the time conversion to canonicalize them. */ /* ### Remove this when it is no longer needed for sure. */ datevalue = apr_hash_get(props, SVN_PROP_REVISION_DATE, APR_HASH_KEY_STRING); if (datevalue) { SVN_ERR(svn_time_from_cstring(&timetemp, datevalue->data, pool)); datevalue = svn_string_create(svn_time_to_cstring(timetemp, pool), pool); apr_hash_set(props, SVN_PROP_REVISION_DATE, APR_HASH_KEY_STRING, datevalue); } encoded_prophash = svn_stringbuf_create_ensure(0, pool); propstream = svn_stream_from_stringbuf(encoded_prophash, pool); SVN_ERR(svn_hash_write2(props, propstream, "PROPS-END", pool)); SVN_ERR(svn_stream_close(propstream)); /* ### someday write a revision-content-checksum */ SVN_ERR(svn_stream_printf(stream, pool, SVN_REPOS_DUMPFILE_REVISION_NUMBER ": %ld\n", rev)); SVN_ERR(svn_stream_printf(stream, pool, SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH ": %" APR_SIZE_T_FMT "\n", encoded_prophash->len)); /* Write out a regular Content-length header for the benefit of non-Subversion RFC-822 parsers. */ SVN_ERR(svn_stream_printf(stream, pool, SVN_REPOS_DUMPFILE_CONTENT_LENGTH ": %" APR_SIZE_T_FMT "\n\n", encoded_prophash->len)); len = encoded_prophash->len; SVN_ERR(svn_stream_write(stream, encoded_prophash->data, &len)); len = 1; return svn_stream_write(stream, "\n", &len); }
static PyObject *fs_get_revision_proplist(FileSystemObject *self, PyObject *args) { svn_revnum_t rev; PyObject *ret; apr_pool_t *temp_pool; apr_hash_t *props; if (!PyArg_ParseTuple(args, "l", &rev)) return NULL; temp_pool = Pool(NULL); if (temp_pool == NULL) return NULL; RUN_SVN_WITH_POOL(temp_pool, svn_fs_revision_proplist(&props, self->fs, rev, temp_pool)); ret = prop_hash_to_dict(props); apr_pool_destroy(temp_pool); return (PyObject *)ret; }
static svn_error_t * close_revision(void *baton) { struct revision_baton *rb = baton; struct parse_baton *pb = rb->pb; const char *conflict_msg = NULL; svn_revnum_t committed_rev; svn_error_t *err; const char *txn_name = NULL; apr_hash_t *hooks_env; /* If we're skipping this revision we're done here. */ if (rb->skipped) return SVN_NO_ERROR; if (rb->rev == 0) { /* Special case: set revision 0 properties when loading into an 'empty' filesystem. */ svn_revnum_t youngest_rev; SVN_ERR(svn_fs_youngest_rev(&youngest_rev, pb->fs, rb->pool)); if (youngest_rev == 0) { apr_hash_t *orig_props; apr_hash_t *new_props; apr_array_header_t *diff; int i; SVN_ERR(svn_fs_revision_proplist(&orig_props, pb->fs, 0, rb->pool)); new_props = svn_prop_array_to_hash(rb->revprops, rb->pool); SVN_ERR(svn_prop_diffs(&diff, new_props, orig_props, rb->pool)); for (i = 0; i < diff->nelts; i++) { const svn_prop_t *prop = &APR_ARRAY_IDX(diff, i, svn_prop_t); SVN_ERR(change_rev_prop(pb->repos, 0, prop->name, prop->value, pb->validate_props, rb->pool)); } } return SVN_NO_ERROR; } /* If the dumpstream doesn't have an 'svn:date' property and we aren't ignoring the dates in the dumpstream altogether, remove any 'svn:date' revision property that was set by FS layer when the TXN was created. */ if (! (pb->ignore_dates || rb->datestamp)) { svn_prop_t *prop = &APR_ARRAY_PUSH(rb->revprops, svn_prop_t); prop->name = SVN_PROP_REVISION_DATE; prop->value = NULL; } /* Apply revision property changes. */ if (rb->pb->validate_props) SVN_ERR(svn_repos_fs_change_txn_props(rb->txn, rb->revprops, rb->pool)); else SVN_ERR(svn_fs_change_txn_props(rb->txn, rb->revprops, rb->pool)); /* Get the txn name and hooks environment if they will be needed. */ if (pb->use_pre_commit_hook || pb->use_post_commit_hook) { SVN_ERR(svn_repos__parse_hooks_env(&hooks_env, pb->repos->hooks_env_path, rb->pool, rb->pool)); err = svn_fs_txn_name(&txn_name, rb->txn, rb->pool); if (err) { svn_error_clear(svn_fs_abort_txn(rb->txn, rb->pool)); return svn_error_trace(err); } } /* Run the pre-commit hook, if so commanded. */ if (pb->use_pre_commit_hook) { err = svn_repos__hooks_pre_commit(pb->repos, hooks_env, txn_name, rb->pool); if (err) { svn_error_clear(svn_fs_abort_txn(rb->txn, rb->pool)); return svn_error_trace(err); } } /* Commit. */ err = svn_fs_commit_txn(&conflict_msg, &committed_rev, rb->txn, rb->pool); if (SVN_IS_VALID_REVNUM(committed_rev)) { if (err) { /* ### Log any error, but better yet is to rev ### close_revision()'s API to allow both committed_rev and err ### to be returned, see #3768. */ svn_error_clear(err); } } else { svn_error_clear(svn_fs_abort_txn(rb->txn, rb->pool)); if (conflict_msg) return svn_error_quick_wrap(err, conflict_msg); else return svn_error_trace(err); } /* Run post-commit hook, if so commanded. */ if (pb->use_post_commit_hook) { if ((err = svn_repos__hooks_post_commit(pb->repos, hooks_env, committed_rev, txn_name, rb->pool))) return svn_error_create (SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED, err, _("Commit succeeded, but post-commit hook failed")); } /* After a successful commit, must record the dump-rev -> in-repos-rev mapping, so that copyfrom instructions in the dump file can look up the correct repository revision to copy from. */ set_revision_mapping(pb->rev_map, rb->rev, committed_rev); /* If the incoming dump stream has non-contiguous revisions (e.g. from using svndumpfilter --drop-empty-revs without --renumber-revs) then we must account for the missing gaps in PB->REV_MAP. Otherwise we might not be able to map all mergeinfo source revisions to the correct revisions in the target repos. */ if ((pb->last_rev_mapped != SVN_INVALID_REVNUM) && (rb->rev != pb->last_rev_mapped + 1)) { svn_revnum_t i; for (i = pb->last_rev_mapped + 1; i < rb->rev; i++) { set_revision_mapping(pb->rev_map, i, pb->last_rev_mapped); } } /* Update our "last revision mapped". */ pb->last_rev_mapped = rb->rev; /* Deltify the predecessors of paths changed in this revision. */ SVN_ERR(svn_fs_deltify_revision(pb->fs, committed_rev, rb->pool)); if (pb->notify_func) { /* ### TODO: Use proper scratch pool instead of pb->notify_pool */ svn_repos_notify_t *notify = svn_repos_notify_create( svn_repos_notify_load_txn_committed, pb->notify_pool); notify->new_revision = committed_rev; notify->old_revision = ((committed_rev == rb->rev) ? SVN_INVALID_REVNUM : rb->rev); pb->notify_func(pb->notify_baton, notify, pb->notify_pool); svn_pool_clear(pb->notify_pool); } return SVN_NO_ERROR; }
svn_error_t * svn_repos_verify_fs2(svn_repos_t *repos, svn_revnum_t start_rev, svn_revnum_t end_rev, svn_repos_notify_func_t notify_func, void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *pool) { svn_fs_t *fs = svn_repos_fs(repos); svn_revnum_t youngest; svn_revnum_t rev; apr_pool_t *iterpool = svn_pool_create(pool); svn_repos_notify_t *notify; /* Determine the current youngest revision of the filesystem. */ SVN_ERR(svn_fs_youngest_rev(&youngest, fs, pool)); /* Use default vals if necessary. */ if (! SVN_IS_VALID_REVNUM(start_rev)) start_rev = 0; if (! SVN_IS_VALID_REVNUM(end_rev)) end_rev = youngest; /* Validate the revisions. */ if (start_rev > end_rev) return svn_error_createf(SVN_ERR_REPOS_BAD_ARGS, NULL, _("Start revision %ld" " is greater than end revision %ld"), start_rev, end_rev); if (end_rev > youngest) return svn_error_createf(SVN_ERR_REPOS_BAD_ARGS, NULL, _("End revision %ld is invalid " "(youngest revision is %ld)"), end_rev, youngest); /* Create a notify object that we can reuse within the loop. */ if (notify_func) notify = svn_repos_notify_create(svn_repos_notify_verify_rev_end, pool); for (rev = start_rev; rev <= end_rev; rev++) { svn_delta_editor_t *dump_editor; void *dump_edit_baton; const svn_delta_editor_t *cancel_editor; void *cancel_edit_baton; svn_fs_root_t *to_root; apr_hash_t *props; svn_pool_clear(iterpool); /* Get cancellable dump editor, but with our close_directory handler. */ SVN_ERR(get_dump_editor((const svn_delta_editor_t **)&dump_editor, &dump_edit_baton, fs, rev, "", svn_stream_empty(pool), notify_func, notify_baton, start_rev, FALSE, TRUE, /* use_deltas, verify */ iterpool)); dump_editor->close_directory = verify_close_directory; SVN_ERR(svn_delta_get_cancellation_editor(cancel_func, cancel_baton, dump_editor, dump_edit_baton, &cancel_editor, &cancel_edit_baton, iterpool)); SVN_ERR(svn_fs_revision_root(&to_root, fs, rev, iterpool)); SVN_ERR(svn_repos_replay2(to_root, "", SVN_INVALID_REVNUM, FALSE, cancel_editor, cancel_edit_baton, NULL, NULL, iterpool)); SVN_ERR(svn_fs_revision_proplist(&props, fs, rev, iterpool)); if (notify_func) { notify->revision = rev; notify_func(notify_baton, notify, iterpool); } } /* We're done. */ if (notify_func) { notify = svn_repos_notify_create(svn_repos_notify_verify_end, iterpool); notify_func(notify_baton, notify, iterpool); } svn_pool_destroy(iterpool); return SVN_NO_ERROR; }