📄 replay.c
字号:
/* * replay.c : routines for replaying revisions * * ==================================================================== * Copyright (c) 2005 CollabNet. All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://subversion.tigris.org/license-1.html. * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * * This software consists of voluntary contributions made by many * individuals. For exact contribution history, see the revision * history and logs, available at http://subversion.tigris.org/. * ==================================================================== */#include <apr_pools.h>#include <apr_strings.h>#include <apr_xml.h>#include <apr_md5.h>#include <mod_dav.h>#include "svn_pools.h"#include "svn_repos.h"#include "svn_fs.h"#include "svn_md5.h"#include "svn_base64.h"#include "svn_xml.h"#include "svn_path.h"#include "svn_dav.h"#include "svn_props.h"#include "dav_svn.h"#include <http_request.h>#include <http_log.h>typedef struct { apr_bucket_brigade *bb; ap_filter_t *output; svn_boolean_t started; svn_boolean_t sending_textdelta;} dav_svn_edit_baton_t;static svn_error_t *maybe_start_report(dav_svn_edit_baton_t *eb){ if (! eb->started) { SVN_ERR(dav_svn__send_xml (eb->bb, eb->output, DAV_XML_HEADER DEBUG_CR "<S:editor-report xmlns:S=\"" SVN_XML_NAMESPACE "\">" DEBUG_CR)); eb->started = TRUE; } return SVN_NO_ERROR;}static svn_error_t *end_report(dav_svn_edit_baton_t *eb){ SVN_ERR(dav_svn__send_xml(eb->bb, eb->output, "</S:editor-report>" DEBUG_CR)); return SVN_NO_ERROR;}static svn_error_t *maybe_close_textdelta(dav_svn_edit_baton_t *eb){ if (eb->sending_textdelta) { SVN_ERR(dav_svn__send_xml(eb->bb, eb->output, "</S:apply-textdelta>" DEBUG_CR)); eb->sending_textdelta = FALSE; } return SVN_NO_ERROR;}static svn_error_t *set_target_revision(void *edit_baton, svn_revnum_t target_revision, apr_pool_t *pool){ dav_svn_edit_baton_t *eb = edit_baton; SVN_ERR(maybe_start_report(eb)); SVN_ERR(dav_svn__send_xml(eb->bb, eb->output, "<S:target-revision rev=\"%ld\"/>" DEBUG_CR, target_revision)); return SVN_NO_ERROR;}static svn_error_t *open_root(void *edit_baton, svn_revnum_t base_revision, apr_pool_t *pool, void **root_baton){ dav_svn_edit_baton_t *eb = edit_baton; *root_baton = edit_baton; SVN_ERR(maybe_start_report(eb)); SVN_ERR(dav_svn__send_xml(eb->bb, eb->output, "<S:open-root rev=\"%ld\"/>" DEBUG_CR, base_revision)); return SVN_NO_ERROR;}static svn_error_t *delete_entry(const char *path, svn_revnum_t revision, void *parent_baton, apr_pool_t *pool){ dav_svn_edit_baton_t *eb = parent_baton; const char *qname = apr_xml_quote_string(pool, path, 1); SVN_ERR(maybe_close_textdelta(eb)); SVN_ERR(dav_svn__send_xml(eb->bb, eb->output, "<S:delete-entry name=\"%s\" rev=\"%ld\"/>" DEBUG_CR, qname, revision)); return SVN_NO_ERROR;}static svn_error_t *add_directory(const char *path, void *parent_baton, const char *copyfrom_path, svn_revnum_t copyfrom_rev, apr_pool_t *pool, void **child_baton){ dav_svn_edit_baton_t *eb = parent_baton; const char *qpath = apr_xml_quote_string(pool, path, 1); const char *qcopy = copyfrom_path ? apr_xml_quote_string(pool, copyfrom_path, 1) : NULL; SVN_ERR(maybe_close_textdelta(eb)); *child_baton = parent_baton; if (! copyfrom_path) SVN_ERR(dav_svn__send_xml(eb->bb, eb->output, "<S:add-directory name=\"%s\"/>" DEBUG_CR, qpath)); else SVN_ERR(dav_svn__send_xml(eb->bb, eb->output, "<S:add-directory name=\"%s\" " "copyfrom-path=\"%s\" " "copyfrom-rev=\"%ld\"/>" DEBUG_CR, qpath, qcopy, copyfrom_rev)); return SVN_NO_ERROR;}static svn_error_t *open_directory(const char *path, void *parent_baton, svn_revnum_t base_revision, apr_pool_t *pool, void **child_baton){ dav_svn_edit_baton_t *eb = parent_baton; const char *qpath = apr_xml_quote_string(pool, path, 1); SVN_ERR(maybe_close_textdelta(eb)); *child_baton = parent_baton; SVN_ERR(dav_svn__send_xml(eb->bb, eb->output, "<S:open-directory name=\"%s\" rev=\"%ld\"/>" DEBUG_CR, qpath, base_revision)); return SVN_NO_ERROR;}static svn_error_t *change_dir_prop(void *baton, const char *name, const svn_string_t *value, apr_pool_t *pool){ dav_svn_edit_baton_t *eb = baton; const char *qname; SVN_ERR(maybe_close_textdelta(eb)); qname = apr_xml_quote_string(pool, name, 1); if (value) { const svn_string_t *enc_value = svn_base64_encode_string(value, pool); SVN_ERR(dav_svn__send_xml (eb->bb, eb->output, "<S:change-dir-prop name=\"%s\">%s</S:change-dir-prop>" DEBUG_CR, qname, enc_value->data)); } else { SVN_ERR(dav_svn__send_xml (eb->bb, eb->output, "<S:change-dir-prop name=\"%s\" del=\"true\"/>" DEBUG_CR, qname)); } return SVN_NO_ERROR;}static svn_error_t *add_file(const char *path, void *parent_baton, const char *copyfrom_path, svn_revnum_t copyfrom_rev, apr_pool_t *pool, void **file_baton){ dav_svn_edit_baton_t *eb = parent_baton; const char *qname = apr_xml_quote_string(pool, path, 1); const char *qcopy = copyfrom_path ? apr_xml_quote_string(pool, copyfrom_path, 1) : NULL; SVN_ERR(maybe_close_textdelta(eb)); *file_baton = parent_baton; if (! copyfrom_path) SVN_ERR(dav_svn__send_xml(eb->bb, eb->output, "<S:add-file name=\"%s\"/>" DEBUG_CR, qname)); else SVN_ERR(dav_svn__send_xml(eb->bb, eb->output, "<S:add-file name=\"%s\" " "copyfrom-path=\"%s\" " "copyfrom-rev=\"%ld\"/>" DEBUG_CR, qname, qcopy, copyfrom_rev)); return SVN_NO_ERROR;}static svn_error_t *open_file(const char *path, void *parent_baton, svn_revnum_t base_revision, apr_pool_t *pool, void **file_baton){ dav_svn_edit_baton_t *eb = parent_baton;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -