⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editorp.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
  path = svn_path_canonicalize(path, pool);  if (copy_path)    copy_path = svn_path_canonicalize(copy_path, pool);  file_entry = store_token(ds, NULL, file_token, TRUE, ds->file_pool);  SVN_CMD_ERR(ds->editor->add_file(path, entry->baton, copy_path, copy_rev,                                   ds->file_pool, &file_entry->baton));  return SVN_NO_ERROR;}static svn_error_t *ra_svn_handle_open_file(svn_ra_svn_conn_t *conn,                                            apr_pool_t *pool,                                            apr_array_header_t *params,                                            ra_svn_driver_state_t *ds){  const char *path, *token, *file_token;  svn_revnum_t rev;  ra_svn_token_entry_t *entry, *file_entry;  SVN_ERR(svn_ra_svn_parse_tuple(params, pool, "ccc(?r)", &path, &token,                                 &file_token, &rev));  SVN_ERR(lookup_token(ds, token, FALSE, &entry));  ds->file_refs++;  path = svn_path_canonicalize(path, pool);  file_entry = store_token(ds, NULL, file_token, TRUE, ds->file_pool);  SVN_CMD_ERR(ds->editor->open_file(path, entry->baton, rev, ds->file_pool,                                    &file_entry->baton));  return SVN_NO_ERROR;}static svn_error_t *ra_svn_handle_apply_textdelta(svn_ra_svn_conn_t *conn,                                                  apr_pool_t *pool,                                                  apr_array_header_t *params,                                                  ra_svn_driver_state_t *ds){  const char *token;  ra_svn_token_entry_t *entry;  svn_txdelta_window_handler_t wh;  void *wh_baton;  char *base_checksum;  /* Parse arguments and look up the token. */  SVN_ERR(svn_ra_svn_parse_tuple(params, pool, "c(?c)",                                 &token, &base_checksum));  SVN_ERR(lookup_token(ds, token, TRUE, &entry));  if (entry->dstream)    return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,                            _("Apply-textdelta already active"));  entry->pool = svn_pool_create(ds->file_pool);  SVN_CMD_ERR(ds->editor->apply_textdelta(entry->baton, base_checksum,                                          entry->pool, &wh, &wh_baton));  entry->dstream = svn_txdelta_parse_svndiff(wh, wh_baton, TRUE, entry->pool);  return SVN_NO_ERROR;}static svn_error_t *ra_svn_handle_textdelta_chunk(svn_ra_svn_conn_t *conn,                                                  apr_pool_t *pool,                                                  apr_array_header_t *params,                                                  ra_svn_driver_state_t *ds){  const char *token;  ra_svn_token_entry_t *entry;  svn_string_t *str;  /* Parse arguments and look up the token. */  SVN_ERR(svn_ra_svn_parse_tuple(params, pool, "cs", &token, &str));  SVN_ERR(lookup_token(ds, token, TRUE, &entry));  if (!entry->dstream)    return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,                            _("Apply-textdelta not active"));  SVN_CMD_ERR(svn_stream_write(entry->dstream, str->data, &str->len));  return SVN_NO_ERROR;}static svn_error_t *ra_svn_handle_textdelta_end(svn_ra_svn_conn_t *conn,                                                apr_pool_t *pool,                                                apr_array_header_t *params,                                                ra_svn_driver_state_t *ds){  const char *token;  ra_svn_token_entry_t *entry;  /* Parse arguments and look up the token. */  SVN_ERR(svn_ra_svn_parse_tuple(params, pool, "c", &token));  SVN_ERR(lookup_token(ds, token, TRUE, &entry));  if (!entry->dstream)    return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,                            _("Apply-textdelta not active"));  SVN_CMD_ERR(svn_stream_close(entry->dstream));  entry->dstream = NULL;  apr_pool_destroy(entry->pool);  return SVN_NO_ERROR;}static svn_error_t *ra_svn_handle_change_file_prop(svn_ra_svn_conn_t *conn,                                                   apr_pool_t *pool,                                                   apr_array_header_t *params,                                                   ra_svn_driver_state_t *ds){  const char *token, *name;  svn_string_t *value;  ra_svn_token_entry_t *entry;  SVN_ERR(svn_ra_svn_parse_tuple(params, pool, "cc(?s)", &token, &name,                                 &value));  SVN_ERR(lookup_token(ds, token, TRUE, &entry));  SVN_CMD_ERR(ds->editor->change_file_prop(entry->baton, name, value, pool));  return SVN_NO_ERROR;}static svn_error_t *ra_svn_handle_close_file(svn_ra_svn_conn_t *conn,                                             apr_pool_t *pool,                                             apr_array_header_t *params,                                             ra_svn_driver_state_t *ds){  const char *token;  ra_svn_token_entry_t *entry;  const char *text_checksum;  /* Parse arguments and look up the file token. */  SVN_ERR(svn_ra_svn_parse_tuple(params, pool, "c(?c)",                                 &token, &text_checksum));  SVN_ERR(lookup_token(ds, token, TRUE, &entry));  /* Close the file and destroy the baton. */  SVN_CMD_ERR(ds->editor->close_file(entry->baton, text_checksum, pool));  apr_hash_set(ds->tokens, token, APR_HASH_KEY_STRING, NULL);  if (--ds->file_refs == 0)    apr_pool_clear(ds->file_pool);  return SVN_NO_ERROR;}static svn_error_t *ra_svn_handle_absent_file(svn_ra_svn_conn_t *conn,                                              apr_pool_t *pool,                                              apr_array_header_t *params,                                              ra_svn_driver_state_t *ds){  const char *path;  const char *token;  ra_svn_token_entry_t *entry;  /* Parse parameters and look up the parent directory token. */  SVN_ERR(svn_ra_svn_parse_tuple(params, pool, "cc", &path, &token));  SVN_ERR(lookup_token(ds, token, FALSE, &entry));  /* Call the editor. */  SVN_CMD_ERR(ds->editor->absent_file(path, entry->baton, pool));  return SVN_NO_ERROR;}static svn_error_t *ra_svn_handle_close_edit(svn_ra_svn_conn_t *conn,                                             apr_pool_t *pool,                                             apr_array_header_t *params,                                             ra_svn_driver_state_t *ds){  SVN_CMD_ERR(ds->editor->close_edit(ds->edit_baton, pool));  ds->done = TRUE;  if (ds->aborted)    *ds->aborted = FALSE;  return svn_ra_svn_write_cmd_response(conn, pool, "");}static svn_error_t *ra_svn_handle_abort_edit(svn_ra_svn_conn_t *conn,                                             apr_pool_t *pool,                                             apr_array_header_t *params,                                             ra_svn_driver_state_t *ds){  ds->done = TRUE;  if (ds->aborted)    *ds->aborted = TRUE;  SVN_CMD_ERR(ds->editor->abort_edit(ds->edit_baton, pool));  return svn_ra_svn_write_cmd_response(conn, pool, "");}static svn_error_t *ra_svn_handle_finish_replay(svn_ra_svn_conn_t *conn,                                                apr_pool_t *pool,                                                apr_array_header_t *params,                                                ra_svn_driver_state_t *ds){  if (!ds->for_replay)    return svn_error_createf      (SVN_ERR_RA_SVN_UNKNOWN_CMD, NULL,       _("Command 'finish-replay' invalid outside of replays"));  ds->done = TRUE;  if (ds->aborted)    *ds->aborted = FALSE;  return SVN_NO_ERROR;}static const struct {  const char *cmd;  svn_error_t *(*handler)(svn_ra_svn_conn_t *conn, apr_pool_t *pool,                          apr_array_header_t *params,                          ra_svn_driver_state_t *ds);} ra_svn_edit_cmds[] = {  { "target-rev",       ra_svn_handle_target_rev },  { "open-root",        ra_svn_handle_open_root },  { "delete-entry",     ra_svn_handle_delete_entry },  { "add-dir",          ra_svn_handle_add_dir },  { "open-dir",         ra_svn_handle_open_dir },  { "change-dir-prop",  ra_svn_handle_change_dir_prop },  { "close-dir",        ra_svn_handle_close_dir },  { "absent-dir",       ra_svn_handle_absent_dir },  { "add-file",         ra_svn_handle_add_file },  { "open-file",        ra_svn_handle_open_file },  { "apply-textdelta",  ra_svn_handle_apply_textdelta },  { "textdelta-chunk",  ra_svn_handle_textdelta_chunk },  { "textdelta-end",    ra_svn_handle_textdelta_end },  { "change-file-prop", ra_svn_handle_change_file_prop },  { "close-file",       ra_svn_handle_close_file },  { "absent-file",      ra_svn_handle_absent_file },  { "close-edit",       ra_svn_handle_close_edit },  { "abort-edit",       ra_svn_handle_abort_edit },  { "finish-replay",    ra_svn_handle_finish_replay },  { NULL }};static svn_error_t *blocked_write(svn_ra_svn_conn_t *conn, apr_pool_t *pool,                                  void *baton){  ra_svn_driver_state_t *ds = baton;  const char *cmd;  apr_array_header_t *params;  /* We blocked trying to send an error.  Read and discard an editing   * command in order to avoid deadlock. */  SVN_ERR(svn_ra_svn_read_tuple(conn, pool, "wl", &cmd, &params));  if (strcmp(cmd, "abort-edit") == 0)    {      ds->done = TRUE;      svn_ra_svn__set_block_handler(conn, NULL, NULL);    }  return SVN_NO_ERROR;}svn_error_t *svn_ra_svn__drive_editorp(svn_ra_svn_conn_t *conn,                                       apr_pool_t *pool,                                       const svn_delta_editor_t *editor,                                       void *edit_baton,                                       svn_boolean_t *aborted,                                       svn_boolean_t for_replay){  ra_svn_driver_state_t state;  apr_pool_t *subpool = svn_pool_create(pool);  const char *cmd;  int i;  svn_error_t *err, *write_err;  apr_array_header_t *params;  state.editor = editor;  state.edit_baton = edit_baton;  state.tokens = apr_hash_make(pool);  state.aborted = aborted;  state.done = FALSE;  state.pool = pool;  state.file_pool = svn_pool_create(pool);  state.file_refs = 0;  state.for_replay = for_replay;  while (!state.done)    {      apr_pool_clear(subpool);      SVN_ERR(svn_ra_svn_read_tuple(conn, subpool, "wl", &cmd, &params));      for (i = 0; ra_svn_edit_cmds[i].cmd; i++)        {          if (strcmp(cmd, ra_svn_edit_cmds[i].cmd) == 0)            break;        }      if (ra_svn_edit_cmds[i].cmd)        err = (*ra_svn_edit_cmds[i].handler)(conn, subpool, params, &state);      else        {          err = svn_error_createf(SVN_ERR_RA_SVN_UNKNOWN_CMD, NULL,                                  _("Unknown command '%s'"), cmd);          err = svn_error_create(SVN_ERR_RA_SVN_CMD_ERR, err, NULL);        }      if (err && err->apr_err == SVN_ERR_RA_SVN_CMD_ERR)        {          if (aborted)            *aborted = TRUE;          if (!state.done)            {              /* Abort the edit and use non-blocking I/O to write the error. */              svn_error_clear(editor->abort_edit(edit_baton, subpool));              svn_ra_svn__set_block_handler(conn, blocked_write, &state);            }          write_err = svn_ra_svn_write_cmd_failure(conn, subpool, err->child);          if (!write_err)            write_err = svn_ra_svn_flush(conn, subpool);          svn_ra_svn__set_block_handler(conn, NULL, NULL);          svn_error_clear(err);          SVN_ERR(write_err);          break;        }      SVN_ERR(err);    }  /* Read and discard editing commands until the edit is complete. */  while (!state.done)    {      apr_pool_clear(subpool);      SVN_ERR(svn_ra_svn_read_tuple(conn, subpool, "wl", &cmd, &params));      state.done = (strcmp(cmd, "abort-edit") == 0);    }  apr_pool_destroy(subpool);  return SVN_NO_ERROR;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -