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

📄 add.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
      if ((!no_ignore) && svn_cstring_match_glob_list(this_entry.name,                                                      ignores))         continue;      /* Construct the full path of the entry. */      fullpath = svn_path_join(dirname, this_entry.name, subpool);      /* Recurse on directories; add files; ignore the rest. */      if (this_entry.filetype == APR_DIR)        {          SVN_ERR(add_dir_recursive(fullpath, dir_access, force,                                    no_ignore, ctx, subpool));        }      else if (this_entry.filetype != APR_UNKFILE)        {          err = add_file(fullpath, ctx, dir_access, subpool);          if (err && err->apr_err == SVN_ERR_ENTRY_EXISTS && force)            svn_error_clear(err);          else if (err)            return err;        }      /* Clean out the per-iteration pool. */      svn_pool_clear(subpool);    }  /* Check that the loop exited cleanly. */  if (! (APR_STATUS_IS_ENOENT(err->apr_err)))    {      return svn_error_createf        (err->apr_err, err,         _("Error during recursive add of '%s'"),         svn_path_local_style(dirname, subpool));    }  else  /* Yes, it exited cleanly, so close the dir. */    {      apr_status_t apr_err;      svn_error_clear(err);      apr_err = apr_dir_close(dir);      if (apr_err)        return svn_error_wrap_apr          (apr_err, _("Can't close directory '%s'"),           svn_path_local_style(dirname, subpool));    }  /* Opened by svn_wc_add */  SVN_ERR(svn_wc_adm_close(dir_access));  /* Destroy the per-iteration pool. */  svn_pool_destroy(subpool);  return SVN_NO_ERROR;}/* The main logic of the public svn_client_add;  the only difference   is that this function uses an existing access baton.   (svn_client_add just generates an access baton and calls this func.) */static svn_error_t *add(const char *path,     svn_boolean_t recursive,    svn_boolean_t force,    svn_boolean_t no_ignore,    svn_wc_adm_access_t *adm_access,    svn_client_ctx_t *ctx,    apr_pool_t *pool){  svn_node_kind_t kind;  svn_error_t *err;  SVN_ERR(svn_io_check_path(path, &kind, pool));  if ((kind == svn_node_dir) && recursive)    err = add_dir_recursive(path, adm_access, force, no_ignore, ctx, pool);  else if (kind == svn_node_file)    err = add_file(path, ctx, adm_access, pool);  else    err = svn_wc_add2(path, adm_access, NULL, SVN_INVALID_REVNUM,                      ctx->cancel_func, ctx->cancel_baton,                      ctx->notify_func2, ctx->notify_baton2, pool);  /* Ignore SVN_ERR_ENTRY_EXISTS when FORCE is set.  */  if (err && err->apr_err == SVN_ERR_ENTRY_EXISTS && force)    {      svn_error_clear(err);      err = SVN_NO_ERROR;    }  return err;}svn_error_t *svn_client_add3(const char *path,                 svn_boolean_t recursive,                svn_boolean_t force,                svn_boolean_t no_ignore,                svn_client_ctx_t *ctx,                apr_pool_t *pool){  svn_error_t *err, *err2;  svn_wc_adm_access_t *adm_access;  const char *parent_path = svn_path_dirname(path, pool);  SVN_ERR(svn_wc_adm_open3(&adm_access, NULL, parent_path,                           TRUE, 0, ctx->cancel_func, ctx->cancel_baton,                           pool));  err = add(path, recursive, force, no_ignore, adm_access, ctx, pool);    err2 = svn_wc_adm_close(adm_access);  if (err2)    {      if (err)        svn_error_clear(err2);      else        err = err2;    }  return err;}svn_error_t *svn_client_add2(const char *path,                svn_boolean_t recursive,                svn_boolean_t force,                svn_client_ctx_t *ctx,                apr_pool_t *pool){  return svn_client_add3(path, recursive, force, FALSE, ctx, pool);}svn_error_t *svn_client_add(const char *path,                svn_boolean_t recursive,               svn_client_ctx_t *ctx,               apr_pool_t *pool){  return svn_client_add3(path, recursive, FALSE, FALSE, ctx, pool);}static svn_error_t *path_driver_cb_func(void **dir_baton,                    void *parent_baton,                    void *callback_baton,                    const char *path,                    apr_pool_t *pool){  const svn_delta_editor_t *editor = callback_baton;  SVN_ERR(svn_path_check_valid(path, pool));  return editor->add_directory(path, parent_baton, NULL,                               SVN_INVALID_REVNUM, pool, dir_baton);}static svn_error_t *mkdir_urls(svn_commit_info_t **commit_info_p,           const apr_array_header_t *paths,           svn_client_ctx_t *ctx,           apr_pool_t *pool){  svn_ra_session_t *ra_session;  const svn_delta_editor_t *editor;  void *edit_baton;  void *commit_baton;  const char *log_msg;  apr_array_header_t *targets;  svn_error_t *err;  const char *common;  int i;  /* Condense our list of mkdir targets. */  SVN_ERR(svn_path_condense_targets(&common, &targets, paths, FALSE, pool));  if (! targets->nelts)    {      const char *bname;      svn_path_split(common, &common, &bname, pool);      APR_ARRAY_PUSH(targets, const char *) = bname;    }  else    {      svn_boolean_t resplit = FALSE;      /* We can't "mkdir" the root of an editor drive, so if one of         our targets is the empty string, we need to back everything         up by a path component. */      for (i = 0; i < targets->nelts; i++)        {          const char *path = APR_ARRAY_IDX(targets, i, const char *);          if (! *path)            {              resplit = TRUE;              break;            }        }      if (resplit)        {          const char *bname;          svn_path_split(common, &common, &bname, pool);          for (i = 0; i < targets->nelts; i++)            {              const char *path = APR_ARRAY_IDX(targets, i, const char *);              path = svn_path_join(bname, path, pool);              APR_ARRAY_IDX(targets, i, const char *) = path;            }        }    }  /* Create new commit items and add them to the array. */  if (ctx->log_msg_func || ctx->log_msg_func2)    {      svn_client_commit_item2_t *item;      const char *tmp_file;      apr_array_header_t *commit_items         = apr_array_make(pool, targets->nelts, sizeof(item));                for (i = 0; i < targets->nelts; i++)        {          const char *path = APR_ARRAY_IDX(targets, i, const char *);          item = apr_pcalloc(pool, sizeof(*item));          item->url = svn_path_join(common, path, pool);          item->state_flags = SVN_CLIENT_COMMIT_ITEM_ADD;          APR_ARRAY_PUSH(commit_items, svn_client_commit_item2_t *) = item;        }      SVN_ERR(svn_client__get_log_msg(&log_msg, &tmp_file, commit_items,                                      ctx, pool));      if (! log_msg)        return SVN_NO_ERROR;    }  else    log_msg = "";  /* Open an RA session for the URL. Note that we don't have a local     directory, nor a place to put temp files. */  SVN_ERR(svn_client__open_ra_session_internal(&ra_session, common, NULL,                                               NULL, NULL, FALSE, TRUE,                                               ctx, pool));  /* URI-decode each target. */  for (i = 0; i < targets->nelts; i++)    {      const char *path = APR_ARRAY_IDX(targets, i, const char *);      path = svn_path_uri_decode(path, pool);      APR_ARRAY_IDX(targets, i, const char *) = path;    }  /* Fetch RA commit editor */  SVN_ERR(svn_client__commit_get_baton(&commit_baton, commit_info_p, pool));  SVN_ERR(svn_ra_get_commit_editor2(ra_session, &editor, &edit_baton,                                    log_msg, svn_client__commit_callback,                                    commit_baton,                                     NULL, TRUE, /* No lock tokens */                                    pool));    /* Call the path-based editor driver. */  err = svn_delta_path_driver(editor, edit_baton, SVN_INVALID_REVNUM,                               targets, path_driver_cb_func,                               (void *)editor, pool);  if (err)    {      /* At least try to abort the edit (and fs txn) before throwing err. */      svn_error_clear(editor->abort_edit(edit_baton, pool));      return err;    }  /* Close the edit. */  SVN_ERR(editor->close_edit(edit_baton, pool));  return SVN_NO_ERROR;}svn_error_t *svn_client_mkdir2(svn_commit_info_t **commit_info_p,                  const apr_array_header_t *paths,                  svn_client_ctx_t *ctx,                  apr_pool_t *pool){  if (! paths->nelts)    return SVN_NO_ERROR;    if (svn_path_is_url(APR_ARRAY_IDX(paths, 0, const char *)))    {      SVN_ERR(mkdir_urls(commit_info_p, paths, ctx, pool));    }  else    {      /* This is a regular "mkdir" + "svn add" */      apr_pool_t *subpool = svn_pool_create(pool);      svn_error_t *err;      int i;      for (i = 0; i < paths->nelts; i++)        {          const char *path = APR_ARRAY_IDX(paths, i, const char *);          svn_pool_clear(subpool);          /* See if the user wants us to stop. */          if (ctx->cancel_func)            SVN_ERR(ctx->cancel_func(ctx->cancel_baton));          SVN_ERR(svn_io_dir_make(path, APR_OS_DEFAULT, subpool));          err = svn_client_add3(path, FALSE, FALSE, FALSE, ctx, subpool);          /* We just created a new directory, but couldn't add it to             version control. Don't leave unversioned directoies behind. */          if (err)            {              /* ### If this returns an error, should we link it onto                 err instead, so that the user is warned that we just                 created an unversioned directory? */              svn_error_clear(svn_io_remove_dir(path, subpool));              return err;            }        }      svn_pool_destroy(subpool);    }  return SVN_NO_ERROR;}svn_error_t *svn_client_mkdir(svn_client_commit_info_t **commit_info_p,                 const apr_array_header_t *paths,                 svn_client_ctx_t *ctx,                 apr_pool_t *pool){  svn_commit_info_t *commit_info = NULL;  svn_error_t *err;  err = svn_client_mkdir2(&commit_info, paths, ctx, pool);  /* These structs have the same layout for the common fields. */  *commit_info_p = (svn_client_commit_info_t *) commit_info;  return err;}

⌨️ 快捷键说明

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