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

📄 commit_util.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
      struct file_mod_t *mod;      svn_client_commit_item2_t *item;      void *val;      void *file_baton;      const char *tempfile, *dir_path;      unsigned char digest[APR_MD5_DIGESTSIZE];      svn_boolean_t fulltext = FALSE;      svn_wc_adm_access_t *item_access;            svn_pool_clear(subpool);      /* Get the next entry. */      apr_hash_this(hi, &key, &klen, &val);      mod = val;      /* Transmit the entry. */      item = mod->item;      file_baton = mod->file_baton;      if (ctx->cancel_func)        SVN_ERR(ctx->cancel_func(ctx->cancel_baton));      if (ctx->notify_func2)        {          svn_wc_notify_t *notify;          const char *npath = NULL;          if (notify_path_prefix)            {              if (strcmp(notify_path_prefix, item->path) != 0)                npath = svn_path_is_child(notify_path_prefix, item->path,                                          subpool);              else                npath = ".";            }          if (! npath)            npath = item->path;          notify = svn_wc_create_notify(npath,                                        svn_wc_notify_commit_postfix_txdelta,                                        subpool);          notify->kind = svn_node_file;          (*ctx->notify_func2)(ctx->notify_baton2, notify, subpool);        }      if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_ADD)        fulltext = TRUE;      dir_path = svn_path_dirname(item->path, subpool);      SVN_ERR(svn_wc_adm_retrieve(&item_access, adm_access, dir_path,                                  subpool));      SVN_ERR(svn_wc_transmit_text_deltas2(&tempfile, digest, item->path,                                           item_access, fulltext, editor,                                           file_baton, subpool));      if (tempfile && *tempfiles)        {          tempfile = apr_pstrdup(apr_hash_pool_get(*tempfiles), tempfile);          apr_hash_set(*tempfiles, tempfile, APR_HASH_KEY_STRING, (void *)1);        }      if (digests)        {          unsigned char *new_digest = apr_pmemdup(apr_hash_pool_get(*digests),                                                  digest, APR_MD5_DIGESTSIZE);          apr_hash_set(*digests, item->path, APR_HASH_KEY_STRING, new_digest);        }    }  svn_pool_destroy(subpool);  /* Close the edit. */  SVN_ERR(editor->close_edit(edit_baton, pool));  return SVN_NO_ERROR;}/* Commit callback baton */struct commit_baton {  svn_commit_info_t **info;  apr_pool_t *pool;};svn_error_t *svn_client__commit_get_baton(void **baton,                                          svn_commit_info_t **info,                                          apr_pool_t *pool){  struct commit_baton *cb = apr_pcalloc(pool, sizeof(*cb));  cb->info = info;  cb->pool = pool;  *baton = cb;  return SVN_NO_ERROR;}svn_error_t *svn_client__commit_callback(const svn_commit_info_t *commit_info,                                         void *baton,                                         apr_pool_t *pool){  struct commit_baton *cb = baton;  *(cb->info) = svn_commit_info_dup(commit_info, cb->pool);  return SVN_NO_ERROR;}#ifdef SVN_CLIENT_COMMIT_DEBUG/*** Temporary test editor ***/struct edit_baton{  const char *path;  const svn_delta_editor_t *real_editor;  void *real_eb;};struct item_baton{  struct edit_baton *eb;  void *real_baton;  const char *path;};static struct item_baton *make_baton(struct edit_baton *eb,           void *real_baton,           const char *path,           apr_pool_t *pool){  struct item_baton *new_baton = apr_pcalloc(pool, sizeof(*new_baton));  new_baton->eb = eb;  new_baton->real_baton = real_baton;  new_baton->path = apr_pstrdup(pool, path);  return new_baton;}static svn_error_t *set_target_revision(void *edit_baton,                    svn_revnum_t target_revision,                    apr_pool_t *pool){  struct edit_baton *eb = edit_baton;  return (*eb->real_editor->set_target_revision)(eb->real_eb,                                                 target_revision,                                                 pool);}static svn_error_t *open_root(void *edit_baton,          svn_revnum_t base_revision,          apr_pool_t *dir_pool,          void **root_baton){  struct edit_baton *eb = edit_baton;  struct item_baton *new_baton = make_baton(eb, NULL, eb->path, dir_pool);  fprintf(stderr, "TEST EDIT STARTED (base URL=%s)\n", eb->path);  *root_baton = new_baton;  return (*eb->real_editor->open_root)(eb->real_eb,                                       base_revision,                                       dir_pool,                                       &new_baton->real_baton);}static svn_error_t *add_file(const char *path,         void *parent_baton,         const char *copyfrom_path,         svn_revnum_t copyfrom_revision,         apr_pool_t *pool,         void **baton){  struct item_baton *db = parent_baton;  struct item_baton *new_baton = make_baton(db->eb, NULL, path, pool);  const char *copystuffs = "";  if (copyfrom_path && SVN_IS_VALID_REVNUM(copyfrom_revision))    copystuffs = apr_psprintf(pool,                               " (copied from %s:%ld)",                              copyfrom_path,                              copyfrom_revision);  fprintf(stderr, "   Adding  : %s%s\n", path, copystuffs);  *baton = new_baton;  return (*db->eb->real_editor->add_file)(path, db->real_baton,                                          copyfrom_path, copyfrom_revision,                                          pool, &new_baton->real_baton);}static svn_error_t *delete_entry(const char *path,             svn_revnum_t revision,             void *parent_baton,             apr_pool_t *pool){  struct item_baton *db = parent_baton;  fprintf(stderr, "   Deleting: %s\n", path);  return (*db->eb->real_editor->delete_entry)(path, revision,                                              db->real_baton, pool);}static svn_error_t *open_file(const char *path,          void *parent_baton,          svn_revnum_t base_revision,          apr_pool_t *pool,          void **baton){  struct item_baton *db = parent_baton;  struct item_baton *new_baton = make_baton(db->eb, NULL, path, pool);  fprintf(stderr, "   Opening : %s\n", path);  *baton = new_baton;  return (*db->eb->real_editor->open_file)(path, db->real_baton,                                           base_revision, pool,                                           &new_baton->real_baton);}static svn_error_t *close_file(void *baton, const char *text_checksum, apr_pool_t *pool){  struct item_baton *fb = baton;  fprintf(stderr, "   Closing : %s\n", fb->path);  return (*fb->eb->real_editor->close_file)(fb->real_baton,                                            text_checksum, pool);}static svn_error_t *change_file_prop(void *file_baton,                 const char *name,                 const svn_string_t *value,                 apr_pool_t *pool){  struct item_baton *fb = file_baton;  fprintf(stderr, "      PropSet (%s=%s)\n", name, value ? value->data : "");  return (*fb->eb->real_editor->change_file_prop)(fb->real_baton,                                                  name, value, pool);}static svn_error_t *apply_textdelta(void *file_baton,                const char *base_checksum,                apr_pool_t *pool,                svn_txdelta_window_handler_t *handler,                void **handler_baton){  struct item_baton *fb = file_baton;  fprintf(stderr, "      Transmitting text...\n");  return (*fb->eb->real_editor->apply_textdelta)(fb->real_baton,                                                 base_checksum, pool,                                                 handler, handler_baton);}static svn_error_t *close_edit(void *edit_baton, apr_pool_t *pool){  struct edit_baton *eb = edit_baton;  fprintf(stderr, "TEST EDIT COMPLETED\n");  return (*eb->real_editor->close_edit)(eb->real_eb, pool);}static svn_error_t *add_directory(const char *path,              void *parent_baton,              const char *copyfrom_path,              svn_revnum_t copyfrom_revision,              apr_pool_t *pool,              void **baton){  struct item_baton *db = parent_baton;  struct item_baton *new_baton = make_baton(db->eb, NULL, path, pool);  const char *copystuffs = "";  if (copyfrom_path && SVN_IS_VALID_REVNUM(copyfrom_revision))    copystuffs = apr_psprintf(pool,                               " (copied from %s:%ld)",                              copyfrom_path,                              copyfrom_revision);  fprintf(stderr, "   Adding  : %s%s\n", path, copystuffs);  *baton = new_baton;  return (*db->eb->real_editor->add_directory)(path,                                               db->real_baton,                                               copyfrom_path,                                               copyfrom_revision,                                               pool,                                               &new_baton->real_baton);}static svn_error_t *open_directory(const char *path,               void *parent_baton,               svn_revnum_t base_revision,               apr_pool_t *pool,               void **baton){  struct item_baton *db = parent_baton;  struct item_baton *new_baton = make_baton(db->eb, NULL, path, pool);  fprintf(stderr, "   Opening : %s\n", path);  *baton = new_baton;  return (*db->eb->real_editor->open_directory)(path, db->real_baton,                                                base_revision, pool,                                                &new_baton->real_baton);}static svn_error_t *change_dir_prop(void *dir_baton,                const char *name,                const svn_string_t *value,                apr_pool_t *pool){  struct item_baton *db = dir_baton;  fprintf(stderr, "      PropSet (%s=%s)\n", name, value ? value->data : "");  return (*db->eb->real_editor->change_dir_prop)(db->real_baton,                                                 name, value, pool);}static svn_error_t *close_directory(void *baton, apr_pool_t *pool){  struct item_baton *db = baton;  fprintf(stderr, "   Closing : %s\n", db->path);  return (*db->eb->real_editor->close_directory)(db->real_baton, pool);}static svn_error_t *abort_edit(void *edit_baton, apr_pool_t *pool){  struct edit_baton *eb = edit_baton;  fprintf(stderr, "TEST EDIT ABORTED\n");  return (*eb->real_editor->abort_edit)(eb->real_eb, pool);}static svn_error_t *get_test_editor(const svn_delta_editor_t **editor,                void **edit_baton,                const svn_delta_editor_t *real_editor,                void *real_eb,                const char *base_url,                apr_pool_t *pool){  svn_delta_editor_t *ed = svn_delta_default_editor(pool);  struct edit_baton *eb = apr_pcalloc(pool, sizeof(*eb));  eb->path = apr_pstrdup(pool, base_url);  eb->real_editor = real_editor;  eb->real_eb = real_eb;  /* We don't implement absent_file() or absent_directory() in this     editor, because presumably commit would never send that. */  ed->set_target_revision = set_target_revision;  ed->open_root = open_root;  ed->add_directory = add_directory;  ed->open_directory = open_directory;  ed->close_directory = close_directory;  ed->add_file = add_file;  ed->open_file = open_file;  ed->close_file = close_file;  ed->delete_entry = delete_entry;  ed->apply_textdelta = apply_textdelta;  ed->change_dir_prop = change_dir_prop;  ed->change_file_prop = change_file_prop;  ed->close_edit = close_edit;  ed->abort_edit = abort_edit;  *editor = ed;  *edit_baton = eb;  return SVN_NO_ERROR;}#endif /* SVN_CLIENT_COMMIT_DEBUG */svn_error_t * svn_client__get_log_msg(const char **log_msg,                                      const char **tmp_file,                                      const apr_array_header_t *commit_items,                                      svn_client_ctx_t *ctx,                                      apr_pool_t *pool){    /* client provided new callback function. simply forward call to him */    if (ctx->log_msg_func2)      return (*ctx->log_msg_func2)(log_msg, tmp_file, commit_items,                                   ctx->log_msg_baton2, pool);    /* client want use old (pre 1.3) API, therefore build     * svn_client_commit_item_t array */    if (ctx->log_msg_func)      {        int i;        svn_error_t * err;        svn_client_commit_item_t *old_item;        apr_pool_t * subpool = svn_pool_create(pool);        apr_array_header_t *old_commit_items          = apr_array_make(subpool, commit_items->nelts, sizeof(old_item));        for (i = 0; i < commit_items->nelts; i++)          {            svn_client_commit_item2_t *item =              APR_ARRAY_IDX(commit_items, i, svn_client_commit_item2_t *);            old_item = apr_pcalloc(subpool, sizeof(*old_item));            old_item->path = item->path;            old_item->kind = item->kind;            old_item->url = item->url;            /* pre 1.3 API use revision field for copyfrom_rev and revision             * depeding of copyfrom_url */            old_item->revision = item->copyfrom_url ?              item->copyfrom_rev : item->revision;            old_item->copyfrom_url = item->copyfrom_url;            old_item->state_flags = item->state_flags;            old_item->wcprop_changes = item->wcprop_changes;            APR_ARRAY_PUSH(old_commit_items, svn_client_commit_item_t *)              = old_item;          }        err = (*ctx->log_msg_func)(log_msg, tmp_file, old_commit_items,          ctx->log_msg_baton, pool);        svn_pool_destroy(subpool);        return err;      }    *log_msg = "";    *tmp_file = NULL;    return SVN_NO_ERROR;}

⌨️ 快捷键说明

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