You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2013/07/03 15:32:27 UTC
svn commit: r1499393 - /subversion/trunk/subversion/libsvn_ra_serf/update.c
Author: rhuijben
Date: Wed Jul 3 13:32:27 2013
New Revision: 1499393
URL: http://svn.apache.org/r1499393
Log:
Checkpoint some preparation for converting the update report xml parser in
ra_serf to the transition based parser. This patch just adds new and
updates existing commented out code.
The code currently doesn't exit the processing loop when enabled.
* subversion/libsvn_ra_serf/update.c
(USE_TRANSITION_PARSER): Add commented define.
(report_state_e): Add a few more states.
(update_ttable): Fix a few existing transitions and add new
ones as needed by a simple checkout.
(update_opened,
update_closed,
update_cdata): Move functions to ...
(update_opened,
update_closed,
update_cdata): ... here, to allow calling the required helper functions,
Add some temporary SVN_DBG() calls to verify the transition table.
(finish_report): Add code to allow enabling the new parser, depending on
USE_TRANSITION_PARSER.
Modified:
subversion/trunk/subversion/libsvn_ra_serf/update.c
Modified: subversion/trunk/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/update.c?rev=1499393&r1=1499392&r2=1499393&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/update.c Wed Jul 3 13:32:27 2013
@@ -49,6 +49,10 @@
#include "ra_serf.h"
#include "../libsvn_ra/ra_loader.h"
+/*
+#define USE_TRANSITION_PARSER
+*/
+
/*
* This enum represents the current state of our XML parsing for a REPORT.
@@ -77,6 +81,17 @@ typedef enum report_state_e {
IGNORE_PROP_NAME,
NEED_PROP_NAME,
TXDELTA
+
+#ifdef NOT_USED_YET
+ ,
+
+ CHECKED_IN,
+ CHECKED_IN_HREF,
+
+ SET_PROP,
+
+ MD5_CHECKSUM
+#endif
} report_state_e;
@@ -392,10 +407,11 @@ struct report_context_t {
};
-#ifdef NOT_USED_YET
+#ifdef USE_TRANSITION_PARSER
#define D_ "DAV:"
#define S_ SVN_XML_NAMESPACE
+#define V_ SVN_DAV_PROP_NS_DAV
static const svn_ra_serf__xml_transition_t update_ttable[] = {
{ INITIAL, S_, "update-report", UPDATE_REPORT,
FALSE, { NULL }, FALSE },
@@ -410,19 +426,19 @@ static const svn_ra_serf__xml_transition
FALSE, { "rev", "name", NULL }, TRUE },
{ OPEN_DIR, S_, "add-directory", ADD_DIR,
- FALSE, { "rev", "name", "?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
+ FALSE, { "name", "?rev", "?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
{ ADD_DIR, S_, "add-directory", ADD_DIR,
- FALSE, { "rev", "name", "?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
+ FALSE, { "name", "?rev", "?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
{ OPEN_DIR, S_, "open-file", OPEN_FILE,
FALSE, { "rev", "name", NULL }, TRUE },
{ OPEN_DIR, S_, "add-file", ADD_FILE,
- FALSE, { "rev", "name", "?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
+ FALSE, { "name", "?rev", "?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
{ ADD_DIR, S_, "add-file", ADD_FILE,
- FALSE, { "rev", "name", "?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
+ FALSE, { "name", "?rev", "?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
{ OPEN_DIR, S_, "delete-entry", OPEN_FILE,
FALSE, { "?rev", "name", NULL }, TRUE },
@@ -439,65 +455,45 @@ static const svn_ra_serf__xml_transition
{ ADD_DIR, S_, "absent-file", ABSENT_FILE,
FALSE, { "name", NULL }, TRUE },
- { 0 }
-};
+ { OPEN_DIR, D_, "checked-in", CHECKED_IN,
+ FALSE, { NULL }, FALSE },
+ { ADD_DIR, D_, "checked-in", CHECKED_IN,
+ FALSE, { NULL }, FALSE },
-/* Conforms to svn_ra_serf__xml_opened_t */
-static svn_error_t *
-update_opened(svn_ra_serf__xml_estate_t *xes,
- void *baton,
- int entered_state,
- const svn_ra_serf__dav_props_t *tag,
- apr_pool_t *scratch_pool)
-{
- report_context_t *ctx = baton;
+ { ADD_FILE, D_, "checked-in", CHECKED_IN,
+ FALSE, { NULL }, FALSE },
- return SVN_NO_ERROR;
-}
+ { OPEN_DIR, S_, "set-prop", SET_PROP,
+ TRUE, { "name", "?encoding", NULL }, TRUE },
+ { ADD_DIR, S_, "set-prop", SET_PROP,
+ TRUE, { "name", "?encoding", NULL }, TRUE },
-/* Conforms to svn_ra_serf__xml_closed_t */
-static svn_error_t *
-update_closed(svn_ra_serf__xml_estate_t *xes,
- void *baton,
- int leaving_state,
- const svn_string_t *cdata,
- apr_hash_t *attrs,
- apr_pool_t *scratch_pool)
-{
- report_context_t *ctx = baton;
+ { OPEN_FILE, S_, "set-prop", SET_PROP,
+ TRUE, { "name", "?encoding", NULL }, TRUE },
- if (leaving_state == TARGET_REVISION)
- {
- const char *rev = svn_hash_gets(attrs, "rev");
+ { ADD_FILE, S_, "set-prop", SET_PROP,
+ TRUE, { "name", "?encoding", NULL }, TRUE },
- SVN_ERR(ctx->update_editor->set_target_revision(ctx->update_baton,
- SVN_STR_TO_REV(rev),
- ctx->sess->pool));
- }
- return SVN_NO_ERROR;
-}
+ { OPEN_FILE, S_, "prop", PROP,
+ FALSE, { NULL }, FALSE },
+ { ADD_FILE, S_, "prop", PROP,
+ FALSE, { NULL }, FALSE },
+ { CHECKED_IN, D_, "href", CHECKED_IN_HREF,
+ TRUE, { NULL }, TRUE },
-/* Conforms to svn_ra_serf__xml_cdata_t */
-static svn_error_t *
-update_cdata(svn_ra_serf__xml_estate_t *xes,
- void *baton,
- int current_state,
- const char *data,
- apr_size_t len,
- apr_pool_t *scratch_pool)
-{
- report_context_t *ctx = baton;
+ { PROP, V_, "md5-checksum", MD5_CHECKSUM,
+ TRUE, { NULL }, TRUE },
- return SVN_NO_ERROR;
-}
+ { 0 }
+};
-#endif /* NOT_USED_YET */
+#endif /* USE_TRANSITION_PARSER */
/* Returns best connection for fetching files/properties. */
@@ -2539,6 +2535,73 @@ cdata_report(svn_ra_serf__xml_parser_t *
return SVN_NO_ERROR;
}
+#ifdef USE_TRANSITION_PARSER
+/* Conforms to svn_ra_serf__xml_opened_t */
+static svn_error_t *
+update_opened(svn_ra_serf__xml_estate_t *xes,
+ void *baton,
+ int entered_state,
+ const svn_ra_serf__dav_props_t *tag,
+ apr_pool_t *scratch_pool)
+{
+ report_context_t *ctx = baton;
+ SVN_DBG(("Enter state: %d", entered_state));
+
+ return SVN_NO_ERROR;
+}
+
+
+
+/* Conforms to svn_ra_serf__xml_closed_t */
+static svn_error_t *
+update_closed(svn_ra_serf__xml_estate_t *xes,
+ void *baton,
+ int leaving_state,
+ const svn_string_t *cdata,
+ apr_hash_t *attrs,
+ apr_pool_t *scratch_pool)
+{
+ report_context_t *ctx = baton;
+
+ SVN_DBG(("Leaving state: %d", leaving_state));
+
+ if (leaving_state == UPDATE_REPORT)
+ {
+ ctx->report_completed = TRUE;
+ ctx->done = TRUE;
+ }
+ else if (leaving_state == TARGET_REVISION)
+ {
+ const char *revstr = svn_hash_gets(attrs, "rev");
+ apr_int64_t rev;
+
+ SVN_ERR(svn_cstring_atoi64(&rev, revstr));
+
+ SVN_ERR(ctx->update_editor->set_target_revision(ctx->update_baton,
+ (svn_revnum_t)rev,
+ ctx->sess->pool));
+ }
+
+
+ return SVN_NO_ERROR;
+}
+
+
+/* Conforms to svn_ra_serf__xml_cdata_t */
+static svn_error_t *
+update_cdata(svn_ra_serf__xml_estate_t *xes,
+ void *baton,
+ int current_state,
+ const char *data,
+ apr_size_t len,
+ apr_pool_t *scratch_pool)
+{
+ report_context_t *ctx = baton;
+ SVN_DBG(("Got CDATA in state %d\n", current_state));
+ return SVN_NO_ERROR;
+}
+#endif /* USE_TRANSITION_PARSER */
+
/** Editor callbacks given to callers to create request body */
@@ -2758,6 +2821,9 @@ finish_report(void *report_baton,
svn_ra_serf__session_t *sess = report->sess;
svn_ra_serf__handler_t *handler;
svn_ra_serf__xml_parser_t *parser_ctx;
+#ifdef USE_TRANSITION_PARSER
+ svn_ra_serf__xml_context_t *xmlctx;
+#endif
const char *report_target;
svn_stringbuf_t *buf = NULL;
apr_pool_t *iterpool = svn_pool_create(pool);
@@ -2787,7 +2853,16 @@ finish_report(void *report_baton,
/* create and deliver request */
report->path = report_target;
+#ifdef USE_TRANSITION_PARSER
+ xmlctx = svn_ra_serf__xml_context_create(update_ttable,
+ update_opened, update_closed,
+ update_cdata,
+ report,
+ pool);
+ handler = svn_ra_serf__create_expat_handler(xmlctx, pool);
+#else
handler = apr_pcalloc(pool, sizeof(*handler));
+#endif
handler->handler_pool = pool;
handler->method = "REPORT";
@@ -2801,6 +2876,7 @@ finish_report(void *report_baton,
handler->conn = sess->conns[0];
handler->session = sess;
+#ifndef USE_TRANSITION_PARSER
parser_ctx = apr_pcalloc(pool, sizeof(*parser_ctx));
parser_ctx->pool = pool;
@@ -2815,6 +2891,7 @@ finish_report(void *report_baton,
handler->response_baton = parser_ctx;
report->parser_ctx = parser_ctx;
+#endif
svn_ra_serf__request_create(handler);